#!/bin/bash
#
# hpswvsvc init script.
#
# description: HP Software Version daemon.

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

test -x /usr/hpserver/bin/hpswvsvc || exit 1

# 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_HPSWVSVC="yes"
test "$START_HPSWVSVC" = yes || exit 0

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

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

