2008-06-19 16:53:10 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Pandora FMS Plugin Server, startup script
|
2008-09-08 18:12:57 +02:00
|
|
|
# Copyright (c) 2006-2008 Sancho Lerena, <slerena@gmail.com>
|
2008-06-19 16:53:10 +02: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
|
2008-06-19 16:53:10 +02:00
|
|
|
|
|
|
|
# Configurable path and filenames
|
|
|
|
PANDORA_HOME="/etc/pandora/pandora_server.conf"
|
|
|
|
PANDORA_PID_PATH="/var/run"
|
|
|
|
PANDORA_PID=$PANDORA_PID_PATH/pandora_plugin.pid
|
2008-09-08 18:12:57 +02:00
|
|
|
PANDORA_DAEMON=/usr/local/bin/pandora_plugin
|
2008-06-19 16:53:10 +02:00
|
|
|
|
|
|
|
# Main script
|
|
|
|
|
|
|
|
if [ ! -d "$PANDORA_PID_PATH" ]
|
|
|
|
then
|
|
|
|
echo "Pandora FMS Plugin Server cannot write it's PID file in $PANDORA_PID_PATH. Please create that directory"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f $PANDORA_DAEMON ]
|
|
|
|
then
|
2008-09-08 18:12:57 +02:00
|
|
|
echo "Pandora FMS Plugin Server not found, please check setup and read manual"
|
|
|
|
exit
|
2008-06-19 16:53:10 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
2008-09-08 18:12:57 +02:00
|
|
|
start)
|
|
|
|
OLD_PATH="`pwd`"
|
|
|
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
|
|
|
if [ ! -z $PANDORA_PID ]
|
|
|
|
then
|
|
|
|
echo "Pandora FMS Plugin Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..."
|
|
|
|
exit 1
|
|
|
|
fi
|
2008-06-19 16:53:10 +02:00
|
|
|
|
2008-09-08 18:12:57 +02:00
|
|
|
$PANDORA_DAEMON $PANDORA_HOME -D
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
|
|
|
if [ ! -z "$PANDORA_PID" ]
|
|
|
|
then
|
|
|
|
echo "Pandora FMS Plugin Server is now running with PID $PANDORA_PID"
|
|
|
|
else
|
|
|
|
echo "Cannot start Pandora FMS Plugin Server. Aborted."
|
|
|
|
fi
|
|
|
|
cd "$OLD_PATH"
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
|
|
|
if [ -z $PANDORA_PID ]
|
|
|
|
then
|
|
|
|
echo "Pandora FMS Plugin Server is not running, cannot stop it."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Stopping Pandora FMS Plugin Server"
|
|
|
|
kill $PANDORA_PID > /dev/null 2>&1
|
|
|
|
rm -f $PANDORA_PID
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
force-reload|restart)
|
|
|
|
$0 stop
|
2008-10-30 14:15:18 +01:00
|
|
|
sleep 2
|
2008-09-08 18:12:57 +02:00
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: pandora_plugin {start|stop|restart}"
|
|
|
|
exit 1
|
2008-06-19 16:53:10 +02:00
|
|
|
esac
|
|
|
|
|