#!/bin/bash
# chkconfig: 234 99 00
# description: A boot script for the Freevo webserver.
#
# The Freevo webserver may also be started as a plugin by having 
# plugin.activate('www') in your local_conf.py
#
# This file may be placed in your system's init.d startup directory and
# setup to start at the appropriate runlevels.  You may instead use the
# record_server_init script to be run from init.  Init will keep an eye
# on your process and restart it if it fails.
#
# There is a file called boot_config which can be found in the boot/ 
# directory of Freevo.  This file should be copied to /etc/freevo/boot_config
# and edited to suit your needs.
#
# $Id: webserver 3631 2003-09-06 16:36:37Z mikeruelle $

# Get startup config file
test -f /etc/freevo/boot_config || exit 0
. /etc/freevo/boot_config

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON_START="$FREEVO_HOME/freevo webserver start"
DAEMON_STOP="$FREEVO_HOME/freevo webserver stop"
NAME="webserver"

test -f $DAEMON || exit 0


case "$1" in
  start)
    echo -n "Starting $NAME: "
    $DAEMON_START 2>&1 > /dev/null
    echo "done."
    ;;
  stop)
    echo -n "Stopping $NAME: "
    $DAEMON_STOP 2>&1 > /dev/null
    echo "done."
    ;;
  status)
    echo
    echo "Possible process list, if any:"
    echo
    ps -ef | grep webserver | egrep -v 'start|stop|status|tail|less|grep'
    ;;
  restart)
    echo "Restarting..."
    $0 stop
    sleep 3
    $0 start
    ;;
  *)
    echo "Usage: $0 {start|stop|status|restart}" >&2
    exit 1
    ;;
esac

exit 0
