#!/bin/csh

# Pandora FMS IPSO/BSD, startup script
# Copyright (c) 2006-2009 Artica ST, <info@artica.es>
# IPSO/BSD (csh)
# v1.2 Build 091104
# http://www.pandorafms.com


set PANDORA_PATH=/opt/pandora_agent
set DAEMON=pandora_agent.sh
set PIDFILE=/var/run/pandora.pid
test -x $PANDORA_PATH/$DAEMON || exit

switch ($1)
 case start:
 if ( -e $PIDFILE ) then
   echo "Pandora Agent is currently running on this machine.  Aborting now..."
   exit
        else 
  nice -10 $PANDORA_PATH/$DAEMON $PANDORA_PATH & set MYPID=$!
  echo $MYPID > /var/run/pandora.pid
  echo "Pandora Agent is now running with PID $MYPID"
  exit
 endif
        breaksw
 case stop:
  if ( -f $PIDFILE ) then
  echo "Stopping Pandora Agent."
  kill -9 `cat $PIDFILE`
  rm $PIDFILE
  else
   echo "Pandora Agent is not running, cannot stop it. Aborting now..."
  endif
 breaksw
 case restart:
  $0 stop
  $0 start
  breaksw
 default: 
 echo "Usage: ./pandora_agent {start|stop|restart|force-reload}"
        breaksw
        
endsw