#! /bin/sh # # <%= scope.lookupvar('xymon::client::service_name') %> This shell script takes care of starting and stopping # the xymon client. ### BEGIN INIT INFO # Provides: <%= scope.lookupvar('xymon::client::service_name') %> hobbit-client # Required-Start: $remote_fs $network # Should-Start: $all # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Xymon system monitor client # Description: Client to feed system data to a remote Xymon server. ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON="/usr/lib/xymon/client/bin/xymonlaunch" NAME=<%= scope.lookupvar('xymon::client::service_name') %> DESC="Xymon Client" PIDFILE="/var/run/xymon/clientlaunch.pid" XYMONCLIENTHOME="/usr/lib/xymon/client" test -x $DAEMON || exit 0 . /lib/lsb/init-functions . /usr/share/xymon/init-common.sh # Include <%= scope.lookupvar('xymon::client::service_name') %> defaults if available if [ -f <%= scope.lookupvar('xymon::client::service_default_path') %> ] ; then . <%= scope.lookupvar('xymon::client::service_default_path') %> fi [ -z "$MACHINE" ] && MACHINE="$CLIENTHOSTNAME" [ -z "$MACHINEDOTS" ] && MACHINEDOTS="`hostname -f`" export XYMONSERVERS XYMONCLIENTHOME CLIENTHOSTNAME MACHINE MACHINEDOTS case "$1" in start) # do not run the client script on the server [ -x /usr/lib/xymon/server/bin/xymond ] && exit 0 create_includefiles if test "$TMPFSSIZE" && test -e /proc/mounts && ! grep -q /var/lib/xymon/tmp /proc/mounts; then echo "Mounting tmpfs on /var/lib/xymon/tmp" rm -f /var/lib/xymon/tmp/* mount -t tmpfs -o"size=$TMPFSSIZE,mode=755,uid=$(id -u xymon)" tmpfs /var/lib/xymon/tmp fi log_daemon_msg "Starting $DESC" "$NAME" start-stop-daemon --exec $DAEMON --chuid xymon --umask 022 --start \ -- \ --config=/etc/xymon/clientlaunch.cfg \ --log=/var/log/xymon/clientlaunch.log \ --pidfile=$PIDFILE log_end_msg $? ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" start-stop-daemon --exec $DAEMON --pidfile $PIDFILE --stop --retry 5 log_end_msg $? ;; status) if test -s $PIDFILE then kill -0 `cat $PIDFILE` if test $? -eq 0 then echo "Xymon client running with PID `cat $PIDFILE`" exit 0 else echo "Xymon client not running, removing stale PID file" rm -f $PIDFILE exit 1 fi else echo "Xymon client does not appear to be running" exit 3 fi ;; restart) if [ -x /usr/lib/xymon/server/bin/xymond ] ; then log_action_msg "Xymon server installed. Please restart 'xymon' instead" exit 0 fi $0 stop sleep 1 $0 start ;; reload|force-reload) [ -x /usr/lib/xymon/server/bin/xymond ] && exit 0 create_includefiles kill -HUP `cat /var/run/xymon/clientlaunch.pid` ;; rotate) for PIDFILE in /var/run/xymon/*.pid do test -e $PIDFILE && kill -HUP `cat $PIDFILE` done ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload|status|rotate}" >&2 exit 1 ;; esac exit 0