2007-07-31 19:26:09 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2007-03-19 21:04:37 +01:00
|
|
|
# Pandora FMS Recon Server, startup script
|
2008-09-08 18:12:57 +02:00
|
|
|
# Copyright (c) 2006-2008 Sancho Lerena, <slerena@gmail.com>
|
2007-03-19 21:04:37 +01:00
|
|
|
# Linux Version (generic)
|
2008-10-30 14:15:18 +01:00
|
|
|
# v2.1 Build 081030
|
2008-09-08 18:12:57 +02:00
|
|
|
# http://www.pandorafms.com
|
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"
|
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_recon.pid
|
2007-11-20 14:59:21 +01:00
|
|
|
PANDORA_DAEMON=/usr/local/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`"
|
2008-03-11 16:55:35 +01:00
|
|
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
|
|
|
if [ ! -z $PANDORA_PID ]
|
2007-03-19 21:04:37 +01:00
|
|
|
then
|
2008-03-11 16:55:35 +01:00
|
|
|
echo "Pandora FMS Recon Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..."
|
|
|
|
exit 1
|
2007-03-19 21:04:37 +01: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" ]
|
2007-03-19 21:04:37 +01:00
|
|
|
then
|
2008-03-11 16:55:35 +01:00
|
|
|
echo "Pandora Recon Server is now running with PID $PANDORA_PID"
|
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)
|
2008-03-11 16:55:35 +01:00
|
|
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
|
|
|
if [ -z $PANDORA_PID ]
|
2007-03-19 21:04:37 +01:00
|
|
|
then
|
2008-03-11 16:55:35 +01:00
|
|
|
echo "Pandora FMS Recon Server is not running, cannot stop it."
|
|
|
|
exit 1
|
2007-03-19 21:04:37 +01:00
|
|
|
else
|
2008-03-11 16:55:35 +01:00
|
|
|
echo "Stopping Pandora FMS Recon Server"
|
|
|
|
kill $PANDORA_PID > /dev/null 2>&1
|
|
|
|
rm -f $PANDORA_PID
|
2007-03-19 21:04:37 +01:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
force-reload|restart)
|
|
|
|
$0 stop
|
2008-10-30 14:15:18 +01:00
|
|
|
sleep 2
|
2007-03-19 21:04:37 +01:00
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: pandora_recon {start|stop|restart}"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|