Skip to content

Commit 7c23546

Browse files
committed
Update entrypoint.sh
Option to set DOCUMENT_ROOT #6
1 parent dcf3059 commit 7c23546

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

entrypoint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ set -eu
3131
: "${APACHE_SERVER_NAME:=""}" # set server name, example: example.com
3232
: "${APACHE_SERVER_ALIAS:=""}" # set server name, example: 'www.example.com *.example.com'
3333
: "${APACHE_SERVER_ADMIN:=""}" # set server admin, example: admin@example.com
34+
: "${APACHE_DOCUMENT_ROOT:=""}" # when unset it use default: /var/www/html
3435
: "${DISABLE_APACHE_DEFAULTSITES:="0"}" # set 1 to disable default sites (add or mount your own conf in /etc/apache2/sites-enabled)
3536
: "${ENABLE_NGINX_REMOTEIP:="0"}" # set 1 to enable (use this only behind a proxy/loadbalancer)
3637
: "${ENABLE_NGINX_STATUS:="0"}" # set 1 to enable
38+
: "${NGINX_DOCUMENT_ROOT:=""}" # when unset it use default: /var/www/html
3739

3840
PHP_INI_FILE_NAME="50-php.ini"
3941
lsb_dist="$(. /etc/os-release && echo "$ID")" # get os (example: debian or alpine) - do not change!
@@ -398,6 +400,13 @@ if [ "$APACHE_IS_EXISTS" -eq "1" -a "$DISABLE_APACHE_DEFAULTSITES" -eq "1" ]; th
398400
fi
399401
fi
400402

403+
if [ "$APACHE_IS_EXISTS" -eq "1" -a -n "$APACHE_DOCUMENT_ROOT" ]; then
404+
echo ">> setting Apache root to: ${APACHE_DOCUMENT_ROOT}"
405+
find "/etc/apache2/sites-available" -type f -name "*.conf" -print | while read -r f; do
406+
sed -ri "s#^(\s*DocumentRoot\s+)/var/www/html#\1${APACHE_DOCUMENT_ROOT}#g" "$f"
407+
done
408+
fi
409+
401410
####################################################
402411
##################### NGINX ########################
403412
####################################################
@@ -480,6 +489,11 @@ real_ip_header X-Forwarded-For;
480489
EOF
481490
fi
482491

492+
if [ "$NGINX_IS_EXISTS" -eq "1" -a -n "$NGINX_DOCUMENT_ROOT" ]; then
493+
echo ">> setting NGINX root to: ${NGINX_DOCUMENT_ROOT}"
494+
sed -ri "s#^(\s*root\s+).*;#\1${NGINX_DOCUMENT_ROOT};#g" "$NGINX_CONF_FILE"
495+
fi
496+
483497
####################################################
484498

485499
if [ "$(id -u)" -eq 0 ]; then

0 commit comments

Comments
 (0)