summaryrefslogtreecommitdiff
path: root/www/gitea/files/gitea.in
blob: affda78defa1861d3200187e35c10e19ae2a301c (plain) (blame)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh

# PROVIDE: gitea
# REQUIRE: NETWORKING SYSLOG
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable gitea:
#
#gitea_enable="YES"

. /etc/rc.subr

name="gitea"
rcvar="gitea_enable"

load_rc_config $name

: ${gitea_user:="%%GITUSER%%"}
: ${gitea_enable:="NO"}
: ${gitea_configcheck_enable:="YES"}
: ${gitea_facility:="daemon"}
: ${gitea_priority:="info"}
: ${gitea_shared:="%%PREFIX%%/share/${name}"}
: ${gitea_custom:="%%PREFIX%%/etc/${name}"}

command="%%PREFIX%%/sbin/${name} web"
procname="%%PREFIX%%/sbin/${name}"
githome="$(eval echo ~${gitea_user})"

pidfile="/var/run/${name}.pid"

start_cmd="${name}_start"
start_precmd="${name}_prestart"

gitea_start() {
	for d in /var/db/gitea /var/log/gitea; do
		if [ ! -e "$d" ]; then
			mkdir "$d"
			chown ${gitea_user} "$d"
		fi
	done
	/usr/sbin/daemon %%DAEMONARGS%% \
		-u ${gitea_user} -p ${pidfile} \
		-l daemon -s warning \
		/usr/bin/env -i \
		"GITEA_WORK_DIR=${gitea_shared}" \
		"GITEA_CUSTOM=${gitea_custom}" \
		"HOME=${githome}" \
		"PATH=%%PREFIX%%/bin:${PATH}" \
		"USER=${gitea_user}" \
		$command
}

gitea_prestart() {
	if checkyesno gitea_configcheck_enable; then
		if su -m ${gitea_user} -c "%%PREFIX%%/sbin/${name} doctor check >/dev/null"; then
		else
			echo "cannot start ${name} because of configuration errors. Run" >&2
			echo "    su -m git -c '${name} doctor check'" >&2
			echo "for further details"
			return 1
		fi
	fi
}

run_rc_command "$1"