2007-07-31 19:26:09 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2007-03-19 21:04:37 +01:00
|
|
|
# Pandora FMS Recon Server, startup script
|
|
|
|
# Sancho Lerena, <slerena@gmail.com>
|
|
|
|
# Linux Version (generic)
|
2007-07-31 19:26:09 +02:00
|
|
|
# v1.3 Build 070731
|
2007-03-19 21:04:37 +01:00
|
|
|
|
|
|
|
# Configurable path and filenames
|
2007-08-02 20:44:17 +02:00
|
|
|
PANDORA_HOME="/etc/pandora/pandora_server.conf"
|
2007-07-31 19:26:09 +02:00
|
|
|
PANDORA_PID_PATH="/var/run/pandora"
|
|
|
|
PANDORA_PID=$PANDORA_PID_PATH/pandora_recon.pid
|
2007-08-02 20:30:10 +02:00
|
|
|
PANDORA_DAEMON=/usr/bin/pandora_recon
|
2007-03-19 21:04:37 +01: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 ]
|
2007-03-19 21:04:37 +01:00
|
|
|
then
|
|
|
|
echo "Pandora FMS Recon Server not found, please check setup and read manual"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
OLD_PATH="`pwd`"
|
|
|
|
if [ -f $PANDORA_PID ]
|
|
|
|
then
|
2007-07-31 19:26:09 +02:00
|
|
|
CHECK_PID=`cat $PANDORA_PID`
|
|
|
|
CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "pandora_recon" | wc -l`
|
|
|
|
if [ $CHECK_PID_RESULT == 1 ]
|
2007-03-19 21:04:37 +01:00
|
|
|
then
|
2007-07-31 19:26:09 +02:00
|
|
|
echo "Pandora FMS Recon Server is currently running on this machine with PID ($CHECK_PID). Aborting now..."
|
2007-03-19 21:04:37 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-08-02 20:30:10 +02:00
|
|
|
$PANDORA_DAEMON $PANDORA_HOME -D
|
|
|
|
sleep 1
|
2007-07-31 19:26:09 +02:00
|
|
|
|
2007-08-23 18:54:41 +02:00
|
|
|
MYPID=`ps aux | grep "$PANDORA_DAEMON" | grep -v grep | tail -1 | awk '{print $2}'`
|
2007-03-19 21:04:37 +01:00
|
|
|
if [ ! -z "$MYPID" ]
|
|
|
|
then
|
|
|
|
echo $MYPID > $PANDORA_PID
|
2007-07-31 19:26:09 +02:00
|
|
|
echo "Pandora Recon Server is now running with PID $MYPID"
|
2007-03-19 21:04:37 +01:00
|
|
|
else
|
2007-07-31 19:26:09 +02:00
|
|
|
echo "Cannot start Pandora FMS Recon Server. Aborted."
|
2007-03-19 21:04:37 +01:00
|
|
|
fi
|
2007-07-31 19:26:09 +02:00
|
|
|
cd "$OLD_PATH"
|
2007-03-19 21:04:37 +01:00
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
if [ -f $PANDORA_PID ]
|
|
|
|
then
|
|
|
|
echo "Stopping Pandora FMS Recon Server"
|
|
|
|
PID_2=`cat $PANDORA_PID`
|
2007-07-31 19:26:09 +02:00
|
|
|
if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'pandora_recon' `" ]
|
2007-03-19 21:04:37 +01:00
|
|
|
then
|
|
|
|
kill `cat $PANDORA_PID` 2> /dev/null > /dev/null
|
|
|
|
fi
|
|
|
|
rm -f $PANDORA_PID
|
|
|
|
else
|
|
|
|
echo "Pandora FMS Recon Server is not running, cannot stop it."
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
force-reload|restart)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: pandora_recon {start|stop|restart}"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|