summaryrefslogtreecommitdiffstats
path: root/Services
diff options
context:
space:
mode:
Diffstat (limited to 'Services')
-rw-r--r--Services/apache/docker-compose.yml1
-rw-r--r--Services/apache/httpd.conf2
-rw-r--r--Services/apache/run.sh4
-rw-r--r--Services/apache/sx-httpd.sh36
-rw-r--r--Services/php/run.sh49
5 files changed, 41 insertions, 51 deletions
diff --git a/Services/apache/docker-compose.yml b/Services/apache/docker-compose.yml
index b8130ef..e0a016f 100644
--- a/Services/apache/docker-compose.yml
+++ b/Services/apache/docker-compose.yml
@@ -10,6 +10,7 @@ apache:
CONTAINER_TYPE: "service"
CONTAINER_SERVICE: "apache"
CONTAINER_INSTANCE: "sx-apache"
+ SERVER_NAME: "localhost"
volumes:
- "/tmp/container/logs:/data/logs"
- "/tmp/container/www:/data/www" \ No newline at end of file
diff --git a/Services/apache/httpd.conf b/Services/apache/httpd.conf
index f612424..8b04449 100644
--- a/Services/apache/httpd.conf
+++ b/Services/apache/httpd.conf
@@ -16,4 +16,4 @@ Alias / /data/www
Allow from All
Require all granted
DirectoryIndex index.html home.html
-</Directory> \ No newline at end of file
+</Directory>
diff --git a/Services/apache/run.sh b/Services/apache/run.sh
index 8cb8010..a02537e 100644
--- a/Services/apache/run.sh
+++ b/Services/apache/run.sh
@@ -10,8 +10,8 @@ fi
check_environment
check_httpd_environment
-display_container_header
+display_container_httpd_header
begin_config
end_config
-start_daemon
display_container_started
+start_daemon
diff --git a/Services/apache/sx-httpd.sh b/Services/apache/sx-httpd.sh
index ad7b995..6b2a417 100644
--- a/Services/apache/sx-httpd.sh
+++ b/Services/apache/sx-httpd.sh
@@ -2,8 +2,35 @@
function check_httpd_environment {
if [ ! -v SERVER_NAME ]; then
- export SERVER_NAME=$CONTAINER_NAME
+ SERVER_NAME="localhost"
+ export SERVER_NAME
+ echo "! WARNING : environment var SERVER_NAME is missing..."
+ echo "! WARNING : auto-assigned value : $SERVER_NAME"
fi
+ if [ ! -v DOCROOT ]; then
+ DOCROOT="/data/www"
+ export DOCROOT
+ echo "! WARNING : environment var DOCROOT is missing..."
+ echo "! WARNING : auto-assigned value : $DOCROOT"
+ fi
+}
+
+function display_container_httpd_header {
+ echo "+====================================================="
+ echo "| Container : $HOSTNAME"
+ if [ -v CONTAINER_TYPE ]; then
+ echo "| Type : $CONTAINER_TYPE"
+ fi
+ if [ -v CONTAINER_INSTANCE ]; then
+ echo "| Instance : $CONTAINER_INSTANCE"
+ fi
+ if [ -v CONTAINER_SERVICE ]; then
+ echo "| Service : $CONTAINER_SERVICE"
+ fi
+ if [ -v CONTAINER_SERVICE ]; then
+ echo "| ServerName : $SERVER_NAME"
+ fi
+ echo "+====================================================="
}
# Begin configuration before starting daemonized process
@@ -12,10 +39,13 @@ 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 "=> Set DocumentRoot to $DOCROOT in $HTTPDCONF"
echo "DocumentRoot \"$DOCROOT\"" >> $HTTPDCONF
fi
+ if [ -v SERVER_NAME ]; then
+ echo "=> Set ServerName to $SERVER_NAME in $HTTPDCONF"
+ echo "ServerName \"$SERVER_NAME\"" >> $HTTPDCONF
+ fi
}
# End configuration process just before starting daemon
diff --git a/Services/php/run.sh b/Services/php/run.sh
index bcddd35..a02537e 100644
--- a/Services/php/run.sh
+++ b/Services/php/run.sh
@@ -1,49 +1,8 @@
#!/bin/bash
-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-PHP 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-PHP 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 + php server"
- /usr/sbin/apachectl &
- sleep 2
-}
-
-# Stop the httpd server running in background.
-function stop_server {
- echo "=> Stopping httpd + php 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 + php daemon ..."
- exec /usr/sbin/apachectl -D FOREGROUND
-}
-
-
+source /bin/sx-lib.sh
+source /bin/sx-httpd.sh
if [[ "$0" == *"run.sh" && ! $1 = "" ]];then
eval "$@";
@@ -51,8 +10,8 @@ fi
check_environment
check_httpd_environment
-display_container_header
+display_container_httpd_header
begin_config
end_config
-start_daemon
display_container_started
+start_daemon