#!/bin/bash

# A common configuration mistake is to leave "PidFile /var/run/apache.pid"
# in the configuration file.  Abort if we see this.

if [ -f /etc/apache-perl/httpd.conf ]; then
  if grep '^PidFile /var/run/apache\.pid' /etc/apache-perl/httpd.conf >/dev/null 2>/dev/null; then
    echo 'apache-perl: Incorrect PidFile in /etc/apache-perl/httpd.conf.'
    exit 0
  fi
fi

#! /bin/bash
#
# apache	Start the apache HTTP server.
#

NAME=apache-perl
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/apache-perl
SUEXEC=/usr/lib/apache/suexec
PIDFILE=/var/run/$NAME.pid
CONF=/etc/apache-perl/httpd.conf
APACHECTL=/usr/sbin/apache-perl-ctl

trap "" 1
export LANG=C
export PATH

test -f $CONF || exit 0
test -f $DAEMON || exit 0
test -f $APACHECTL || exit 0

# ensure we don't leak environment vars into apachectl
APACHECTL=/usr/sbin/apache-perl-ctl

if egrep -q -i "^[[:space:]]*ServerType[[:space:]]+inet" $CONF
then
    exit 0
fi

case "$1" in
  start)
    echo -n "Starting web server: $NAME"
    start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON
    ;;

  stop)
    echo -n "Stopping web server: $NAME"
    start-stop-daemon --stop --pidfile $PIDFILE --oknodo --exec $DAEMON
    ;;

  reload)
    echo -n "Reloading $NAME configuration"
    start-stop-daemon --stop --pidfile $PIDFILE --signal USR1 --exec $DAEMON
    ;;

  reload-modules)
    echo -n "Reloading $NAME modules"
    start-stop-daemon --stop --pidfile $PIDFILE --oknodo --retry 30
    start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON
    ;;

  restart)
    $0 reload-modules
    exit $?
    ;;

  force-reload)
    $0 reload-modules
    exit $?
    ;;

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

if [ $? == 0 ]; then
	echo .
	exit 0
else
	echo failed
	exit 1
fi
