PageRenderTime 37ms CodeModel.GetById 29ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/rc5.d/S98hobbit-client

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