diff options
Diffstat (limited to 'Services/apache/run.sh')
-rw-r--r-- | Services/apache/run.sh | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/Services/apache/run.sh b/Services/apache/run.sh index ef073a3..7e2fb8e 100644 --- a/Services/apache/run.sh +++ b/Services/apache/run.sh @@ -1,7 +1,57 @@ #!/bin/bash -source /sx/httpd.sh +source /bin/sx-lib.sh +export HTTPDCONF=/etc/httpd/conf.d/app.conf +# Begin configuration before starting daemonized process +# and start generating host keys +function begin_config { + echo "=> BEGIN APACHE CONFIGURATION" + mkdir -p /var/run/httpd + if [ -v DOCROOT ]; then + echo "=> Changing document root to $DOCROOT" + ${DOCROOT=/data/www} + echo "DocumentRoot \"$DOCROOT\"" >> $HTTPDCONF + fi +} + +# End configuration process just before starting daemon +function end_config { + stop_server + echo "=> END APACHE CONFIGURATION" +} + +# Start the httpd server in background. Used to perform config +# against the database structure such as user creation +function start_server { + echo "=> Starting httpd server" + /usr/sbin/apachectl & + sleep 2 +} + +# Stop the httpd server running in background. +function stop_server { + echo "=> Stopping httpd server ..." + killall httpd + rm -rf /run/httpd/* + sleep 2 +} + +# Start the httpd server as a deamon and execute it inside +# the running shell +function start_daemon { + echo "=> Starting httpd daemon ..." + exec /usr/sbin/apachectl -D FOREGROUND +} + + + +if [[ "$0" == *"httpd.sh" && ! $1 = "" ]];then + eval "$@"; +fi + + +display_container_header begin_config end_config - -start_daemon
\ No newline at end of file +start_daemon +display_container_started |