default-init.in 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2016 Nagios(R) Core(TM) Development Team
  4. #
  5. # chkconfig: - 80 30
  6. # description: Starts and stops the Nagios Remote Plugin Executor \
  7. # so a remote nagios server can run plugins on this host
  8. #
  9. ### BEGIN INIT INFO
  10. # Provides: nrpe
  11. # Required-Start: $local_fs $remote_fs $syslog $network $time
  12. # Required-Stop: $local_fs $remote_fs $syslog $network
  13. # Default-Start: 3 5
  14. # Default-Stop: 0 1 2 4 6
  15. # Short-Description: Starts and stops the Nagios Remote Plugin Executor
  16. # Description: Starts and stops the Nagios Remote Plugin Executor
  17. # so a remote nagios server can run plugins on this host
  18. ### END INIT INFO
  19. NRPE_BIN=@sbindir@/nrpe
  20. NRPE_CFG=@pkgsysconfdir@/nrpe.cfg
  21. LOCK_DIR=@subsyslockdir@
  22. LOCK_FILE=@subsyslockfile@
  23. PID_FILE=@piddir@/nrpe.pid
  24. test -x $NRPE_BIN || exit 5
  25. RETVAL=0
  26. # Default these commands/functions to RedHat/CentOS etc. values
  27. MSG_CMD="echo -n"
  28. START_CMD="daemon --pidfile $PID_FILE"
  29. TERM_CMD="killproc -p $PID_FILE $NRPE_BIN -TERM"
  30. HUP_CMD="killproc -p $PID_FILE $NRPE_BIN -HUP"
  31. PRT_STAT="echo"
  32. STAT_MSG="echo -n Checking for nrpe daemon "
  33. STAT_CMD="status nrpe"
  34. EXIT_CMD="exit"
  35. # Source the function library
  36. if [ -f /etc/rc.status ]; then
  37. . /etc/rc.status
  38. # Set these commands/functions to SuSE etc. values
  39. START_CMD="startproc -p $PID_FILE"
  40. TERM_CMD="killproc -p $PID_FILE -TERM $NRPE_BIN"
  41. HUP_CMD="killproc -p $PID_FILE -HUP $NRPE_BIN"
  42. PRT_STAT="rc_status -v -r"
  43. STAT_CMD="checkproc -p $PID_FILE $NRPE_BIN"
  44. EXIT_CMD="rc_exit"
  45. rc_reset
  46. elif [ -f /etc/rc.d/init.d/functions ]; then
  47. . /etc/rc.d/init.d/functions
  48. elif [ -f /etc/init.d/functions ]; then
  49. . /etc/init.d/functions
  50. elif [ -f /lib/lsb/init-functions ]; then
  51. . /lib/lsb/init-functions
  52. MSG_CMD="log_daemon_msg"
  53. START_CMD="start_daemon -p $PID_FILE"
  54. PRT_STAT="log_end_msg"
  55. STAT_MSG=
  56. STAT_CMD="status_of_proc -p $PID_FILE $NRPE_BIN nrpe"
  57. elif [ -f /etc/rc.d/functions ]; then
  58. . /etc/rc.d/functions
  59. fi
  60. # See how we were called.
  61. case "$1" in
  62. start)
  63. # Start daemons.
  64. $MSG_CMD "Starting nrpe "
  65. $START_CMD $NRPE_BIN -c $NRPE_CFG -d
  66. RETVAL=$?
  67. if test $PRT_STAT = log_end_msg; then
  68. $PRT_STAT $RETVAL
  69. else
  70. $PRT_STAT
  71. fi
  72. if [ $RETVAL = 0 ]; then
  73. [ -d $LOCK_DIR ] && touch $LOCK_FILE || true
  74. fi
  75. ;;
  76. stop)
  77. # Stop daemons.
  78. $MSG_CMD "Shutting down nrpe "
  79. $TERM_CMD
  80. RETVAL=$?
  81. if test $PRT_STAT = log_end_msg; then
  82. $PRT_STAT $RETVAL
  83. else
  84. $PRT_STAT
  85. fi
  86. if [ $RETVAL = 0 ]; then
  87. [ -d $LOCK_DIR ] && rm -f $LOCK_FILE
  88. fi
  89. ;;
  90. restart|force-reload)
  91. $0 stop
  92. $0 start
  93. RETVAL=$?
  94. ;;
  95. reload)
  96. $MSG_CMD "Reloading nrpe "
  97. $HUP_CMD
  98. RETVAL=$?
  99. if test $PRT_STAT = log_end_msg; then
  100. $PRT_STAT $RETVAL
  101. else
  102. $PRT_STAT
  103. fi
  104. ;;
  105. try-restart|condrestart)
  106. $STAT_CMD || exit 0
  107. $0 stop
  108. $0 start
  109. RETVAL=$?
  110. ;;
  111. status)
  112. $STAT_MSG
  113. $STAT_CMD
  114. RETVAL=$?
  115. if test $PRT_STAT != log_end_msg; then
  116. $PRT_STAT
  117. fi
  118. ;;
  119. *)
  120. echo "Usage: nrpe {start|stop|restart|reload|try-restart|condrestart|status}"
  121. exit 1
  122. esac
  123. $EXIT_CMD $RETVAL