openrc-init 991 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/sbin/runscript
  2. #
  3. # Copyright (c) 2016 Nagios(R) Core(TM) Development Team
  4. #
  5. # Start/stop the nrpe daemon.
  6. #
  7. # Goes in /etc/init.d - Config is in /etc/conf.d/nrpe
  8. opts="reload"
  9. # extra_started_commands="reload" use this if OpenRC >= 0.9.4
  10. NRPE_BIN="${exec_prefix}/sbin/nrpe"
  11. NRPE_PID="/var/run/nrpe/nrpe.pid"
  12. depend() {
  13. use logger dns net localmount netmount nfsmount
  14. }
  15. checkconfig() {
  16. # Make sure the config file exists
  17. if [ ! -f $NRPE_CFG ]; then
  18. eerror "You need to setup $NRPE_CFG.
  19. return 1
  20. fi
  21. return 0
  22. }
  23. start() {
  24. checkconfig || return 1
  25. ebegin "Starting nrpe"
  26. # Make sure we have a sane current directory
  27. cd /
  28. start-stop-daemon --start --exec $NRPE_BIN --pidfile $PID_FILE \
  29. -- -c $NRPE_CFG -d $NRPE_OPTS
  30. eend $?
  31. }
  32. stop() {
  33. ebegin "Stopping nrpe"
  34. start-stop-daemon --stop --exec $NRPE_BIN --pidfile $PID_FILE
  35. eend $?
  36. }
  37. reload() {
  38. ebegin "Reloading nrpe"
  39. start-stop-daemon --stop --oknodo --exec $NRPE_BIN \
  40. --pidfile $PID_FILE --signal HUP
  41. eend $?
  42. }