PageRenderTime 64ms CodeModel.GetById 60ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/rc3.d/S98hobbit

http://github.com/brinkman83/bashrc
Shell | 110 lines | 77 code | 16 blank | 17 comment | 8 complexity | 78bf1e7d611cec4b89c060359ee159b4 MD5 | raw file
  1#!/bin/sh
  2
  3# Startup script for the Hobbit monitor
  4#
  5# This starts the "hobbitlaunch" tool, which in turn starts
  6# all of the other Hobbit server programs.
  7
  8### BEGIN INIT INFO
  9# Provides:          hobbit
 10# Required-Start:    $remote_fs $network
 11# Should-Start:      $all
 12# Required-Stop:     $remote_fs
 13# Default-Start:     2 3 4 5
 14# Default-Stop:      0 1 6
 15# Short-Description: Hobbit system monitor server
 16# Description:       Hobbit system monitor, server part.
 17#                    (Also monitors the local host.)
 18### END INIT INFO
 19
 20PIDFILE=/var/run/hobbit/hobbitlaunch.pid
 21DAEMON=/usr/lib/hobbit/server/bin/hobbitlaunch
 22NAME="hobbitd"
 23DESC="Hobbit Server"
 24
 25test -x $DAEMON || exit 0
 26
 27. /lib/lsb/init-functions
 28. /usr/share/hobbit/init-common.sh
 29
 30# Include hobbitclient defaults if available
 31if [ -f /etc/default/hobbit-client ] ; then
 32	. /etc/default/hobbit-client
 33fi
 34
 35case "$1" in
 36   "start")
 37	create_includefiles
 38
 39	log_daemon_msg "Starting $DESC" "$NAME"
 40	start-stop-daemon --exec $DAEMON --chuid hobbit --umask 022 --start \
 41		-- \
 42		--config=/etc/hobbit/hobbitlaunch.cfg \
 43		--env=/etc/hobbit/hobbitserver.cfg \
 44		--log=/var/log/hobbit/hobbitlaunch.log \
 45		--pidfile=$PIDFILE
 46	log_end_msg $?
 47	;;
 48
 49   "stop")
 50	log_daemon_msg "Stopping $DESC" "$NAME"
 51	start-stop-daemon --exec $DAEMON --pidfile $PIDFILE --stop --retry 5
 52	log_end_msg $?
 53	;;
 54
 55   "status")
 56	if test -s $PIDFILE
 57	then
 58		kill -0 `cat $PIDFILE`
 59		if test $? -eq 0
 60		then
 61			echo "Hobbit (hobbitlaunch) running with PID `cat $PIDFILE`"
 62			exit 0
 63		else
 64			echo "Hobbit not running, removing stale PID file"
 65			rm -f $PIDFILE
 66			exit 1
 67		fi
 68	else
 69		echo "Hobbit (hobbitlaunch) does not appear to be running"
 70		exit 3
 71	fi
 72	;;
 73
 74   "restart")
 75	if test -s $PIDFILE
 76	then
 77		$0 stop
 78		sleep 1
 79		$0 start
 80	else
 81		log_action_msg "hobbitlaunch does not appear to be running, starting it"
 82		$0 start
 83	fi
 84	;;
 85
 86   "reload"|"force-reload")
 87	if test -s $PIDFILE
 88	then
 89		create_includefiles
 90		log_action_msg "Reloading hobbitd config"
 91		kill -HUP `cat /var/run/hobbit/hobbitd.pid`
 92	else
 93		log_action_msg "hobbitd not running (no PID file)"
 94	fi
 95	;;
 96
 97   "rotate")
 98	for PIDFILE in /var/run/hobbit/*.pid
 99	do
100		test -e $PIDFILE && kill -HUP `cat $PIDFILE`
101	done
102	;;
103
104   *)
105   	echo "Usage: $0 start|stop|restart|force-reload|reload|status|rotate"
106	break;
107esac
108
109exit 0
110