summaryrefslogtreecommitdiff
blob: a5c6189b56b18ff407b8298ac7befc291f3586c9 (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
#!/sbin/openrc-run

NAME=${SVCNAME##*.}
if [ -n "${NAME}" -a "${SVCNAME}" != "automatic" ]; then
    PID="/run/automatic.${NAME}.pid"
    PNAME=$(echo ${RC_SVCNAME} | sed 's/\..*//g')
    CONF_DEFAULT="/etc/conf.d/automatic.${NAME}"
else
    PID="/run/automatic.pid"
    PNAME=${RC_SVCNAME}
    CONF_DEFAULT="/etc/conf.d/automatic"
fi
CONF=${CONF:-${CONF_DEFAULT}}
EXEC=${EXEC:-/usr/bin/automatic}

depend() {
	need net
	provide automatic
}

start() {
	ebegin "Starting automatic"
	start-stop-daemon --start --quiet --make-pidfile --pidfile ${PID} --exec ${EXEC} -- ${OPTS} ${CONFIG}
	eend $?
}

start_post() {
	pgrep -n $(echo ${PNAME}) > ${PID}
}

stop() {
	ebegin "Stopping automatic"
	start-stop-daemon --stop --quiet --pidfile ${PID}
	rm -f ${PID}
	eend $?
}