#!/bin/sh

if [ $# = 1 ]
then
	APACHE_HOMEDIR=$1
else
	APACHE_HOMEDIR=.
fi

cd $APACHE_HOMEDIR/..

. ./setEnv.sh

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NMS_HOME/lib:$WEBSERVER_HOME/lib
export LD_LIBRARY_PATH


cp -f $WEBSERVER_HOME/conf/backup/httpd.conf $WEBSERVER_HOME/conf
cp -f $WEBSERVER_HOME/ssl/backup/ssl.conf $WEBSERVER_HOME/ssl
cp -f $TOMCAT_HOME/conf/backup/server.xml  $TOMCAT_HOME/conf
cp -f $TOMCAT_HOME/conf/backup/mod_jk.conf-auto  $TOMCAT_HOME/conf/mod_jk.conf-nms
cp -f $TOMCAT_HOME/conf/backup/workers.properties  $TOMCAT_HOME/conf/workers.properties
cp -f $WEBSERVER_HOME/bin/backup/apachectl $WEBSERVER_HOME/bin

CLASS_PATH=$NMS_HOME/classes



$JAVA_HOME/bin/java -Dwebserver.rootdir=$WEBSERVER_HOME -Dwebnms.rootdir=$NMS_HOME -Dwebserver.port=$WEBSERVER_PORT -Dssl.port=$SSL_PORT -cp  $CLASS_PATH com.adventnet.nms.util.InitWebSvr $WEBSERVER_HOME/conf/httpd.conf $TOMCAT_HOME/conf/server.xml $TOMCAT_HOME/conf/mod_jk.conf-nms  $TOMCAT_HOME/conf/workers.properties $WEBSERVER_HOME/bin/apachectl $WEBSERVER_HOME/ssl/ssl.conf

cd apache
bin/httpd -d . -f conf/httpd.conf -D SSL
cd $OLDPWD
