bsd-init.in 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2016 Nagios(R) Core(TM) Development Team
  4. #
  5. # PROVIDE: nrpe
  6. # REQUIRE: LOGIN
  7. # KEYWORD: shutdown
  8. #
  9. # Add the following lines to /etc/rc.conf to enable nrpe:
  10. #
  11. # nrpe_enable (bool): Set to "NO" by default.
  12. # Set it to "YES" to enable nrpe.
  13. # nrpe_flags (str): Set to "" by default.
  14. # nrpe_configfile (str): Set to "@pkgsysconfdir@/nrpe.cfg" by default.
  15. #
  16. . /etc/rc.subr
  17. sig_reload=HUP
  18. nrpe_enable=${nrpe_enable:-"NO"}
  19. command=${nrpe_program:-"@sbindir@/nrpe"}
  20. command_args="-c ${nrpe_configfile} -d"
  21. extra_commands=reload
  22. pidfile=${pidfile:-"/var/run/nrpe.pid"}
  23. nrpe_configfile=${nrpe_configfile:-"@pkgsysconfdir@/nrpe.cfg"}
  24. name=nrpe
  25. rcvar=nrpe_enable
  26. load_rc_config "${name}"
  27. required_files="${nrpe_configfile}"
  28. start_precmd=nrpe_prestart
  29. stop_precmd=find_pidfile
  30. find_pidfile()
  31. {
  32. [ -n "$nrpe_pidfile" ] &&
  33. warn "No longer necessary to set nrpe_pidfile in rc.conf[.local]"
  34. if getpidfile_from_conf pid_file ${nrpe_configfile}; then
  35. pidfile="$_pidfile_from_conf"
  36. else
  37. pidfile='%%PIDDIR%%/nrpe.pid'
  38. }
  39. nrpe_prestart()
  40. {
  41. find_pidfile
  42. install -d -o ${nrpe_user:-nagios} ${pidfile%/*}
  43. }
  44. run_rc_command "$1"