#!/bin/sh
#$Id: hasplm.redhat,v 1.3 2004/06/08 14:54:28 chris Exp $
#
# chkconfig: 2345 28 72
# description: HASP License Manager
# processname: /usr/sbin/hasplm

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration and check that networking is up.
if [ -f /etc/sysconfig/network ] ; then
	. /etc/sysconfig/network
	[ ${NETWORKING} = "no" ] && exit 0
fi

[ -x /usr/sbin/hasplm ] || exit 0

RETVAL=0

start () {
    echo -n "Starting HASP LM: "
    # start daemon
    daemon /usr/sbin/hasplm
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/subsys/hasplm
    return $RETVAL
}

stop () {
    # stop daemon
    echo -n "Stopping HASP LM: "
    killproc /usr/sbin/hasplm
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/hasplm
    return $RETVAL
}

restart () {
    stop
    start
    RETVAL=$?
    return $RETVAL
}

# See how we were called.
case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	status /usr/sbin/hasplm
	RETVAL=$?
	;;
    restart)
	restart
	;;
    condrestart)
	# only restart if it is already running
	[ -f /var/lock/subsys/hasplm ] && restart || :
	;;
    reload)
	echo -n "Reloading HASP LM: "
	killproc /usr/sbin/hasplm -HUP
	RETVAL=$?
	echo
	;;
    *)
        echo "Usage: hasplm {start|stop|restart|condrestart|reload|status}"
        RETVAL=1
esac

exit $RETVAL
