aboutsummaryrefslogtreecommitdiffstats
path: root/community/caddy/caddy.initd
blob: 22d9fab90a09381f740ce45b325f2411738d3b3e (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
#!/sbin/openrc-run

name="Caddy webserver"
command="/usr/sbin/caddy"
command_args="$CADDY_OPTS"
pidfile="/var/run/caddy.pid"
command_background=yes
command_user=caddy:caddy
extra_commands="checkconfig"
extra_started_commands="reload"

depend() {
	need net localmount
	after firewall
}

checkconfig() {
	ebegin "Checking configuration for $RC_SVCNAME"
	su -s /bin/sh ${command_user%:*} -c "$command $command_args -validate"
	eend $?
}

reload() {
	checkconfig || return $?
	ebegin "Reloading $RC_SVCNAME"
	case "$supervisor" in
		"") start-stop-daemon --signal USR1 --pidfile "$pidfile";;
		supervise-daemon) supervise-daemon $RC_SVCNAME --signal USR1;;
		*) eend 1 "Unsupported supervisor: $supervisor";;
	esac
	eend $?
}

start_pre() {
	if [ "$RC_CMD" != "restart" ]; then
		checkconfig || return $?
	fi
}

stop_pre() {
	if [ "$RC_CMD" == "restart" ]; then
		checkconfig || return $?
	fi
}