#!/bin/sh
#
# Latmos-Account web application
#
# chkconfig: 345 97 3
# description: Latmos-Account web application

. /etc/rc.d/init.d/functions
[ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
export LC_ALL
export LANG

USER=nobody
PORT=4000
[ -f /etc/sysconfig/latmos-accounts ] && \
    . /etc/sysconfig/latmos-accounts

RETVAL=0
prog=latmos_accounts_web

function start () {
    gprintf "Starting %s: " "$prog"
    daemon --user $USER /usr/bin/latmos_accounts_web_server.pl --daemon --fork --port $PORT --host localhost --forcehttps 2>/dev/null
    [ $? -eq 0 ] && success || failure
    touch /var/lock/subsys/$prog
    echo
}

function stop () {
    gprintf "Stopping %s: " "$prog"
    killproc latmos_accounts_web_server.pl
    rm -f /var/lock/subsys/$prog
    echo
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	status latmos_accounts_web_server.pl
	;;
    restart)
	stop
	start
	;;
    reload)
	stop
	start
	;;
    *)
	gprintf "Usage: $0 {start|stop|status|restart|reload}\n"
	exit 1
esac

exit $RETVAL
