#!/bin/sh
#
# chkconfig: 345 95 5
# description: ASMO daemon
#
### BEGIN INIT INFO
# Provides: asmod
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
### END INIT INFO

# Source function library.
# for Debian based /lib/lsb/init-functions
. /etc/rc.d/init.d/functions

exec=/opt/asmo/server/am
user="asmo"
prog="asmod"

lock=/var/lock/subsys/$prog
case "$1" in
	start)
		[ -f $lock ] && exit 2
		echo -n "Starting $prog: "
		daemon --user=$user $exec --daemon
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch $lock
		echo
		;;
	stop)
		echo -n "Stopping $prog: "
		killproc $exec
		RETVAL=$?
		rm -f $lock
		echo
		;;
	status)
		status $exec
		;;
	restart)
		$0 stop
		$0 start
		;;
	*)
		echo "Usage: $0 {start|stop|status|restart}"
		exit 3
esac
exit $RETVAL
