33set -e
44set -x
55
6+ is_alpine () {
7+ [ -f /etc/alpine-release ]
8+ }
9+
610# Cleanup
711rm -rf /var/www/html/*
812
@@ -13,7 +17,7 @@ cp /speedtest/*.js /var/www/html/
1317cp /speedtest/favicon.ico /var/www/html/
1418
1519# Set custom webroot on alpine
16- if [ -f /etc/alpine-release ] ; then
20+ if is_alpine ; then
1721 sed -i " s#\" /var/www/localhost/htdocs\" #\" /var/www/html\" #g" /etc/apache2/httpd.conf
1822fi
1923
@@ -38,24 +42,24 @@ if [ "$MODE" != "backend" ]; then
3842fi
3943
4044# Apply Telemetry settings when running in standalone or frontend mode and telemetry is enabled
41- if [[ " $TELEMETRY " == " true" && ( " $MODE " == " frontend" || " $MODE " == " standalone" || " $MODE " == " dual" ) ]]; then
45+ if [[ " $TELEMETRY " == " true" && (" $MODE " == " frontend" || " $MODE " == " standalone" || " $MODE " == " dual" ) ]]; then
4246 cp -r /speedtest/results /var/www/html/results
4347
4448 if [ " $MODE " == " frontend" ]; then
4549 mkdir /var/www/html/backend
4650 cp /speedtest/backend/getIP_util.php /var/www/html/backend
4751 fi
4852
49- if [ " $DB_TYPE " == " mysql" ]; then
53+ if [ " $DB_TYPE " == " mysql" ]; then
5054 sed -i ' s/$db_type = ' \' ' .*' \' ' /$db_type = ' \' $DB_TYPE \' ' /g' /var/www/html/results/telemetry_settings.php
5155 sed -i ' s/$MySql_username = ' \' ' .*' \' ' /$MySql_username = ' \' $DB_USERNAME \' ' /g' /var/www/html/results/telemetry_settings.php
5256 sed -i ' s/$MySql_password = ' \' ' .*' \' ' /$MySql_password = ' \' $DB_PASSWORD \' ' /g' /var/www/html/results/telemetry_settings.php
5357 sed -i ' s/$MySql_hostname = ' \' ' .*' \' ' /$MySql_hostname = ' \' $DB_HOSTNAME \' ' /g' /var/www/html/results/telemetry_settings.php
5458 sed -i ' s/$MySql_databasename = ' \' ' .*' \' ' /$MySql_databasename = ' \' $DB_NAME \' ' /g' /var/www/html/results/telemetry_settings.php
55- if [ " $DB_PORT " != " " ]; then
59+ if [ " $DB_PORT " != " " ]; then
5660 sed -i ' s/$MySql_port = ' \' ' .*' \' ' /$MySql_port = ' \' $DB_PORT \' ' /g' /var/www/html/results/telemetry_settings.php
5761 fi
58- elif [ " $DB_TYPE " == " postgresql" ]; then
62+ elif [ " $DB_TYPE " == " postgresql" ]; then
5963 sed -i ' s/$db_type = ' \' ' .*' \' ' /$db_type = ' \' $DB_TYPE \' ' /g' /var/www/html/results/telemetry_settings.php
6064 sed -i ' s/$PostgreSql_username = ' \' ' .*' \' ' /$PostgreSql_username = ' \' $DB_USERNAME \' ' /g' /var/www/html/results/telemetry_settings.php
6165 sed -i ' s/$PostgreSql_password = ' \' ' .*' \' ' /$PostgreSql_password = ' \' $DB_PASSWORD \' ' /g' /var/www/html/results/telemetry_settings.php
@@ -77,14 +81,22 @@ if [[ "$TELEMETRY" == "true" && ( "$MODE" == "frontend" || "$MODE" == "standalon
7781 fi
7882
7983 mkdir -p /database/
80- chown www-data /database/
84+ if is_alpine; then
85+ chown apache /database/
86+ else
87+ chown www-data /database/
88+ fi
8189fi
8290
83- chown -R www-data /var/www/html/*
91+ if is_alpine; then
92+ chown -R apache /var/www/html/*
93+ else
94+ chown -R www-data /var/www/html/*
95+ fi
8496
8597# Allow selection of Apache port for network_mode: host
8698if [ " $WEBPORT " != " 80" ]; then
87- if [ -f /etc/alpine-release ] ; then
99+ if is_alpine ; then
88100 sed -i " s/^Listen 80\$ /Listen $WEBPORT /g" /etc/apache2/httpd.conf
89101 else
90102 sed -i " s/^Listen 80\$ /Listen $WEBPORT /g" /etc/apache2/ports.conf
95107echo " Done, Starting APACHE"
96108
97109# This runs apache
98- if [ -f /etc/alpine-release ] ; then
110+ if is_alpine ; then
99111 exec httpd -DFOREGROUND
100112else
101113 exec apache2-foreground
0 commit comments