summaryrefslogtreecommitdiffstats
path: root/scripts/init/freebsd/gogs
blob: 8fc0359eff19f998f62d6690a07ca1e7aeeff95b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: gogs
# REQUIRE: NETWORKING SYSLOG
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable gogs:
#
#gogs_enable="YES"

. /etc/rc.subr

name="gogs"
rcvar="gogs_enable"

load_rc_config $name

: ${gogs_user:="git"}
: ${gogs_enable:="NO"}
: ${gogs_directory:="/home/git"}

command="${gogs_directory}/gogs web"
procname="$(echo $command |cut -d' ' -f1)"

pidfile="${gogs_directory}/${name}.pid"

start_cmd="${name}_start"
stop_cmd="${name}_stop"

gogs_start() {
	cd ${gogs_directory}
	export USER=${gogs_user}
	export HOME=/usr/home/${gogs_user}
	/usr/sbin/daemon -f -u ${gogs_user} -p ${pidfile} $command
}

gogs_stop() {
	if [ ! -f $pidfile ]; then
		echo "GITEA PID File not found. Maybe GITEA is not running?"
	else
		kill $(cat $pidfile)
	fi
}

run_rc_command "$1"