#!/bin/bash
#
# webs init script.
#
# description: HP Instant TopTools web server.

# Source function library.
. /etc/rc.config

test -x /usr/itt/bin/webs || exit 0

# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}


# Force execution if not called by a runlevel directory.
test $link = $base && START_ITT="yes"
test "$START_ITT" = yes || exit 0

#
#	See how we were called.
#
return=$rc_done
case "$1" in
  start)
	# Check if webs is already running
	if [ ! -f /var/lock/subsys/webs ]; then
	    echo -n 'Starting HP Instant TopTools web server: '
	    startproc /usr/itt/bin/webs || return=$rc_failed
	    [ "$return" = "$rc_done" ] && touch /var/lock/subsys/webs
	    echo -e "$return"
	fi
	;;
  stop)
	echo -n 'Stopping HP Instant TopTools web server: '
	killproc /usr/itt/bin/webs || return=$rc_failed
	[ "$return" = "$rc_done" ] && rm -f touch /var/lock/subsys/webs
	echo -e "$return"
	;;
  reload|restart)
	$0 stop
	$0 start
	;;
  status)
	checkproc /usr/itt/bin/webs && echo OK || echo No process
	;;
  *)
	echo "Usage: /etc/rc.d/init.d/webs {start|stop|restart|reload|status}"
	exit 1
esac

test "$return" = "$rc_done" || exit 1
exit 0
