7898122cf130edc8a7a17e99c6a1d8963fc21ddc
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides: nagixsc_http2nagios
4 # Required-Start: $local_fs $remote_fs
5 # Required-Stop: $local_fs $remote_fs
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Short-Description: Nag(IX)SC HTTP Pull
9 # Description: Nag(IX)SC HTTP Pull
10 ### END INIT INFO
12 # Author: Sven Velt <sven@velt.de>
14 # PATH should only include /usr/* if it runs after the mountnfs.sh script
15 PATH=/usr/sbin:/usr/bin:/sbin:/bin
16 DESC="Nag(IX)SC HTTP2Nagios"
17 NAME=nagixsc_http2nagios
18 DAEMONPATH=/usr/sbin
19 DAEMON=$DAEMONPATH/$NAME
20 DAEMON_ARGS="-c /etc/nagixsc/http2nagios.cfg"
21 PIDFILE=/var/run/$NAME.pid
22 SCRIPTNAME=/etc/init.d/$NAME
24 # Exit if the package is not installed
25 [ -x "$DAEMON" ] || exit 0
27 # Read configuration variable file if it is present
28 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
30 # Load the VERBOSE setting and other rcS variables
31 [ -f /etc/default/rcS ] && . /etc/default/rcS
33 # Define LSB log_* functions.
34 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
35 . /lib/lsb/init-functions
37 # Check if RUN is set to "yes".
38 if [ "x$RUN" != "xyes" ] ; then
39 echo "$NAME has been disabled in /etc/default/$NAME."
40 exit 0
41 fi
43 DAEMON_ARGS="$DAEMON_ARGS --daemon"
45 is_running()
46 {
47 [ -f "$PIDFILE" ] || return 1
48 ps ax | grep "`cat $PIDFILE`" | grep $NAME | grep -qv grep
49 return $?
50 }
52 do_start()
53 {
54 is_running && return 1
55 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1
56 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS || return 2
57 }
59 do_stop()
60 {
61 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
62 RETVAL="$?"
63 [ "$RETVAL" = 2 ] && return 2
64 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
65 [ "$?" = 2 ] && return 2
66 rm -f $PIDFILE
67 return "$RETVAL"
68 }
72 case "$1" in
73 start)
74 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
75 do_start
76 case "$?" in
77 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
78 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
79 esac
80 ;;
81 stop)
82 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
83 do_stop
84 case "$?" in
85 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
86 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
87 esac
88 ;;
89 restart|force-reload)
90 log_daemon_msg "Restarting $DESC" "$NAME"
91 do_stop
92 case "$?" in
93 0|1)
94 do_start
95 case "$?" in
96 0) log_end_msg 0 ;;
97 1) log_end_msg 1 ;; # Old process is still running
98 *) log_end_msg 1 ;; # Failed to start
99 esac
100 ;;
101 *)
102 # Failed to stop
103 log_end_msg 1
104 ;;
105 esac
106 ;;
107 *)
108 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
109 exit 3
110 ;;
111 esac