summaryrefslogtreecommitdiff
path: root/network/zabbix_agentd/rc.zabbix_agentd
diff options
context:
space:
mode:
authorNiels Horn <niels.horn@gmail.com>2010-05-13 01:00:27 +0200
committerErik Hanson <erik@slackbuilds.org>2010-05-13 01:00:27 +0200
commitcc817703debc23860b74bac3abcc53f93dde6de0 (patch)
treecb92a0f9ca1b5f059d65eb6c65959327ae080322 /network/zabbix_agentd/rc.zabbix_agentd
parentf33c3d5a66642d55d4ed667503164ca4998d1ee5 (diff)
downloadslackbuilds-cc817703debc23860b74bac3abcc53f93dde6de0.tar.gz
network/zabbix_agentd: Added to 13.0 repository
Diffstat (limited to 'network/zabbix_agentd/rc.zabbix_agentd')
-rw-r--r--network/zabbix_agentd/rc.zabbix_agentd79
1 files changed, 79 insertions, 0 deletions
diff --git a/network/zabbix_agentd/rc.zabbix_agentd b/network/zabbix_agentd/rc.zabbix_agentd
new file mode 100644
index 0000000000..bbe5650698
--- /dev/null
+++ b/network/zabbix_agentd/rc.zabbix_agentd
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+# usage: ./rc.zabbix_agentd { start | stop | restart }
+
+PRGNAM=zabbix_agentd
+PRGDIR=/usr/sbin/
+PIDDIR=/var/run/zabbix/
+LOGDIR=/var/log/zabbix/
+DATE=$(date +%a\ %b\ %d\ %T\ %Y)
+RETVAL=0
+
+prg_start() {
+ echo -n "Starting $PRGNAM ... "
+ if [ -r ${PIDDIR}${PRGNAM}.pid ]; then
+ if $(! /sbin/pidof $PRGNAM > /dev/null 2>&1 ) ; then
+ echo "Removing an old ${PIDDIR}${PRGNAM}.pid"
+ rm -f ${PIDDIR}${PRGNAM}.pid
+ fi
+ fi
+ ${PRGDIR}${PRGNAM} >> ${LOGDIR}${PRGNAM}.log 2>&1
+ RETVAL=$?
+
+ if [ $RETVAL -eq 0 ]; then
+ touch /var/lock/$PRGNAM
+ sleep 2
+ echo "Done"
+ else
+ echo "Failed"
+ fi
+ return $RETVAL
+}
+
+prg_stop() {
+ echo -n "Stopping $PRGNAM ... "
+ if [ -r ${PIDDIR}${PRGNAM}.pid ]; then
+ killall $PRGNAM
+ # Give it some time to die gracefully
+ for second in 0 1 2 3 4 5 6 7 8 9 10 ; do
+ if $(! /sbin/pidof $PRGNAM > /dev/null 2>&1 ) ; then
+ rm -f ${PIDDIR}${PRGNAM}.pid
+ break;
+ fi
+ sleep 1
+ done
+
+ if [ "$second" = "10" ]; then
+ echo "\nWARNING: $PRGNAM did not exit!"
+ sleep 10
+ else
+ echo "$DATE EXIT: $PRGNAM stopped by user: $USER (UID: $EUID)" >> ${LOGDIR}${PRGNAM}.log
+ echo "Done"
+ fi
+ fi
+ rm -f /var/lock/$PRGNAM
+ return $RETVAL
+}
+
+# How were we called:
+case "$1" in
+ start)
+ prg_start
+ ;;
+ stop)
+ prg_stop
+ ;;
+ restart|reload)
+ prg_stop
+ # Wait a few seconds before restarting
+ sleep 10
+ prg_start
+ ;;
+ *)
+ echo ""
+ echo "Usage: $(basename $0) {start | stop | restart }"
+ RETVAL=1
+esac
+
+exit $RETVAL
+#EOF