#!/bin/bash
#
# apache	Start the apache HTTP server.
#
# The variables below are NOT to be changed.  They are there to make the
# script more readable.

set -e

. /lib/lsb/init-functions

DAEMON=/usr/local/apache/bin/httpd
PIDFILE=/var/run/httpd-adm.pid
CONF=/usr/local/apache/conf/httpd-adm.conf
APACHECTL=/usr/local/apache/bin/apachectl
# note: SSD is required only at startup of the daemon.
SSD=`which start-stop-daemon`
ENV="env -i LANG=C PATH=/bin:/usr/bin:/usr/local/bin"

ulimit -n 4096

# Check that we're not being started by inetd
if egrep -q -i "^[[:space:]]*ServerType[[:space:]]+inet" $CONF
then
    exit 0
fi


should_start() {
    if [ ! -x $DAEMON ]; then
    log_begin_msg "$DAEMON is not executable, not starting/reloading..."
    log_end_msg 1
    fi
}

case "$1" in
  start)
    should_start
    log_begin_msg "Starting $NAME 1.3 web server..."
    $DAEMON -DSSL -f $CONF
    ;;

  stop)
    echo -n "Stopping web server: $NAME"
    kill `cat $PIDFILE`
    ;;

  reload | force-reload)
    echo -n "Reloading $NAME configuration"
    kill -SIGUSR1 `cat $PIDFILE`
    ;;

  restart)
    echo -n "Restarting $NAME"
    if ! kill -SIGHUP `cat $PIDFILE`; then
        $DAEMON -DSSL -f $CONF
    fi
    ;;

  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart}"
    exit 1
    ;;
esac

