#! /bin/bash
# $Id: httpdCheck,v 1.2 2005/03/08 22:40:56 tom Exp $
# $Source: /home/CVS/fireballTop/fireballFS/root/usr/local/fireball/httpdCheck,v $
#
# httpdCheck
# Monitors httpd startup to emit an indication when the web server
# has finished starting.  Due to the long startup times for modperl
# under httpd, it can take a very long time after bootup before web
# access is available.  This script attempts to give an indication on
# the console when the web server finishes its initialization.  It
# detects this by counting the instances of httpd in the ps listing.
# If none are detected, httpd isn't even starting and we exit.
# If only one is detected, then httpd is still initializing.
# When more than one is detected, then httpd is running; we emit a
# message and exit.

echo -e "Web server starting up.  Takes about 30 seconds.\r"
while true
do
  (( count = $(ps | grep ' httpd ' | wc -l) ))
  #echo "__${count}__"
  if [[ $count = 1 ]]
  then
    echo -e "No Web Server running.\r"
    exit
  fi
  if [[ $count != '2' ]]
  then
    echo -e "Web Server ready.\r"
    exit
  fi
  
  sleep 5
done
