forked from ports/contrib
47 lines
1.0 KiB
Bash
47 lines
1.0 KiB
Bash
#!/bin/sh
|
|
#@ acpid2 startup script.
|
|
|
|
RD=/var/run
|
|
CONFDIR=/etc/acpi/events
|
|
PID=${RD}/acpid.pid
|
|
LCK=${RD}/acpid.lck
|
|
SCK=${RD}/acpid.socket
|
|
|
|
SSD=/sbin/start-stop-daemon
|
|
PROG=/usr/sbin/acpid
|
|
OPTS="-c ${CONFDIR} -L ${LCK} -p ${PID} -s ${SCK}"
|
|
|
|
case "${1}" in
|
|
start)
|
|
exec "${SSD}" --start --pidfile "${PID}" --exec "${PROG}" -- ${OPTS}
|
|
;;
|
|
stop)
|
|
"${SSD}" --stop --retry 10 --pidfile "${PID}" --exec "${PROG}"
|
|
e=${?}
|
|
[ ${e} -eq 0 ] && rm -f ${RD}/acpid.socket
|
|
exit ${e}
|
|
;;
|
|
reload)
|
|
"${SSD}" --status --pidfile "${PID}" --exec "${PROG}" &&
|
|
kill -HUP $(cat ${PID})
|
|
;;
|
|
restart)
|
|
"${SSD}" --status --pidfile "${PID}" --exec "${PROG}" && "${0}" stop
|
|
exec "${0}" start
|
|
;;
|
|
status)
|
|
"${SSD}" --status --pidfile "${PID}" --exec "${PROG}"
|
|
e=${?}
|
|
case ${e} in
|
|
0) echo "${PROG} is running with pid $(cat ${PID})";;
|
|
1) echo "${PROG} is not running but the pid file ${PID} exists";;
|
|
3) echo "${PROG} is not running";;
|
|
4) echo "Unable to determine the program status";;
|
|
esac
|
|
exit ${e}
|
|
;;
|
|
*)
|
|
echo "usage: ${0} start|stop|reload|restart|status"
|
|
;;
|
|
esac
|