Apache Logo

Example Startup Script

Modify the four variables:

    HTTPD
    HTTPD_CONF
    HTTPD_PID
    CAT
then place this script where system startup scripts belong.

On RedHat Linux:

    cp filename /etc/rc.d/init.d/webserver
    cd /etc/rc.d/rc3.d
    ln -s ../init.d/webserver S90webserver
Substituting for filename as appropriate.


#!/bin/sh


HTTPD="/tmp/web/bin/httpd"
HTTPD_CONF="/tmp/web/conf/httpd.conf"
HTTPD_PID="/tmp/web/logs/httpd.pid"
CAT="/bin/cat"
DEPENDENCIES="$HTTPD $HTTPD_CONF"
         
# Save argument
arg=$1

set `id`
if [ $1 != "uid=0(root)" ]
then
	echo "$0: script must be run by root.  Exiting..."
	exit 1
fi

for FILE in $DEPENDENCIES
do
	if [ ! -f $FILE ]
	then
		echo "$0: Missing component '$FILE'.  Exiting"
		exit 1
	fi
done


# See how we were called.
case "$arg" in
  start)
	echo -n "Starting Web server: "
	$HTTPD -f $HTTPD_CONF
	echo "httpd"
	;;
  hup)
	# Reread the configuration files
        echo -n "Rereading the http configuration files: "
	kill -HUP `$CAT $HTTPD_PID`
	echo "done"
	;;
  stop)
	# Stop daemons
	echo -n "Shutting down Web server: "
	kill `$CAT $HTTPD_PID`
	echo "httpd"
	;;
  *)
	echo "Usage: $0 {start|stop}"
	exit 1
esac

exit 0

Last Modified: 17 February 1997

St. Louis Unix Users Group - Linux SIG