#!/bin/sh

##
# Yaws HTTP Server
##

. /etc/rc.common

yaws=%bindir%/yaws
lockdir=/var/spool/lock
#yawsid_opts='--id myserverid'
conf="--conf %etcdir%/yaws/yaws.conf"

StartService ()
{
    if [ "${YAWS:=-NO-}" = "-YES-" ]; then
        ConsoleMessage "Starting yaws http daemon"
        HOME=/tmp $yaws ${yawsid_opts} --daemon --heart ${conf}
        HOME=/tmp $yaws ${yawsid_opts} --wait-started=10 >/dev/null
        RETVAL=$?
        [ $RETVAL = 0 ]
    fi
}

StopService ()
{
    ConsoleMessage "Stopping yaws http daemon"
    HOME=/tmp $yaws  ${yawsid_opts} --stop
        HOME=/tmp $yaws ${yawsid_opts} --wait-stopped=10 >/dev/null
}

RestartService ()
{
    if [ "${YAWS:=-NO-}" = "-YES-" ]; then
        ConsoleMessage "Restarting yaws http daemon"
        HOME=/tmp $yaws ${yawsid_opts} --hup
    else
        StopService
    fi
}

RunService "$1"
