apcupsd.init 665 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. #PKG apcupsd
  3. #INIT 15
  4. . /etc/rc.conf
  5. pidfile=$(echo "$apcupsd_flags" | \
  6. sed -n 's/.*\(-P\|--pid-file\) \([^ ]\+\).*/\2/p')
  7. [ "$pidfile" ] || pidfile="/var/run/apcupsd.pid"
  8. case $1 in
  9. autostop) ;;
  10. autostart)
  11. test x"${apcupsd:-NO}" = x"NO" && exit 0
  12. test x"$apcupsd" = x"DAEMON" && test -x /bin/mksh && exec mksh -T- $0 start
  13. exec sh $0 start
  14. ;;
  15. start)
  16. mkdir -p /var/lock
  17. /usr/sbin/apcupsd $apcupsd_flags
  18. ;;
  19. stop)
  20. if [ -f "$pidfile" ]; then
  21. kill $(<$pidfile)
  22. rm -f $pidfile
  23. else
  24. kill $(pgrep -f /usr/sbin/apcupsd)
  25. fi
  26. ;;
  27. restart)
  28. sh $0 stop
  29. sleep 1
  30. sh $0 start
  31. ;;
  32. *)
  33. echo "usage: $0 (start | stop | restart)"
  34. exit 1
  35. esac
  36. exit $?