From 3442ec61fa38eea4e68a3edea4ea3225ff78c8a0 Mon Sep 17 00:00:00 2001 From: osmiy Date: Mon, 28 May 2007 13:32:10 +0000 Subject: - modifed startup scripts (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@4187 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- misc/init.d/debian/zabbix-agent | 8 +- misc/init.d/debian/zabbix-server | 52 ++++++++++++ misc/init.d/debian/zabbix-suckerd | 51 ----------- misc/init.d/debian/zabbix-trapperd | 51 ----------- misc/init.d/fedora/core5/zabbix_agentd | 79 +++++++++++++++++ misc/init.d/gentoo/zabbix-agentd | 6 +- misc/init.d/gentoo/zabbix-server | 34 ++++++++ misc/init.d/gentoo/zabbix-suckerd | 34 -------- misc/init.d/gentoo/zabbix-trapperd | 34 -------- misc/init.d/redhat/8.0/zabbix_server | 85 +++++++++++++++++++ misc/init.d/redhat/8.0/zabbix_suckerd | 85 ------------------- misc/init.d/redhat/8.0/zabbix_trapperd | 87 ------------------- misc/init.d/redhat/zabbix_server_ctl | 149 +++++++++++++++++++++++++++++++++ misc/init.d/redhat/zabbix_suckerd_ctl | 149 --------------------------------- misc/init.d/suse/9.1/zabbix_server | 70 ++++++++++++++++ misc/init.d/suse/9.1/zabbix_suckerd | 70 ---------------- misc/init.d/tru64/zabbix_server | 56 +++++++++++++ 17 files changed, 532 insertions(+), 568 deletions(-) create mode 100755 misc/init.d/debian/zabbix-server delete mode 100755 misc/init.d/debian/zabbix-suckerd delete mode 100755 misc/init.d/debian/zabbix-trapperd create mode 100755 misc/init.d/fedora/core5/zabbix_agentd create mode 100644 misc/init.d/gentoo/zabbix-server delete mode 100644 misc/init.d/gentoo/zabbix-suckerd delete mode 100644 misc/init.d/gentoo/zabbix-trapperd create mode 100644 misc/init.d/redhat/8.0/zabbix_server delete mode 100644 misc/init.d/redhat/8.0/zabbix_suckerd delete mode 100644 misc/init.d/redhat/8.0/zabbix_trapperd create mode 100755 misc/init.d/redhat/zabbix_server_ctl delete mode 100755 misc/init.d/redhat/zabbix_suckerd_ctl create mode 100644 misc/init.d/suse/9.1/zabbix_server delete mode 100644 misc/init.d/suse/9.1/zabbix_suckerd create mode 100644 misc/init.d/tru64/zabbix_server (limited to 'misc') diff --git a/misc/init.d/debian/zabbix-agent b/misc/init.d/debian/zabbix-agent index 78ac583e..234e5534 100755 --- a/misc/init.d/debian/zabbix-agent +++ b/misc/init.d/debian/zabbix-agent @@ -4,10 +4,10 @@ # # Written by Alexei Vladishev . -PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/zabbix/bin -DAEMON=/home/zabbix/bin/zabbix_agentd NAME=zabbix_agentd -DESC="Zabbix agent" +PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/zabbix/bin +DAEMON=/home/zabbix/bin/${NAME} +DESC="Zabbix agent daemon" PID=/var/tmp/$NAME.pid test -f $DAEMON || exit 0 @@ -31,7 +31,7 @@ case "$1" in # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart". # -# echo -n "Restarting $DESC: zabbix_suckerd" +# echo -n "Restarting $DESC: zabbix_agent" $0 stop $0 start # start-stop-daemon --stop --quiet --pidfile \ diff --git a/misc/init.d/debian/zabbix-server b/misc/init.d/debian/zabbix-server new file mode 100755 index 00000000..367dc3bc --- /dev/null +++ b/misc/init.d/debian/zabbix-server @@ -0,0 +1,52 @@ +#! /bin/sh +# +# Zabbix daemon start/stop script. +# +# Written by Alexei Vladishev . + +NAME=zabbix_server +PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/zabbix/bin +DAEMON=/home/zabbix/bin/${NAME} +DESC="Zabbix server daemon" +PID=/var/tmp/$NAME.pid + +test -f $DAEMON || exit 0 + +set -e + +case "$1" in + start) + echo "Starting $DESC: $NAME" + start-stop-daemon --oknodo --start --pidfile $PID \ + --exec $DAEMON + ;; + stop) + echo "Stopping $DESC: $NAME" + start-stop-daemon --oknodo --stop --pidfile $PID \ + --exec $DAEMON + ;; + restart|force-reload) + # + # If the "reload" option is implemented, move the "force-reload" + # option to the "reload" entry above. If not, "force-reload" is + # just the same as "restart". + # +# echo -n "Restarting $DESC: zabbix_server" + $0 stop + $0 start +# start-stop-daemon --stop --quiet --pidfile \ +# /tmp/$NAME.pid --user zabbix --exec $DAEMON +# sleep 1 +# start-stop-daemon --start --quiet --pidfile \ +# /tmp/$NAME.pid --user zabbix --exec $DAEMON +# echo "$NAME." + ;; + *) + N=/etc/init.d/$NAME + # echo "Usage: $N {start|stop|restart|force-reload}" >&2 + echo "Usage: $N {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/misc/init.d/debian/zabbix-suckerd b/misc/init.d/debian/zabbix-suckerd deleted file mode 100755 index 6f2498a5..00000000 --- a/misc/init.d/debian/zabbix-suckerd +++ /dev/null @@ -1,51 +0,0 @@ -#! /bin/sh -# -# Zabbix daemon start/stop script. -# -# Written by Alexei Vladishev . - -PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/zabbix/bin -DAEMON=/home/zabbix/bin/zabbix_suckerd -NAME=zabbix_suckerd -DESC="Zabbix sucker daemon" - -test -f $DAEMON || exit 0 - -set -e - -case "$1" in - start) - echo "Starting $DESC: $NAME" - start-stop-daemon --oknodo --start --pidfile /tmp/$NAME.pid \ - --exec $DAEMON - ;; - stop) - echo "Stopping $DESC: $NAME" - start-stop-daemon --oknodo --stop --pidfile /tmp/$NAME.pid \ - --exec $DAEMON - ;; - restart|force-reload) - # - # If the "reload" option is implemented, move the "force-reload" - # option to the "reload" entry above. If not, "force-reload" is - # just the same as "restart". - # -# echo -n "Restarting $DESC: zabbix_suckerd" - $0 stop - $0 start -# start-stop-daemon --stop --quiet --pidfile \ -# /tmp/$NAME.pid --user zabbix --exec $DAEMON -# sleep 1 -# start-stop-daemon --start --quiet --pidfile \ -# /tmp/$NAME.pid --user zabbix --exec $DAEMON -# echo "$NAME." - ;; - *) - N=/etc/init.d/$NAME - # echo "Usage: $N {start|stop|restart|force-reload}" >&2 - echo "Usage: $N {start|stop|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/misc/init.d/debian/zabbix-trapperd b/misc/init.d/debian/zabbix-trapperd deleted file mode 100755 index c9330eb5..00000000 --- a/misc/init.d/debian/zabbix-trapperd +++ /dev/null @@ -1,51 +0,0 @@ -#! /bin/sh -# -# Zabbix daemon start/stop script. -# -# Written by Alexei Vladishev . - -PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/zabbix/bin -DAEMON=/home/zabbix/bin/zabbix_trapperd -NAME=zabbix_trapperd -DESC="Zabbix trapper daemon" - -test -f $DAEMON || exit 0 - -set -e - -case "$1" in - start) - echo "Starting $DESC: $NAME" - start-stop-daemon --oknodo --start --pidfile /tmp/$NAME.pid \ - --exec $DAEMON - ;; - stop) - echo "Stopping $DESC: $NAME" - start-stop-daemon --oknodo --stop --pidfile /tmp/$NAME.pid \ - --exec $DAEMON - ;; - restart|force-reload) - # - # If the "reload" option is implemented, move the "force-reload" - # option to the "reload" entry above. If not, "force-reload" is - # just the same as "restart". - # -# echo -n "Restarting $DESC: zabbix_suckerd" - $0 stop - $0 start -# start-stop-daemon --stop --quiet --pidfile \ -# /tmp/$NAME.pid --user zabbix --exec $DAEMON -# sleep 1 -# start-stop-daemon --start --quiet --pidfile \ -# /tmp/$NAME.pid --user zabbix --exec $DAEMON -# echo "$NAME." - ;; - *) - N=/etc/init.d/$NAME - # echo "Usage: $N {start|stop|restart|force-reload}" >&2 - echo "Usage: $N {start|stop|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/misc/init.d/fedora/core5/zabbix_agentd b/misc/init.d/fedora/core5/zabbix_agentd new file mode 100755 index 00000000..84dc2562 --- /dev/null +++ b/misc/init.d/fedora/core5/zabbix_agentd @@ -0,0 +1,79 @@ +#!/bin/bash +# +# /etc/rc.d/init.d/dovecot +# +# Starts the zabbix_agentd daemon +# +# chkconfig: - 95 5 +# description: Zabbix Monitoring Agent +# processname: zabbix_agentd +# pidfile: /var/tmp/zabbix_agentd.pid + +# Source function library. + +. /etc/init.d/functions + +RETVAL=0 +prog="Zabbix Agent" +CONFIG_FILE="/etc/zabbix/zabbix_agentd.conf" +ZABBIX_BIN="/usr/bin/zabbix_agentd" + +test -x $ZABBIX_BIN || exit 0 + +if [ ! -f ${CONFIG_FILE} ]; then + echo -n "${NAME}configuration file ${CONFIG_FILE} does not exist. " + # Tell the user this has skipped + exit 6 +fi + +if [ ! -x ${ZABBIX_BIN} ] ; then + echo -n "${ZABBIX_BIN} not installed! " + # Tell the user this has skipped + exit 5 +fi + +start() { + echo -n $"Starting $prog: " + daemon $ZABBIX_BIN -c $CONFIG_FILE + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_agentd + echo +} + +stop() { + echo -n $"Stopping $prog: " + killproc $ZABBIX_BIN + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_agentd + echo +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + reload|restart) + stop + start + RETVAL=$? + ;; + condrestart) + if [ -f /var/lock/subsys/zabbix_agentd ]; then + stop + start + fi + ;; + status) + status $ZABBIX_BIN + RETVAL=$? + ;; + *) + echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}" + exit 1 +esac + +exit $RETVAL + diff --git a/misc/init.d/gentoo/zabbix-agentd b/misc/init.d/gentoo/zabbix-agentd index 1a163d87..f2e4f9dd 100644 --- a/misc/init.d/gentoo/zabbix-agentd +++ b/misc/init.d/gentoo/zabbix-agentd @@ -3,10 +3,10 @@ # Zabbix agent start/stop script. # # Written by A.Tophofen -PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/zabbix/bin -DAEMON=/home/zabbix/bin/zabbix_agentd NAME=zabbix_agentd -DESC="Zabbix 1.0" +PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/zabbix/bin +DAEMON=/home/zabbix/bin/${NAME} +DESC="Zabbix 1.4" PID=/home/zabbix/lock/$NAME.pid diff --git a/misc/init.d/gentoo/zabbix-server b/misc/init.d/gentoo/zabbix-server new file mode 100644 index 00000000..61ffc873 --- /dev/null +++ b/misc/init.d/gentoo/zabbix-server @@ -0,0 +1,34 @@ +#!/sbin/runscript +# +# Zabbix server start/stop script. +# +# Written by A.Tophofen +NAME=zabbix_server +PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/zabbix/bin +DAEMON=/home/zabbix/bin/${NAME} +DESC="Zabbix 1.4" +PID=/home/zabbix/lock/$NAME.pid + + + +opts="${opts} reload" + + +depend() { + need net +} + +start() { + ebegin "Starting $DESC: $NAME" + start-stop-daemon --start --pidfile $PID \ + --exec $DAEMON + eend +} +stop() { + ebegin "Stopping $DESC: $NAME" + start-stop-daemon --stop --pidfile $PID \ + --exec $DAEMON + eend +} + + diff --git a/misc/init.d/gentoo/zabbix-suckerd b/misc/init.d/gentoo/zabbix-suckerd deleted file mode 100644 index da6b79c7..00000000 --- a/misc/init.d/gentoo/zabbix-suckerd +++ /dev/null @@ -1,34 +0,0 @@ -#!/sbin/runscript -# -# Zabbix suckerdd start/stop script. -# -# Written by A.Tophofen -PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/zabbix/bin -DAEMON=/home/zabbix/bin/zabbix_suckerd -NAME=zabbix_suckerd -DESC="Zabbix 1.0" -PID=/home/zabbix/lock/$NAME.pid - - - -opts="${opts} reload" - - -depend() { - need net -} - -start() { - ebegin "Starting $DESC: $NAME" - start-stop-daemon --start --pidfile $PID \ - --exec $DAEMON - eend -} -stop() { - ebegin "Stopping $DESC: $NAME" - start-stop-daemon --stop --pidfile $PID \ - --exec $DAEMON - eend -} - - diff --git a/misc/init.d/gentoo/zabbix-trapperd b/misc/init.d/gentoo/zabbix-trapperd deleted file mode 100644 index abb3a9d2..00000000 --- a/misc/init.d/gentoo/zabbix-trapperd +++ /dev/null @@ -1,34 +0,0 @@ -#!/sbin/runscript -# -# Zabbix trapperd start/stop script. -# -# Written by A.Tophofen -PATH=/bin:/usr/bin:/sbin:/usr/sbin:/home/zabbix/bin -DAEMON=/home/zabbix/bin/zabbix_trapperd -NAME=zabbix_trapperd -DESC="Zabbix 1.0" -PID=/home/zabbix/lock/$NAME.pid - - - -opts="${opts} reload" - - -depend() { - need net -} - -start() { - ebegin "Starting $DESC: $NAME" - start-stop-daemon --start --pidfile $PID \ - --exec $DAEMON - eend -} -stop() { - ebegin "Stopping $DESC: $NAME" - start-stop-daemon --stop --pidfile $PID \ - --exec $DAEMON - eend -} - - diff --git a/misc/init.d/redhat/8.0/zabbix_server b/misc/init.d/redhat/8.0/zabbix_server new file mode 100644 index 00000000..6cea792e --- /dev/null +++ b/misc/init.d/redhat/8.0/zabbix_server @@ -0,0 +1,85 @@ +#!/bin/bash +# +# chkconfig: - 55 45 +# description: zabbix_server +# probe: false + +# Source function library. +. /etc/rc.d/init.d/functions + +# Source networking configuration. +. /etc/sysconfig/network + +# Check that networking is up. If you are running without a network, comment this out. +[ "${NETWORKING}" = "no" ] && exit 0 + +RETVAL=0 +progdir="/usr/local/zabbix/bin/" +prog="zabbix_server" + +start() { + # Start daemons. + if [ -n "`/sbin/pidof $prog`" ]; then + echo -n "$prog: already running" + failure $"$prog start" + echo + return 1 + fi + echo -n $"Starting $prog: " + # we can't seem to use daemon here - emulate its functionality + su -c $progdir$prog - $USER + RETVAL=$? + usleep 100000 + if [ -z "`/sbin/pidof $progdir$prog`" ]; then + RETVAL=1 + fi + [ $RETVAL -ne 0 ] && failure $"$prog startup" + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog && success $"$prog startup" + echo + return $RETVAL +} +stop() { + RETVAL=0 + pid= + # Stop daemons. + echo -n $"Stopping $prog: " + pid=`/sbin/pidof -s $prog` + if [ -n "$pid" ]; then + kill -TERM $pid + else + failure $"$prog stop" + echo + return 1 + fi + RETVAL=$? + [ $RETVAL -ne 0 ] && failure $"$prog stop" + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog && success $"$prog stop" + echo + return $RETVAL +} +restart() { + stop + start +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + condrestart) + [ -f /var/lock/subsys/$prog ] && restart + ;; + *) + echo $"Usage: $0 {start|stop|restart|condrestart}" + exit 1 +esac + +exit $? + diff --git a/misc/init.d/redhat/8.0/zabbix_suckerd b/misc/init.d/redhat/8.0/zabbix_suckerd deleted file mode 100644 index 0263e3bd..00000000 --- a/misc/init.d/redhat/8.0/zabbix_suckerd +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# -# chkconfig: - 55 45 -# description: zabbix_suckerd -# probe: false - -# Source function library. -. /etc/rc.d/init.d/functions - -# Source networking configuration. -. /etc/sysconfig/network - -# Check that networking is up. If you are running without a network, comment this out. -[ "${NETWORKING}" = "no" ] && exit 0 - -RETVAL=0 -progdir="/usr/local/zabbix/bin/" -prog="zabbix_suckerd" - -start() { - # Start daemons. - if [ -n "`/sbin/pidof $prog`" ]; then - echo -n "$prog: already running" - failure $"$prog start" - echo - return 1 - fi - echo -n $"Starting $prog: " - # we can't seem to use daemon here - emulate its functionality - su -c $progdir$prog - $USER - RETVAL=$? - usleep 100000 - if [ -z "`/sbin/pidof $progdir$prog`" ]; then - RETVAL=1 - fi - [ $RETVAL -ne 0 ] && failure $"$prog startup" - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog && success $"$prog startup" - echo - return $RETVAL -} -stop() { - RETVAL=0 - pid= - # Stop daemons. - echo -n $"Stopping $prog: " - pid=`/sbin/pidof -s $prog` - if [ -n "$pid" ]; then - kill -TERM $pid - else - failure $"$prog stop" - echo - return 1 - fi - RETVAL=$? - [ $RETVAL -ne 0 ] && failure $"$prog stop" - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog && success $"$prog stop" - echo - return $RETVAL -} -restart() { - stop - start -} - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - restart - ;; - condrestart) - [ -f /var/lock/subsys/$prog ] && restart - ;; - *) - echo $"Usage: $0 {start|stop|restart|condrestart}" - exit 1 -esac - -exit $? - diff --git a/misc/init.d/redhat/8.0/zabbix_trapperd b/misc/init.d/redhat/8.0/zabbix_trapperd deleted file mode 100644 index 546f96a6..00000000 --- a/misc/init.d/redhat/8.0/zabbix_trapperd +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -# -# chkconfig: - 55 45 -# description: zabbix_trapperd -# probe: false - -# Source function library. -. /etc/rc.d/init.d/functions - -# Source networking configuration. -. /etc/sysconfig/network - -# Check that networking is up. If you are running without a network, comment this out. -[ "${NETWORKING}" = "no" ] && exit 0 - -RETVAL=0 -progdir="/usr/local/zabbix/bin/" -prog="zabbix_trapperd" - -start() { - # Start daemons. - if [ -n "`/sbin/pidof $prog`" ]; then - echo -n "$prog: already running" - failure $"$prog start" - echo - return 1 - fi - echo -n $"Starting $prog: " - # we can't seem to use daemon here - emulate its functionality - su -c $progdir$prog - $USER - RETVAL=$? - usleep 100000 - if [ -z "`/sbin/pidof $progdir$prog`" ]; then - # The child processes have died after fork()ing, e.g. - # because of a broken config file - RETVAL=1 - fi - [ $RETVAL -ne 0 ] && failure $"$prog startup" - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog && success $"$prog startup" - echo - return $RETVAL -} -stop() { - RETVAL=0 - pid= - # Stop daemons. - echo -n $"Stopping $prog: " - pid=`/sbin/pidof -s $prog` - if [ -n "$pid" ]; then - kill -TERM $pid - else - failure $"$prog stop" - echo - return 1 - fi - RETVAL=$? - [ $RETVAL -ne 0 ] && failure $"$prog stop" - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog && success $"$prog stop" - echo - return $RETVAL -} -restart() { - stop - start -} - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - restart - ;; - condrestart) - [ -f /var/lock/subsys/zabbix_trapperd ] && restart - ;; - *) - echo $"Usage: $0 {start|stop|restart|condrestart}" - exit 1 -esac - -exit $? - diff --git a/misc/init.d/redhat/zabbix_server_ctl b/misc/init.d/redhat/zabbix_server_ctl new file mode 100755 index 00000000..52a2a685 --- /dev/null +++ b/misc/init.d/redhat/zabbix_server_ctl @@ -0,0 +1,149 @@ +#!/bin/sh +# +# zabbix_server_ctl +# +# control script to stop/start/restart zabbix_server +# author: charlie collins +# date: 01.21.2002 +# +# revised 09.21.2003 +# (setup for Red Hat 7.3 with Zabbix 1.0 beta) +# (should work for other Red Hat and Sys V style init machines as well) +# +# (modeled after apache style control scripts) +# (this script can be placed in init.d and respective runlevel for startup usage) +# +# +# The exit codes returned are: +# 0 - operation completed successfully +# 1 - +# 2 - usage error +# 3 - zabbix_server could not be started +# 4 - zabbix_server could not be stopped +# 5 - zabbix_server could not be started during a restart +# 6 - zabbix_server could not be restarted during a restart +# +# +# + +# ************** +# config options +# ************** +# +# (set config options to match your system settings) + +# base zabbix dir +BASEDIR=/opt/zabbix +# PID file +PIDFILE=/var/tmp/zabbix_server.pid +# binary file +ZABBIX_SUCKERD=$BASEDIR/bin/zabbix_server + + +# ************** +# logic section (below here) does NOT normally need any modification +# ************** + +# establish args +ERROR=0 +ARGV="$@" +if [ "x$ARGV" = "x" ] ; then + ARGS="help" +fi + + +# perform action based on args +for ARG in $@ $ARGS +do + # check if PIDFILE exists and ensure is not zero size and react accordingly + if [ -f $PIDFILE ] && [ -s $PIDFILE ] ; then + PID=`cat $PIDFILE` + if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then + STATUS="zabbix_server (pid $PID) running" + RUNNING=1 + else + STATUS="zabbix_server (pid $PID?) not running" + RUNNING=0 + fi + else + STATUS="zabbix_server (no pid file) not running" + RUNNING=0 + fi + + # parse arg and react accordingly + case $ARG in + + start) + if [ $RUNNING -eq 1 ]; then + echo "$0 $ARG: zabbix_server (pid $PID) already running" + continue + fi + if $ZABBIX_SUCKERD ; then + echo "$0 $ARG: zabbix_server started" + else + echo "$0 $ARG: zabbix_server could not be started" + ERROR=3 + fi + ;; + + stop) + if [ $RUNNING -eq 0 ]; then + echo "stop called - in running eq 0" + echo "$0 $ARG: $STATUS" + continue + fi + if kill $PID ; then + echo "$0 $ARG: zabbix_server process(es) stopped" + else + echo "$0 $ARG: zabbix_server process(es) could not be stopped" + ERROR=4 + fi + ;; + + restart) + if [ $RUNNING -eq 0 ]; then + echo "$0 $ARG: zabbix_server not running, trying to start" + if $ZABBIX_SUCKERD ; then + echo "$0 $ARG: zabbix_server started" + else + echo "$0 $ARG: zabbix_server could not be started" + ERROR=5 + fi + else + if kill $PID ; then + if $ZABBIX_SUCKERD ; then + echo "$0 $ARG: zabbix_server restarted" + else + echo "$0 $ARG: zabbix_server could not be started" + ERROR=3 + fi + else + echo "$0 $ARG: zabbix_server could not be restarted" + ERROR=6 + fi + fi + ;; + + *) + + echo "usage: $0 (start|stop|restart|help)" + cat </dev/null ; then - STATUS="zabbix_suckerd (pid $PID) running" - RUNNING=1 - else - STATUS="zabbix_suckerd (pid $PID?) not running" - RUNNING=0 - fi - else - STATUS="zabbix_suckerd (no pid file) not running" - RUNNING=0 - fi - - # parse arg and react accordingly - case $ARG in - - start) - if [ $RUNNING -eq 1 ]; then - echo "$0 $ARG: zabbix_suckerd (pid $PID) already running" - continue - fi - if $ZABBIX_SUCKERD ; then - echo "$0 $ARG: zabbix_suckerd started" - else - echo "$0 $ARG: zabbix_suckerd could not be started" - ERROR=3 - fi - ;; - - stop) - if [ $RUNNING -eq 0 ]; then - echo "stop called - in running eq 0" - echo "$0 $ARG: $STATUS" - continue - fi - if kill $PID ; then - echo "$0 $ARG: zabbix_suckerd process(es) stopped" - else - echo "$0 $ARG: zabbix_suckerd process(es) could not be stopped" - ERROR=4 - fi - ;; - - restart) - if [ $RUNNING -eq 0 ]; then - echo "$0 $ARG: zabbix_suckerd not running, trying to start" - if $ZABBIX_SUCKERD ; then - echo "$0 $ARG: zabbix_suckerd started" - else - echo "$0 $ARG: zabbix_suckerd could not be started" - ERROR=5 - fi - else - if kill $PID ; then - if $ZABBIX_SUCKERD ; then - echo "$0 $ARG: zabbix_suckerd restarted" - else - echo "$0 $ARG: zabbix_suckerd could not be started" - ERROR=3 - fi - else - echo "$0 $ARG: zabbix_suckerd could not be restarted" - ERROR=6 - fi - fi - ;; - - *) - - echo "usage: $0 (start|stop|restart|help)" - cat </dev/null 2>&1 + then + echo "${SERVICE} terminated." + rm -f ${PIDFILE} + fi + fi + ;; + 'restart') + $0 stop + $0 start + ;; + *) + echo "Usage: $0 start|stop|restart" + ;; +esac -- cgit