99 lines
2.3 KiB
Bash
Executable File
99 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Pandora FMS Server, startup script
|
|
# Copyright (c) 2006-2009 Sancho Lerena, <sancho.lerena@artica.es>
|
|
# Linux Version (generic), for SuSe and Debian/Ubuntu.
|
|
# other Linux distros could not work properly without modifications
|
|
# v3.0 Build 090810
|
|
# http://www.pandorafms.com
|
|
|
|
### BEGIN INIT INTO
|
|
# Provides: pandora_server
|
|
# Default-Start: 2 3 5
|
|
# Default-Stop: 0 1 2 3 5
|
|
# Required-Start: $network
|
|
# Required-Stop: $network
|
|
# Short-Description: Pandora FMS Server startup script
|
|
### END INIT INFO
|
|
|
|
PANDORA_HOME="/etc/pandora/pandora_server.conf"
|
|
PANDORA_PID_PATH="/var/run"
|
|
PANDORA_PID=$PANDORA_PID_PATH/pandora_server.pid
|
|
PANDORA_DAEMON=/usr/local/bin/pandora_server
|
|
|
|
|
|
# This function replace pidof, not working in the same way in different linux distros
|
|
|
|
function pidof_pandora () (
|
|
PANDORA_PID=`ps aux | grep $PANDORA_DAEMON | grep -v grep | tail -1 | awk '{ print $2 }'`
|
|
echo $PANDORA_PID
|
|
)
|
|
|
|
# Main script
|
|
|
|
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
|
|
|
|
if [ ! -f $PANDORA_DAEMON ]
|
|
then
|
|
echo "Pandora FMS Server not found, please check setup and read manual"
|
|
exit
|
|
fi
|
|
|
|
case "$1" in
|
|
start)
|
|
PANDORA_PID=`pidof_pandora`
|
|
if [ ! -z "$PANDORA_PID" ]
|
|
then
|
|
echo "Pandora FMS Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..."
|
|
exit 1
|
|
fi
|
|
|
|
$PANDORA_DAEMON $PANDORA_HOME -D
|
|
sleep 2
|
|
|
|
PANDORA_PID=`pidof_pandora`
|
|
if [ ! -z "$PANDORA_PID" ]
|
|
then
|
|
echo "Pandora Server is now running with PID $PANDORA_PID"
|
|
else
|
|
echo "Cannot start Pandora FMS Server. Aborted."
|
|
echo "Check Pandora FMS log files at '/var/log/pandora/pandora_server.log'"
|
|
fi
|
|
;;
|
|
|
|
stop)
|
|
PANDORA_PID=`pidof_pandora`
|
|
if [ -z "$PANDORA_PID" ]
|
|
then
|
|
echo "Pandora FMS Server is not running, cannot stop it."
|
|
exit 1
|
|
else
|
|
echo "Stopping Pandora FMS Server"
|
|
kill $PANDORA_PID > /dev/null 2>&1
|
|
fi
|
|
;;
|
|
status)
|
|
PANDORA_PID=`pidof_pandora`
|
|
if [ -z "$PANDORA_PID" ]
|
|
then
|
|
echo "Pandora FMS Server is not running."
|
|
else
|
|
echo "Pandora FMS Server is running with PID $PANDORA_PID."
|
|
fi
|
|
exit 0
|
|
;;
|
|
force-reload|restart)
|
|
$0 stop
|
|
sleep 3
|
|
$0 start
|
|
;;
|
|
*)
|
|
echo "Usage: pandora_server { start | stop | restart | status }"
|
|
exit 1
|
|
esac
|
|
|