upsd.init 549 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. #PKG nut
  3. #INIT 60
  4. . /etc/rc.conf
  5. case $1 in
  6. autostop) ;;
  7. autostart)
  8. test x"${upsd:-NO}" = x"NO" && exit 0
  9. test x"$upsd" = x"DAEMON" && test -x /bin/mksh && exec mksh -T- $0 start
  10. exec sh $0 start
  11. ;;
  12. start)
  13. [ -d /var/state/ups ] || mkdir -p /var/state/ups
  14. /usr/bin/upsdrvctl start || exit 1
  15. /usr/sbin/upsd || exit 2
  16. ;;
  17. stop)
  18. /usr/sbin/upsd -c stop || kill $(pgrep -f /usr/sbin/upsd)
  19. /usr/bin/upsdrvctl stop
  20. ;;
  21. restart)
  22. sh $0 stop
  23. sleep 1
  24. sh $0 start
  25. ;;
  26. *)
  27. echo "Usage: $0 {start | stop | restart}"
  28. exit 1
  29. ;;
  30. esac
  31. exit $?