apcupsd.init.4 926 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2013 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. INSTANCE="${SVCNAME#*.}"
  5. if [ -z "${INSTANCE}" ] || [ "${SVCNAME}" = "apcupsd" ]; then
  6. INSTANCE="apcupsd"
  7. fi
  8. dir="/run/apcupsd"
  9. depend() {
  10. use net
  11. }
  12. start_pre() {
  13. checkpath -d -m 0775 -o root:uucp ${dir}
  14. }
  15. start() {
  16. rm -f /etc/apcupsd/powerfail
  17. export SERVICE="${SVCNAME}"
  18. if [ ! -d "${dir}" ]; then
  19. einfo " Creating ${dir}"
  20. /bin/mkdir -p "${dir}"
  21. /bin/chown root:uucp "${dir}"
  22. fi
  23. ebegin "Starting APC UPS daemon"
  24. start-stop-daemon \
  25. --start --pidfile "${dir}/${SVCNAME}.pid" \
  26. --exec /sbin/apcupsd -- \
  27. -f "/etc/apcupsd/${INSTANCE}.conf" \
  28. -P "${dir}/${SVCNAME}.pid"
  29. eend $?
  30. }
  31. stop() {
  32. ebegin "Stopping APC UPS daemon"
  33. start-stop-daemon \
  34. --stop --pidfile "${dir}/${SVCNAME}.pid" \
  35. --retry TERM/5/TERM/5 \
  36. --exec /sbin/apcupsd
  37. eend $?
  38. }