#!/bin/sh # Pandora FMS Recon Server, startup script # Sancho Lerena, # Linux Version (generic) # v1.3 (Mar/2007) # Configurable path and filenames PANDORA_HOME="/usr/share/pandora_server" PANDORA_PID="$PANDORA_HOME/var/pandora_recon.pid" # Main script if [ ! -f $PANDORA_HOME/bin/pandora_recon.pl ] 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 PID_2=`cat $PANDORA_PID` if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'pandora_recon.pl'`" ] then echo "Pandora FMS Recon Server is currently running on this machine. Aborting now..." exit fi fi cd $PANDORA_HOME/bin ./pandora_recon.pl $PANDORA_HOME -D MYPID=`ps aux | grep 'pandora_recon.pl' | grep -v grep | tail -1 | awk '{print $2}'` if [ ! -z "$MYPID" ] then echo $MYPID > $PANDORA_PID echo "Pandora FMS Recon Server is now running with PID $MYPID" else echo "Cannot start Pandora FMS Recon Server. Aborted" fi cd "$OLD_PATH" ;; stop) if [ -f $PANDORA_PID ] then echo "Stopping Pandora FMS Recon Server" PID_2=`cat $PANDORA_PID` if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'pandora_recon.pl'`" ] 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