PageRenderTime 38ms CodeModel.GetById 32ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/rc0.d/K20zabbix-agent

http://github.com/brinkman83/bashrc
Shell | 71 lines | 52 code | 9 blank | 10 comment | 3 complexity | 0661a686ec40c25b83b29b52b21dffbc MD5 | raw file
 1#! /bin/sh
 2### BEGIN INIT INFO
 3# Provides:          zabbix-agent
 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-agent daemon
 9### END INIT INFO
10
11set -e
12
13NAME=zabbix_agentd
14DAEMON=/usr/sbin/$NAME
15DESC="Zabbix agent"
16
17test -x $DAEMON || exit 0
18
19DIR=/var/run/zabbix-agent
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