#!/bin/bash

INSTALL_DIR=$1
DOCUMENT_ROOT=$2
HTTP_PORT=$3
SSL_PORT=$4

echo "INSTALL_DIR = $INSTALL_DIR"
echo "DOCUMENT_ROOT = $DOCUMENT_ROOT"
echo "HTTP_PORT = $HTTP_PORT"
echo "SSL_PORT = $SSL_PORT"

sed -i "s#_SRVROOT_SRC_#${INSTALL_DIR}#g" $1/conf/httpd.conf
sed -i "s#_DOCROOT_SRC_#${DOCUMENT_ROOT}#g" $1/conf/httpd.conf
sed -i "s#_HTTP_LISTEN_PORT_#${HTTP_PORT}#g" $1/conf/httpd.conf
sed -i "s#_SSL_LISTEN_PORT_#${SSL_PORT}#g" $1/conf/httpd-ssl.conf

sed -i "s#_SRVROOT_SRC_#${INSTALL_DIR}#g" $1/bin/apachectl
sed -i "s#_SRVROOT_SRC_#${INSTALL_DIR}#g" $1/bin/start.sh
sed -i "s#_SRVROOT_SRC_#${INSTALL_DIR}#g" $1/bin/stop.sh
