diff options
Diffstat (limited to 'package/apcupsd/files/apcupsd.init')
-rw-r--r-- | package/apcupsd/files/apcupsd.init | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/package/apcupsd/files/apcupsd.init b/package/apcupsd/files/apcupsd.init new file mode 100644 index 000000000..a9817f1be --- /dev/null +++ b/package/apcupsd/files/apcupsd.init @@ -0,0 +1,38 @@ +#!/bin/sh +#PKG apcupsd +#INIT 15 +. /etc/rc.conf + +pidfile=$(echo "$apcupsd_flags" | \ + sed -n 's/.*\(-P\|--pid-file\) \([^ ]\+\).*/\2/p') +[ "$pidfile" ] || pidfile="/var/run/apcupsd.pid" + +case $1 in +autostop) ;; +autostart) + test x"${apcupsd:-NO}" = x"NO" && exit 0 + test x"$apcupsd" = x"DAEMON" && test -x /bin/mksh && exec mksh -T- $0 start + exec sh $0 start + ;; +start) + mkdir -p /var/lock + /usr/sbin/apcupsd $apcupsd_flags + ;; +stop) + if [ -f "$pidfile" ]; then + kill $(<$pidfile) + rm -f $pidfile + else + kill $(pgrep -f /usr/sbin/apcupsd) + fi + ;; +restart) + sh $0 stop + sleep 1 + sh $0 start + ;; +*) + echo "usage: $0 (start | stop | restart)" + exit 1 +esac +exit $? |