2019-10-11 18:15:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
rm -rf /var/www/html/*
|
|
|
|
|
|
|
|
# Copy frontend files
|
|
|
|
cp /speedtest/*.js /var/www/html/
|
|
|
|
|
2020-11-30 10:49:16 +00:00
|
|
|
# Copy favicon
|
|
|
|
cp /speedtest/favicon.ico /var/www/html/
|
|
|
|
|
2019-10-11 18:15:05 +00:00
|
|
|
# Set up backend side for standlone modes
|
|
|
|
if [ "$MODE" == "standalone" ]; then
|
|
|
|
cp -r /speedtest/backend/ /var/www/html/backend
|
|
|
|
if [ ! -z "$IPINFO_APIKEY" ]; then
|
|
|
|
sed -i s/\$IPINFO_APIKEY=\"\"/\$IPINFO_APIKEY=\"$IPINFO_APIKEY\"/g /var/www/html/backend/getIP_ipInfo_apikey.php
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$MODE" == "backend" ]; then
|
|
|
|
cp -r /speedtest/backend/* /var/www/html
|
|
|
|
if [ ! -z "$IPINFO_APIKEY" ]; then
|
|
|
|
sed -i s/\$IPINFO_APIKEY=\"\"/\$IPINFO_APIKEY=\"$IPINFO_APIKEY\"/g /var/www/html/getIP_ipInfo_apikey.php
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set up index.php for frontend-only or standalone modes
|
|
|
|
if [ "$MODE" == "frontend" ]; then
|
|
|
|
cp /speedtest/frontend.php /var/www/html/index.php
|
|
|
|
elif [ "$MODE" == "standalone" ]; then
|
|
|
|
cp /speedtest/standalone.php /var/www/html/index.php
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Apply Telemetry settings when running in standalone or frontend mode and telemetry is enabled
|
|
|
|
if [[ "$TELEMETRY" == "true" && ( "$MODE" == "frontend" || "$MODE" == "standalone" ) ]]; then
|
|
|
|
cp -r /speedtest/results /var/www/html/results
|
|
|
|
|
|
|
|
sed -i s/\$db_type=\".*\"/\$db_type=\"sqlite\"\;/g /var/www/html/results/telemetry_settings.php
|
|
|
|
sed -i s/\$Sqlite_db_file\ =\ \".*\"/\$Sqlite_db_file=\"\\\/database\\\/db.sql\"/g /var/www/html/results/telemetry_settings.php
|
|
|
|
sed -i s/\$stats_password=\".*\"/\$stats_password=\"$PASSWORD\"/g /var/www/html/results/telemetry_settings.php
|
|
|
|
|
|
|
|
if [ "$ENABLE_ID_OBFUSCATION" == "true" ]; then
|
2019-11-24 21:09:45 +00:00
|
|
|
sed -i s/\$enable_id_obfuscation=.*\;/\$enable_id_obfuscation=true\;/g /var/www/html/results/telemetry_settings.php
|
2019-10-11 18:15:05 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$REDACT_IP_ADDRESSES" == "true" ]; then
|
2019-11-24 21:09:45 +00:00
|
|
|
sed -i s/\$redact_ip_addresses=.*\;/\$redact_ip_addresses=true\;/g /var/www/html/results/telemetry_settings.php
|
2019-10-11 18:15:05 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p /database/
|
|
|
|
chown www-data /database/
|
|
|
|
fi
|
|
|
|
|
2020-07-13 10:02:11 +00:00
|
|
|
chown -R www-data /var/www/html/*
|
2019-10-11 18:15:05 +00:00
|
|
|
|
2020-04-01 16:57:32 +00:00
|
|
|
# Allow selection of Apache port for network_mode: host
|
|
|
|
if [ "$WEBPORT" != "80" ]; then
|
2020-07-12 11:47:17 +00:00
|
|
|
sed -i "s/^Listen 80\$/Listen $WEBPORT/g" /etc/apache2/ports.conf
|
|
|
|
sed -i "s/*:80>/*:$WEBPORT>/g" /etc/apache2/sites-available/000-default.conf
|
2020-04-01 16:57:32 +00:00
|
|
|
fi
|
|
|
|
|
2019-10-11 18:15:05 +00:00
|
|
|
echo "Done, Starting APACHE"
|
|
|
|
|
|
|
|
# This runs apache
|
|
|
|
apache2-foreground
|