#!/bin/bash -e
#
# Test if the web server (apache) works.

server=www

# Wait for 10 seconds
HEADOPTS="-t 10"

unset http_proxy || true
unset ftp_proxy  || true

if pidof apache > /dev/null ; then
    echo "success: $0: apache is running."
else
    echo "error: $0: apache is not running."
    exit 1
fi
	    
if [ ! -x /usr/bin/HEAD ] ; then
	echo "error: $0: Unable to find /usr/bin/HEAD."
	exit 1
else
    url=http://$server/
    if HEAD $HEADOPTS $url 2>&1 | grep -q 'Server: Apache' ; then
	echo "success: $0: Apache is listening on '$url'."
    else
	echo "error: $0: Apache is not listening on '$url'."
    fi
fi
