#!/usr/bin/ksh # # description: gmetad startup script # # Jul 03, 2006, Michael Perzl (michael@perzl.org) # GMETAD_BIN=/opt/freeware/sbin/gmetad PIDFILE=/var/run/gmetad.pid # Check for missing binaries (stale symlinks should not happen) test -x $GMETAD_BIN || { echo "$GMETAD_BIN not installed"; if [ "$1" = "stop" ]; then exit 0; else exit 5; fi; } # Check for existence of needed config file and read it GMETAD_CONFIG=/etc/gmetad.conf test -r $GMETAD_CONFIG || { echo "$GMETAD_CONFIG not existing"; if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; } RUN_AS_USER="nobody" case "$1" in start) if [ -r $PIDFILE ]; then echo "GANGLIA gmetad daemon is already running with PID "`cat $PIDFILE`"." exit 1 fi echo "Starting GANGLIA gmetad..." ## Start daemon and write PID to file $PIDFILE. mkdir -p /var/run $GMETAD_BIN -p $PIDFILE ;; stop) echo "Shutting down GANGLIA gmetad daemon... " ## Stop daemon. if [ -r $PIDFILE ]; then kill -15 `cat $PIDFILE` rm -f $PIDFILE fi ;; status) if [ -r $PIDFILE ]; then echo "GANGLA gmetad daemon is running with PID "`cat $PIDFILE`"." else echo "GANGLIA gmetad daemon is not running." fi ;; restart) ## Stop the service and regardless of whether it was ## running or not, start it again. $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|status|restart}" exit 1 ;; esac