#!/bin/bash # # apache2 Start the apache2 HTTP and HTTPS server. # # The variables below are NOT to be changed. They are there to make the # script more readable. # # * 2007/08/10 (Yasuhiro MORIKAWA) Modified from /etc/init.d/apache in debian package # ### BEGIN INIT INFO # Provides: apache2 # Required-Start: $remote_fs # Required-Stop: $remote_fs # Should-Start: $network $syslog # Should-Stop: $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start and stop apache2 # Description: apache2 is a web server ### END INIT INFO NAME=apache2 CONF=/usr/local/$NAME/conf/httpd.conf APACHECTL=/usr/local/$NAME/bin/apachectl # note: SSD is required only at startup of the daemon. ENV="env -i LANG=C PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/apache2/bin" trap "" 1 # Check that we're not being started by inetd if egrep -q -i "^[[:space:]]*ServerType[[:space:]]+inet" $CONF then exit 0 fi test_config() { if [ ! -x $APACHECTL ]; then echo "$APACHECTL is not executable, exiting" exit 0 fi # ensure we don't leak environment vars into apachectl APACHECTL="$ENV $APACHECTL" if ! $APACHECTL configtest 2> /dev/null then printf "Configuration syntax error detected. Not reloading.\n\n" $APACHECTL configtest exit 1 fi } case "$1" in start) test_config echo -n "Starting web server: $NAME" $APACHECTL -k start ;; stop) echo -n "Stopping web server: $NAME" $APACHECTL -k graceful-stop ;; restart) test_config echo -n "Restarting $NAME" $APACHECTL -k graceful ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart}" exit 1 ;; esac if [ $? -eq 0 ]; then echo . exit 0 else echo " failed" exit 1 fi