#!/bin/bash # init file for eGurkha Agent # # chkconfig: 2345 85 15 # description: Automatic starting/stop/restart of the eGurkha VM Agent # ### BEGIN INIT INFO # Provides: eGurkha Monitoring VM Agent # Required-Start: none # Required-Stop: none # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Controls the eG Innovations Monitoring VM Agent # Description: Runs the /opt/egvmagent/bin/start_vmagent and /opt/egurkha/bin/stop_vmagent commands ### END INIT INFO # source function library func=0 if [ -f /etc/init.d/functions ] then func=1 . /etc/init.d/functions fi RETVAL=0 prog=eGVMAgent eg_vmagent_start="su - xxxx -c /opt/egvmagent/bin/start_vmagent > /dev/null 2>&1" eg_vmagent_stop="su - xxxx -c /opt/egvmagent/bin/stop_vmagent > /dev/null 2>&1" start() { echo -n $"Starting $prog: " if [ $func -eq 1 ] then daemon $eg_vmagent_start else $eg_vmagent_start fi RETVAL=$? echo if [ -d /var/lock/subsys ] then touch /var/lock/subsys/egvmagent fi return $RETVAL } stop() { echo -n $"Stopping $prog: " if [ $func -eq 1 ] then daemon $eg_vmagent_stop else $eg_vmagent_stop fi RETVAL=$? echo if [ -d /var/lock/subsys ] then rm -f /var/lock/subsys/egvmagent fi return $RETVAL } reload(){ stop start } restart(){ stop start } condrestart(){ [ -e /var/lock/subsys/egvmagent ] && restart return 0 } case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; condrestart) condrestart ;; status) status egvmagentmon RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}" RETVAL=1 esac exit $RETVAL