<!-- Oracle Remote Diagnostic Agent / Data Collection Results 4.29 -->
<!-- Module:S313IREQ Version:1.23 Report:ohs_apachectl OS:linux -->
---+ Content Taken from File /u01/install/APPS/fs1/FMW_Home/as_1/ohs/bin/apachectl
<verbatim>
#!/bin/sh
#
# Apache control script designed to allow an easy command line interface
# to controlling Apache.  Written by Marc Slemko, 1997/08/23
# 
# The exit codes returned are:
#	0 - operation completed successfully
#	1 - 
#	2 - usage error
#	3 - httpd could not be started
#	4 - httpd could not be stopped
#	5 - httpd could not be started during a restart
#	6 - httpd could not be restarted during a restart
#	7 - httpd could not be restarted during a graceful restart
#	8 - configuration syntax error
#
# When multiple arguments are given, only the error from the _last_
# one is reported.  Run "apachectl help" for usage info
#
#
# |||||||||||||||||||| START CONFIGURATION SECTION  ||||||||||||||||||||
# --------------------                              --------------------
#
#

# The Linux dynamic linker is not completely thread safe, and so we must force
# all symbols to be resolved whenever a shared library is loaded: bug 6468858
LD_BIND_NOW=true; export LD_BIND_NOW

#set ulimit for OHS to dump core when it crashes
#ulimit -c unlimited

MACH=`uname -m`

ORACLE_HOME=$ORACLE_HOME; export ORACLE_HOME

LD_LIBRARY_PATH=$ORACLE_HOME/ohs/lib:$ORACLE_HOME/opmn/lib:$ORACLE_HOME/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH

PERL5LIB=$ORACLE_HOME/ohs/mod_perl/lib/site_perl/5.10.0/$MACH-linux-thread-multi:$ORACLE_HOME/perl/lib/5.10.0:$ORACLE_HOME/perl/lib/site_perl/5.10.0:$PERL5LIB; export PERL5LIB


NLS_LANG=${NLS_LANG="AMERICAN_AMERICA.WE8ISO8859P1"}; export NLS_LANG
#

# 
TNS_ADMIN=${TNS_ADMIN="$ORACLE_HOME/network/admin"}; export TNS_ADMIN

#check ORACLE_CONFIG_HOME
if [ -z "$ORACLE_CONFIG_HOME" ]
then
     ORACLE_CONFIG_HOME=${ORACLE_HOME}; export ORACLE_CONFIG_HOME
fi

# the path to our PID file
if [ -z "$ORACLE_INSTANCE" ]
then
  PIDFILE=${ORACLE_CONFIG_HOME}/logs/httpd.pid
  CONFIGOPTS="-d $ORACLE_HOME/ohs"
else
  PIDFILE=${COMPONENT_LOG_PATH}/httpd.pid
  CONFIGOPTS=
fi
#
# a command that outputs a formatted text version of the HTML at the
# url given on the command line.  Designed for lynx, however other
# programs may work.  
LYNX="lynx -dump"
#
# the URL to your server's mod_status status page.  If you do not
# have one, then status and fullstatus will not work.
STATUSURL="http://localhost:7779/server-status"
#
# --------------------                              --------------------
# ||||||||||||||||||||   END CONFIGURATION SECTION  ||||||||||||||||||||

#
# Start the server with the given options
#
ohs_start ()
{
  if isrun verbose
  then
    return
  fi

  args=
  while [ $# -gt 0 ]
  do
    args="$args \"$1\""
    shift
  done

  echo "$PROG $COMMAND: execing httpd"
  HTTPD="exec $HTTPD"

  if eval $HTTPD $CONFIGOPTS $args
  then
    echo "$PROG $COMMAND: httpd started"
  else
    echo "$PROG $COMMAND: httpd could not be started"
    ERROR=3
  fi
}

ohs_startssl ()
{
  args=
  while [ $# -gt 0 ]
  do
    args="$args \"$1\""
    shift
  done

  eval ohs_start -DSSL "$args"
}

#
# Restart the server with the given options
#
ohs_restart ()
{
  args=
  while [ $# -gt 0 ]
  do
    args="$args \"$1\""
    shift
  done

  if notrun
  then
    echo "$PROG $COMMAND: httpd not running, trying to start"
    if eval $HTTPD $CONFIGOPTS $args
    then
      echo "$PROG $COMMAND: httpd started"
    else
      echo "$PROG $COMMAND: httpd could not be started"
      ERROR=5
    fi
  else
    if [ "x$GRACEFULL" = "x" ]
    then
      SIG="-HUP"
      error=6
    else
      SIG="-USR1"
      error=7
    fi
    if eval $HTTPD -t $CONFIGOPTS $args > /dev/null
    then
      if kill $SIG $PID ; then
        echo "$PROG $COMMAND: httpd restarted"
      else
        echo "$PROG $COMMAND: httpd could not be restarted"
        ERROR=$error
      fi
    else
      echo "$PROG $COMMAND: configuration broken, ignoring restart"
      echo "$PROG $COMMAND: (run 'apachectl configtest' for details)"
      ERROR=$error
    fi
  fi
}

ohs_restartssl ()
{
  args=
  while [ $# -gt 0 ]
  do
    args="$args \"$1\""
    shift
  done

  eval ohs_restart -DSSL "$args"
}

ohs_graceful ()
{
  args=
  while [ $# -gt 0 ]
  do
    args="$args \"$1\""
    shift
  done

  GRACEFULL=true
  eval ohs_restart "$args"
  GRACEFULL=
}

ohs_gracefulssl ()
{
  args=
  while [ $# -gt 0 ]
  do
    args="$args \"$1\""
    shift
  done

  GRACEFULL=true
  eval ohs_restart -DSSL "$args"
  GRACEFULL=
}

#
# Stop the server
#
ohs_stop ()
{
  if notrun verbose
  then
    return
  fi
  
  if [ $COMMAND = "hardstop" ]
  then
    SIG="-KILL"
  elif [ $COMMAND = "gracefulstop" ]
  then
    SIG="-WINCH"
  else
    SIG=
  fi

  if kill $SIG $PID
  then
    echo "$PROG $COMMAND: httpd stopped"
  else
    echo "$PROG $COMMAND: httpd could not be stopped"
    ERROR=4
  fi
}

ohs_hardstop ()
{
  ohs_stop
}

ohs_gracefulstop ()
{
  ohs_stop
}

#
# Generate status from the server
#
ohs_status ()
{
  $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
}

ohs_fullstatus ()
{
  $LYNX $STATUSURL
}

#
# Test the server configuration
#
ohs_configtest ()
{
  args=
  while [ $# -gt 0 ]
  do
    args="$args \"$1\""
    shift
  done

  if eval $HTTPD $CONFIGOPTS -t "$args"
  then
    :
  else
    ERROR=8
  fi
}

#
# Check for a running condition
#
checkrun ()
{
  if [ -f $PIDFILE ]
  then
    PID=`cat $PIDFILE`
    if [ "x$PID" != "x" ] && kill -0 $PID 2> /dev/null
    then
      STATUS="httpd (pid $PID) running"
      return 0
    else
      STATUS="httpd (pid $PID?) not running"
      return 1
    fi
  else
    STATUS="httpd (no pid file) not running"
    return 1
  fi
}

#
# Check if the server is ALREADY running
#
isrun ()
{
  if checkrun
  then
    if [ $# -eq 1 ]
    then
      echo "$PROG $COMMAND: httpd (pid $PID) already running"
    fi
    return 0
  else
    return 1
  fi
}

#
# Check if the server is NOT running
#
notrun ()
{
  if checkrun
  then
    return 1
  else
    if [ $# -eq 1 ]
    then
      echo "$PROG $COMMAND: $STATUS"
    fi
    return 0
  fi
}

#
# Check the validity of the supplied config file
#
checkconfigfile ()
{
  if [ "x$F_FOUND" != "x" ]
  then
    echo "$PROG: only one -f <configfile> is permitted"
    usage 2
  elif [ $# -ne 1 -o "x$1" = "x" ]
  then
    echo "$PROG: -f requires <configfile>"
    usage 2
  fi
  if [ ! -f $1 ]
  then
    echo "$PROG: $1 does not exist"
    exit 8
  fi
  PIDFILE=`grep PidFile $1 | grep -v "#" | cut -d" " -f 2`
  if [ "x$PIDFILE" = "x" ]
  then
    echo "$PROG: failed to find PidFile in $1"
    exit 8
  fi
}

#
# Print usage and exit
#
usage ()
{

echo "Usage: $PROG (start|startssl) [-f <configfile>] [-D <name>]"
echo "Usage: $PROG (restart|restartssl) [-f <configfile>] [-D <name>]"
echo "Usage: $PROG (graceful|gracefulssl) [-f <configfile>] [-D <name>]"
echo "Usage: $PROG (configtest) [-f <configfile>] [-D <name>]"
echo "Usage: $PROG (stop|fullstatus|status|graceful-stop|help)"

echo "start         - start httpd"
echo "startssl      - start httpd with SSL enabled"
echo "stop          - stop httpd"
echo "restart       - restart httpd if running by sending a SIGHUP or start if" 
echo "                not running"
echo "restartssl    - restart httpd if running by sending a SIGHUP or start "
echo "                in SSL mode if not running"
echo "fullstatus    - dump a full status screen; requires lynx and mod_status enabled"
echo "status        - dump a short status screen; requires lynx and mod_status enabled"
echo "graceful      - do a graceful restart by sending a SIGUSR1 or start if not running"
echo "gracefulssl   - do a graceful restart by sending a SIGUSR1 or start in SSL "
echo "                mode if not running"
echo "graceful-stop - do a graceful stop by sending a SIGWINCH"
echo "configtest    - do a configuration syntax test"
echo "help          - this screen"

echo "-f <config file> - Specify a configuration file"

echo "-D <name> - define a name for use in <IfDefine name> directives"

  exit $1
}

#
# Main execution entry point
#

# Set the file descriptor soft limit to the file descriptor hard limit.
#
# Administrators:  The file descriptor limit (ulimit -n) no longer has
# to be updated here.  Use the appropriate system configuration mechanism
# to control the file descriptor hard limit for the user which starts OPMN
# and OHS.  The soft limit will be automatically raised accordingly.

PLAT=`uname -s`
case $PLAT in
    AIX)
        ulimit -S -n unlimited
        ;;
    *)
        ulimit -S -n `ulimit -H -n`
        ;;
esac

#
# We need at least a command type to operate
#
PROG=$0
if [ $# -eq 0 ]
then
  usage 2
fi

#
# Group the commands with their options and execute them one at a time
#
ERROR=0
COMMANDS=
OPTIONS=
F_FOUND=


while [ $# -gt 0 ]
do
  case $1 in

  start|stop|hardstop|\
  restart|restartssl|\
  fullstatus|status|\
  graceful|gracefulssl|\
  configtest)
    COMMANDS="$COMMANDS $1";;

  startssl|sslstart|start-SSL)
    COMMANDS="$COMMANDS startssl";;

  graceful-stop|graceful_stop|gracefulstop)
    COMMANDS="$COMMANDS gracefulstop";;

  -f)
    checkconfigfile $2
    F_FOUND=true
    OPTIONS="$OPTIONS -f $2"
    shift;;

  -M)
    OHSMPM="$2"
    shift;;

  -D)
    OPTIONS="$OPTIONS -D $2"
    shift;;

  -?|help)
    usage 0;;

  *)
    usage 2;;

  esac
  shift
done

#select MPM
MPM=${OHSMPM:-worker}
_httpd="httpd"

case ${MPM} in

async   ) _httpd="httpd.async" ;;
prefork  ) _httpd="httpd.prefork" ;;
*        ) _httpd="httpd.worker" ;;
esac

# the path to your httpd binary, including options if necessary
HTTPD=$ORACLE_HOME/ohs/bin/${_httpd}
#


for COMMAND in $COMMANDS
do
  eval ohs_${COMMAND} "$OPTIONS"
done

exit $ERROR

# ====================================================================
# Copyright (c) 2001, 2006, Oracle. All rights reserved.  
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer. 
# 
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
# 
# 3. All advertising materials mentioning features or use of this
#    software must display the following acknowledgment:
#    "This product includes software developed by the Apache Group
#    for use in the Apache HTTP server project (http://www.apache.org/)."
# 
# 4. The names "Apache Server" and "Apache Group" must not be used to
#    endorse or promote products derived from this software without
#    prior written permission. For written permission, please contact
#    apache@apache.org.
# 
# 5. Products derived from this software may not be called "Apache"
#    nor may "Apache" appear in their names without prior written
#    permission of the Apache Group.
#
# 6. Redistributions of any form whatsoever must retain the following
#    acknowledgment:
#    "This product includes software developed by the Apache Group
#    for use in the Apache HTTP server project (http://www.apache.org/)."
# 
# THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.
# ====================================================================
# 
# This software consists of voluntary contributions made by many
# individuals on behalf of the Apache Group and was originally based
# on public domain software written at the National Center for
# Supercomputing Applications, University of Illinois, Urbana-Champaign.
# For more information on the Apache Group and the Apache HTTP server
# project, please see <http://www.apache.org/>.
# 
</verbatim>
[[#Top][Back to top]]
