PageRenderTime 34ms CodeModel.GetById 26ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/rc5.d/S20zabbix-server

http://github.com/brinkman83/bashrc
Shell | 71 lines | 52 code | 9 blank | 10 comment | 3 complexity | e36e12dac385e8097f384a76d6037f6f MD5 | raw file
 1#! /bin/sh
 2### BEGIN INIT INFO
 3# Provides:          zabbix-server
 4# Required-Start:    $local_fs $network
 5# Required-Stop:     $local_fs
 6# Default-Start:     2 3 4 5
 7# Default-Stop:	     0 1 6
 8# Short-Description: Start zabbix-server daemon
 9### END INIT INFO
10
11set -e
12
13NAME=zabbix_server
14DAEMON=/usr/sbin/$NAME
15DESC="Zabbix server"
16
17test -x $DAEMON || exit 0
18
19DIR=/var/run/zabbix-server
20PID=$DIR/$NAME.pid
21RETRY=15
22
23if test ! -d "$DIR"; then
24  mkdir "$DIR"
25  chown -R zabbix:zabbix "$DIR"
26fi
27
28export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
29
30# define LSB log_* functions.
31. /lib/lsb/init-functions
32
33case "$1" in
34  start)
35    log_daemon_msg "Starting $DESC" "$NAME"
36	start-stop-daemon --oknodo --start --pidfile $PID \
37	  --exec $DAEMON >/dev/null 2>&1
38    case "$?" in
39        0) log_end_msg 0 ;;
40        *) log_end_msg 1; exit 1 ;;
41    esac
42	;;
43  stop)
44    log_daemon_msg "Stopping $DESC" "$NAME"
45	start-stop-daemon --oknodo --stop --exec $DAEMON --retry $RETRY
46    case "$?" in
47        0) log_end_msg 0 ;;
48        *) log_end_msg 1; exit 1 ;;
49    esac
50	;;
51  status)
52   ls -l /proc/`cat $PID`/exe &> /dev/null
53   if [ $? -eq 0 ]; then
54       echo "$DESC is running"
55       exit 0
56   else
57       echo "$DESC is NOT running"
58       exit 1
59   fi
60   ;;
61  restart|force-reload)
62	$0 stop
63	$0 start
64	;;
65  *)
66    echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
67	exit 1
68	;;
69esac
70
71exit 0