#!/bin/sh
#
# schedwigui:        Starts the Schedwi Web interface daemon
#
# chkconfig: - 97 03
# description:  This is the Web interface daemon.
#
# processname: schedwigui
# config: /etc/schedwisrv.conf
# config: /etc/schedwi.conf
# pidfile: /var/run/schedwisrv/schedwigui.pid
#

# Sanity checks.
[ -x "/usr/bin/schedwigui" ] || exit 0

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

RETVAL=0
PIDFILE="/var/run/schedwisrv/schedwigui.pid"

start() {
    echo -n $"Starting the Schedwi Web Interface Daemon: "
    daemon "/usr/bin/schedwigui" &>/dev/null &
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/schedwigui
}

stop() {
    echo -n $"Stopping the Schedwi Web Interface Daemon: "
    killproc "/usr/bin/schedwigui"
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ]; then
        rm -f /var/lock/subsys/schedwigui
    fi
}

# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status schedwigui
        RETVAL=$?
        ;;
    restart|reload)
        stop
        start
        ;;
    condrestart)
        if [ -f /var/lock/subsys/schedwigui ]; then
            stop
            start
        fi
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
        ;;
esac
exit $RETVAL
