#!/bin/sh

#* -------------------------------------------------------------------------- */
#*                      CAT: AppLogic Global Catalog                          */
#*                                                                            */
#*                appliance.sh - Appliance controlling script                 */
#* -------------------------------------------------------------------------- */
#* Copyright (C) 2005 3Tera, Inc. All rights reserved.                        */
#*                                                                            */
#* Use of this notice does not imply publication or disclosure.               */
#* This software contains CONFIDENTIAL and PROPRIETARY information            */
#* constituting valuable TRADE SECRETS of 3Tera, Inc., which may be disclosed */
#* by 3Tera, Inc., only under strict limitations on its use and               */
#* confidentiality, and may not be (a) disclosed to third parties,            */
#* (b) copied in any form, or (c) used for any purpose except as specifically */
#* permitted in writing by 3Tera, Inc.                                        */
#* In addition, any hard-copy, printout or other tangible expression of this  */
#* software must include on every page thereof the copyright notice contained */
#* herein and the phrase "3TERA CONFIDENTIAL - HIGHLY PROPRIETARY".           */
#* -------------------------------------------------------------------------- */

# exit with no action, if this is not running in an AppLogic environment
# (standalone startup)
[[ -f /etc/applogic.sh ]] || exit 0

# import appliance properties 
source /etc/applogic.sh

# log file
logfile=/var/log/appliance/log

# perform service control command
case "$1" in
    start)
           if [[ "$__strict_startup" != "off" ]] ; then
              if ! /etc/init.d/httpd status >/dev/null ; then
                 echo "httpd did not start" >>$logfile
                 exit 1
              fi
           fi

           if ! /appliance/execute_command.sh >>$logfile 2>&1; then
              exit 1
           fi

	    sh /appliance/feed_apache_counters.sh &
             ;;

    stop)    ;;

    *)       echo "usage: $0 {start|stop}"
             exit 1
esac

exit 0


