aboutsummaryrefslogtreecommitdiffstats
path: root/main/mini_httpd/mini_httpd.initd
blob: bd8d62fd6024970ec4c3a5997e9792a6c9d4689e (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
#!/sbin/openrc-run

description="Small HTTP server"
extra_started_commands="reload"
start_stop_daemon_args="--quiet"

cfgfile=/etc/mini_httpd/$RC_SVCNAME.conf
pidfile=/run/mini_httpd/$RC_SVCNAME.pid
command=/usr/sbin/mini_httpd
required_files="$cfgfile"

depend() {
	need net
	after firewall
}

start_pre() {
	ebegin
	checkpath -d ${pidfile%/*}
	local logfile=$(awk -F= '$1 == "logfile" { print $2 }' $cfgfile 2>/dev/null)
	[ -n "$logfile" ] && checkpath -d ${logfile%/*}
	command_args="-i $pidfile -C $cfgfile ${logfile:+-l $logfile} $command_args"
	$command -V -C $cfgfile >/dev/null
	eend $?
}

reload() {
	ebegin "Reloading $RC_SVCNAME configuration"
	start-stop-daemon --signal HUP --pidfile $pidfile
	eend $?
}