2007-05-21 11:12:21 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2007-07-31 19:26:09 +02:00
|
|
|
# Pandora FMS Network Server, startup script
|
2006-03-27 05:37:27 +02:00
|
|
|
# Sancho Lerena, <slerena@gmail.com>
|
2007-07-31 19:26:09 +02:00
|
|
|
# Linux Version (generic)
|
|
|
|
# v1.3 Build 070731
|
2006-03-27 05:37:27 +02:00
|
|
|
|
|
|
|
# Configurable path and filenames
|
2007-08-02 20:44:17 +02:00
|
|
|
PANDORA_HOME="/etc/pandora/pandora_server.conf"
|
2008-03-11 16:55:35 +01:00
|
|
|
PANDORA_PID_PATH="/var/run"
|
2007-07-31 19:26:09 +02:00
|
|
|
PANDORA_PID=$PANDORA_PID_PATH/pandora_network.pid
|
2007-11-20 14:59:21 +01:00
|
|
|
PANDORA_DAEMON=/usr/local/bin/pandora_network
|
2006-03-27 05:37:27 +02:00
|
|
|
|
|
|
|
# Main script
|
|
|
|
|
2007-07-31 19:26:09 +02:00
|
|
|
if [ ! -d "$PANDORA_PID_PATH" ]
|
|
|
|
then
|
|
|
|
echo "Pandora FMS cannot write it's PID file in $PANDORA_PID_PATH. Please create that directory"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2007-08-02 20:30:10 +02:00
|
|
|
if [ ! -f $PANDORA_DAEMON ]
|
2006-03-27 05:37:27 +02:00
|
|
|
then
|
2007-06-04 15:45:35 +02:00
|
|
|
echo "Pandora FMS Network Server not found, please check setup and read manual"
|
2006-03-27 05:37:27 +02:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
OLD_PATH="`pwd`"
|
2008-03-11 16:55:35 +01:00
|
|
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
|
|
|
if [ ! -z $PANDORA_PID ]
|
2006-03-27 05:37:27 +02:00
|
|
|
then
|
2008-03-11 16:55:35 +01:00
|
|
|
echo "Pandora FMS Network Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
rm -f $PANDORA_PID
|
2006-03-27 05:37:27 +02:00
|
|
|
fi
|
|
|
|
|
2007-08-02 20:30:10 +02:00
|
|
|
$PANDORA_DAEMON $PANDORA_HOME -D
|
|
|
|
sleep 1
|
2007-07-31 19:26:09 +02:00
|
|
|
|
2008-03-11 16:55:35 +01:00
|
|
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
|
|
|
if [ ! -z "$PANDORA_PID" ]
|
2006-03-27 05:37:27 +02:00
|
|
|
then
|
2008-03-11 16:55:35 +01:00
|
|
|
echo "Pandora Network Server is now running with PID $PANDORA_PID"
|
2006-03-27 05:37:27 +02:00
|
|
|
else
|
2007-07-20 13:02:20 +02:00
|
|
|
echo "Cannot start Pandora FMS Network Server. Aborted."
|
2006-03-27 05:37:27 +02:00
|
|
|
fi
|
2007-07-31 19:26:09 +02:00
|
|
|
cd "$OLD_PATH"
|
2006-03-27 05:37:27 +02:00
|
|
|
;;
|
|
|
|
stop)
|
2008-03-11 16:55:35 +01:00
|
|
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
|
|
|
if [ -z $PANDORA_PID ]
|
2006-03-27 05:37:27 +02:00
|
|
|
then
|
2008-03-11 16:55:35 +01:00
|
|
|
echo "Pandora FMS Network Server is not running, cannot stop it."
|
|
|
|
exit 1
|
|
|
|
else
|
2007-06-04 15:45:35 +02:00
|
|
|
echo "Stopping Pandora FMS Network Server"
|
2008-03-11 16:55:35 +01:00
|
|
|
kill $PANDORA_PID > /dev/null 2>&1
|
2007-07-31 19:26:09 +02:00
|
|
|
rm -f $PANDORA_PID
|
2006-03-27 05:37:27 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
force-reload|restart)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: pandora_network {start|stop|restart}"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|