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 --daemon"
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 is_running()
38 {
39 [ -f "$PIDFILE" ] || return 1
40 ps ax | grep "`cat $PIDFILE`" | grep $NAME | grep -qv grep
41 return $?
42 }
44 do_start()
45 {
46 is_running && return 1
47 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1
48 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS || return 2
49 }
51 do_stop()
52 {
53 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
54 RETVAL="$?"
55 [ "$RETVAL" = 2 ] && return 2
56 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
57 [ "$?" = 2 ] && return 2
58 rm -f $PIDFILE
59 return "$RETVAL"
60 }
64 case "$1" in
65 start)
66 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
67 do_start
68 case "$?" in
69 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
70 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
71 esac
72 ;;
73 stop)
74 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
75 do_stop
76 case "$?" in
77 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
78 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
79 esac
80 ;;
81 restart|force-reload)
82 log_daemon_msg "Restarting $DESC" "$NAME"
83 do_stop
84 case "$?" in
85 0|1)
86 do_start
87 case "$?" in
88 0) log_end_msg 0 ;;
89 1) log_end_msg 1 ;; # Old process is still running
90 *) log_end_msg 1 ;; # Failed to start
91 esac
92 ;;
93 *)
94 # Failed to stop
95 log_end_msg 1
96 ;;
97 esac
98 ;;
99 *)
100 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
101 exit 3
102 ;;
103 esac