33# Exit on non defined variables and on non zero exit codes
44set -eu
55
6- # Get/Set Variables
6+ # + ---------- + #
7+ # | -- VARS -- | #
8+ # + ---------- + #
9+
710SERVER_ADMIN=" ${SERVER_ADMIN:- you@ example.com} "
811HTTP_SERVER_NAME=" ${HTTP_SERVER_NAME:- localhost} "
912HTTPS_SERVER_NAME=" ${HTTPS_SERVER_NAME:- localhost} "
@@ -12,21 +15,37 @@ TZ="${TZ:-UTC}"
1215PHP_MEMORY_LIMIT=" ${PHP_MEMORY_LIMIT:- 256M} "
1316UPLOAD_MAX_FILESIZE=" ${UPLOAD_MAX_FILESIZE:- 8M} "
1417
15- echo ' Updating Configuration: Apache Base (/etc/apache2/httpd.conf)'
18+ # If TRUE, outputs pre and post-change config files, if a /debug folder has also been mounted.
19+ # i.e. - '/opt/docker/configs/littlelink/debug:/debug:rw'
20+ # Useful for comparing (and fixing) changes, if necessary.
21+ DEBUG=" TRUE"
22+
23+ echo ' + ------------------------------------------------------------------ +'
24+ echo ' | LITTLELINK CUSTOM |'
25+
26+ # + ---------------- + #
27+ # | -- HTTPD.CONF -- | #
28+ # + ---------------- + #
29+
30+ echo ' + ------------------------------------------------------------------ +'
31+ echo ' | Updating Configuration: Apache Base (/etc/apache2/httpd.conf) |'
32+
33+ # ALTER: Server Admin, Name, Document Root.
34+
35+ if [[ ${DEBUG} == " TRUE" && -d /debug ]]; then cp /etc/apache2/httpd.conf /debug/httpd.BEFORE.conf; fi
1636
17- # Change Server Admin, Name, Document Root
1837sed -i " s/ServerAdmin\ you@example.com/ServerAdmin\ ${SERVER_ADMIN} /" /etc/apache2/httpd.conf
1938sed -i " s/#ServerName\ www.example.com:80/ServerName\ ${HTTP_SERVER_NAME} /" /etc/apache2/httpd.conf
2039sed -i ' s#^DocumentRoot ".*#DocumentRoot "/htdocs"#g' /etc/apache2/httpd.conf
2140sed -i ' s#Directory "/var/www/localhost/htdocs"#Directory "/htdocs"#g' /etc/apache2/httpd.conf
2241sed -i ' s#AllowOverride None#AllowOverride All#' /etc/apache2/httpd.conf
2342
24- # Change TransferLog after ErrorLog
43+ # ALTER: TransferLog after ErrorLog.
2544sed -i ' s#^ErrorLog .*#ErrorLog "logs/error.log"#g' /etc/apache2/httpd.conf
2645sed -i ' s#LogFormat .* %t#LogFormat "[%{%a %b %d %H:%M:%S}t.%{usec_frac}t %{%Y}t] [httpd.conf] %h %l %u#g' /etc/apache2/httpd.conf
27- sed -i ' s#CustomLog .* combined#BrowserMatchNoCase ^healthcheck nolog\n\n CustomLog "logs/access.log" combinedio env=!nolog\n#g' /etc/apache2/httpd.conf
46+ sed -i ' s#CustomLog logs .* combined#BrowserMatchNoCase ^healthcheck nolog\n\n CustomLog "logs/access.log" combinedio env=!nolog\n#g' /etc/apache2/httpd.conf
2847
29- # Re-define LogLevel
48+ # ALTER: LogLevel.
3049sed -i " s#^LogLevel .*#LogLevel ${LOG_LEVEL} #g" /etc/apache2/httpd.conf
3150
3251# Enable commonly used apache modules
@@ -35,9 +54,18 @@ sed -i 's/#LoadModule\ expires_module/LoadModule\ expires_module/' /etc/apache2/
3554sed -i ' s/#LoadModule\ logio_module/LoadModule\ logio_module/' /etc/apache2/httpd.conf
3655sed -i ' s/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/' /etc/apache2/httpd.conf
3756
38- echo ' Updating Configuration: Apache SSL (/etc/apache2/conf.d/ssl.conf)'
57+ if [[ ${DEBUG} == " TRUE" && -d /debug ]]; then cp /etc/apache2/httpd.conf /debug/httpd.AFTER.conf; fi
58+
59+ # + -------------- + #
60+ # | -- SSL.CONF -- | #
61+ # + -------------- + #
62+
63+ echo ' | Updating Configuration: Apache SSL (/etc/apache2/conf.d/ssl.conf) |'
64+
65+ # ALTER: SSL DocumentRoot and Log locations
66+
67+ if [[ ${DEBUG} == " TRUE" && -d /debug ]]; then cp /etc/apache2/conf.d/ssl.conf /debug/ssl.BEFORE.conf; fi
3968
40- # SSL DocumentRoot and Log locations
4169sed -i ' s#^ErrorLog .*#ErrorLog "logs/ssl-error.log"#g' /etc/apache2/conf.d/ssl.conf
4270sed -i " s/^TransferLog .*/#TransferLog \" logs\/ssl-transfer.log\" \nLogLevel ${LOG_LEVEL} /g" /etc/apache2/conf.d/ssl.conf
4371sed -i ' s#^DocumentRoot ".*#DocumentRoot "/htdocs"#g' /etc/apache2/conf.d/ssl.conf
@@ -47,16 +75,33 @@ sed -i "s/ServerName\ www.example.com:443/ServerName\ ${HTTPS_SERVER_NAME}/" /et
4775sed -i ' s#CustomLog .*#LogFormat "[%{%a %b %d %H:%M:%S}t.%{usec_frac}t %{%Y}t] [ssl.conf] %h %l %u \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" combined\n\nCustomLog "logs/ssl-access.log" combined#g' /etc/apache2/conf.d/ssl.conf
4876sed -i ' /.*%{SSL_PROTOCOL}x.*/d' /etc/apache2/conf.d/ssl.conf
4977
50- echo ' Updating Configuration: PHP (/etc/php8/php.ini)'
78+ if [[ ${DEBUG} == " TRUE" && -d /debug ]]; then cp /etc/apache2/conf.d/ssl.conf /debug/ssl.AFTER.conf; fi
79+
80+ # + ------------- + #
81+ # | -- PHP.INI -- | #
82+ # + ------------- + #
83+
84+ echo ' | Updating Configuration: PHP (/etc/php8/php.ini) |'
5185
52- # Modify php memory limit and timezone
86+ if [[ ${DEBUG} == " TRUE" && -d /debug ]]; then cp /etc/php8/php.ini /debug/php.BEFORE.ini; fi
87+
88+ # ALTER: Modify php memory limit and timezone
5389sed -i " s/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT} /" /etc/php8/php.ini
5490sed -i " s/upload_max_filesize = .*/upload_max_filesize = ${UPLOAD_MAX_FILESIZE} /" /etc/php8/php.ini
5591sed -i " s#^;date.timezone =\$ #date.timezone = \" ${TZ} \" #" /etc/php8/php.ini
5692
5793echo " is_llc_docker = true" >> /etc/php8/php.ini
5894
59- echo ' Updating Configuration: Complete'
60- echo ' Running Apache'
95+ if [[ ${DEBUG} == " TRUE" && -d /debug ]]; then cp /etc/php8/php.ini /debug/php.AFTER.ini; fi
96+
97+ # + ---------- + #
98+ # | -- MISC -- | #
99+ # + ---------- + #
100+
101+ echo ' | Updating Configuration: Complete |'
102+ echo ' | ------------------------------------------------------------------ |'
103+ echo ' | Running Apache |'
104+ echo ' + ------------------------------------------------------------------ +'
105+ echo
61106
62107httpd -D FOREGROUND
0 commit comments