diff --git a/README.md b/README.md index 865e758..e9de9a4 100644 --- a/README.md +++ b/README.md @@ -78,12 +78,13 @@ services: - PGID=1000 - TZ=Europe/London - PASSWORD=PASSWORD - - CUSTOM_RESULTS=true #optional + - CUSTOM_RESULTS=false #optional - DB_TYPE=sqlite #optional - DB_NAME=DB_NAME #optional - DB_HOSTNAME=DB_HOSTNAME #optional - DB_USERNAME=DB_USERNAME #optional - DB_PASSWORD=DB_PASSWORD #optional + - DB_PORT=DB_PORT #optional volumes: - /path/to/appdata/config:/config ports: @@ -100,12 +101,13 @@ docker run -d \ -e PGID=1000 \ -e TZ=Europe/London \ -e PASSWORD=PASSWORD \ - -e CUSTOM_RESULTS=true `#optional` \ + -e CUSTOM_RESULTS=false `#optional` \ -e DB_TYPE=sqlite `#optional` \ -e DB_NAME=DB_NAME `#optional` \ -e DB_HOSTNAME=DB_HOSTNAME `#optional` \ -e DB_USERNAME=DB_USERNAME `#optional` \ -e DB_PASSWORD=DB_PASSWORD `#optional` \ + -e DB_PORT=DB_PORT `#optional` \ -p 80:80 \ -v /path/to/appdata/config:/config \ --restart unless-stopped \ @@ -124,12 +126,13 @@ Container images are configured using parameters passed at runtime (such as thos | `-e PGID=1000` | for GroupID - see below for explanation | | `-e TZ=Europe/London` | Specify a timezone to use EG Europe/London | | `-e PASSWORD=PASSWORD` | Set the password for the results database. | -| `-e CUSTOM_RESULTS=true` | (optional) enables custom results page in `/config/www/results/index.php`. | +| `-e CUSTOM_RESULTS=false` | (optional) set to `true` to enable custom results page in `/config/www/results/index.php`. | | `-e DB_TYPE=sqlite` | Defaults to `sqlite`, can also be set to `mysql` or `postgresql`. | | `-e DB_NAME=DB_NAME` | Database name. Required for mysql and pgsql. | | `-e DB_HOSTNAME=DB_HOSTNAME` | Database address. Required for mysql and pgsql. | | `-e DB_USERNAME=DB_USERNAME` | Database username. Required for mysql and pgsql. | | `-e DB_PASSWORD=DB_PASSWORD` | Database password. Required for mysql and pgsql. | +| `-e DB_PORT=DB_PORT` | Database port. Required for mysql. | | `-v /config` | Contains all relevant configuration files. | ## Environment variables from files (Docker secrets) @@ -248,6 +251,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **01.03.21:** - Fix up database settings. Make sure `index.html` is recreated. * **28.02.21:** - Added php7-ctype. * **23.01.21:** - Rebasing to alpine 3.13. * **01.06.20:** - Rebasing to alpine 3.12. diff --git a/readme-vars.yml b/readme-vars.yml index 06e8742..910cbc9 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -37,12 +37,13 @@ param_env_vars: # optional container parameters opt_param_usage_include_env: true opt_param_env_vars: - - { env_var: "CUSTOM_RESULTS", env_value: "true", desc: "(optional) enables custom results page in `/config/www/results/index.php`."} + - { env_var: "CUSTOM_RESULTS", env_value: "false", desc: "(optional) set to `true` to enable custom results page in `/config/www/results/index.php`."} - { env_var: "DB_TYPE", env_value: "sqlite", desc: "Defaults to `sqlite`, can also be set to `mysql` or `postgresql`."} - { env_var: "DB_NAME", env_value: "DB_NAME", desc: "Database name. Required for mysql and pgsql."} - { env_var: "DB_HOSTNAME", env_value: "DB_HOSTNAME", desc: "Database address. Required for mysql and pgsql."} - { env_var: "DB_USERNAME", env_value: "DB_USERNAME", desc: "Database username. Required for mysql and pgsql."} - { env_var: "DB_PASSWORD", env_value: "DB_PASSWORD", desc: "Database password. Required for mysql and pgsql."} + - { env_var: "DB_PORT", env_value: "DB_PORT", desc: "Database port. Required for mysql."} optional_block_1: false optional_block_1_items: "" @@ -62,6 +63,7 @@ app_setup_block: | # changelog changelogs: + - { date: "01.03.21:", desc: "Fix up database settings. Make sure `index.html` is recreated." } - { date: "28.02.21:", desc: "Added php7-ctype." } - { date: "23.01.21:", desc: "Rebasing to alpine 3.13." } - { date: "01.06.20:", desc: "Rebasing to alpine 3.12." } diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index 20b3209..5191605 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -8,6 +8,8 @@ mkdir -p \ # create symlink to index.html [[ ! -L /usr/share/webapps/librespeed/index.html ]] && \ ln -s /config/www/index.html /usr/share/webapps/librespeed/index.html +[[ ! -f /config/www/index.html ]] && \ + cp /defaults/index.html /config/www/index.html # update templates cp /usr/share/webapps/librespeed/example*.html /config/www/ @@ -19,7 +21,7 @@ cp /usr/share/webapps/librespeed/example*.html /config/www/ cp /config/www/speedtest_worker.js /usr/share/webapps/librespeed/speedtest_worker.js # enables custom results page -if "$CUSTOM_RESULTS"; then +if [ "$CUSTOM_RESULTS" == "true" ]; then echo "custom results" [[ ! -e "/config/www/results/index.php" ]] && \ mkdir -p /config/www/results/ && \ @@ -29,28 +31,29 @@ fi # configure app settings sed -i "\ - s|\$Sqlite_db_file = \"../../speedtest_telemetry.sql\";|\$Sqlite_db_file = \"/config/speedtest_telemetry.sql\";|g; \ - s|\$enable_id_obfuscation=false;|\$enable_id_obfuscation=true;|g; - s|\$stats_password=\"PASSWORD\";|\$stats_password=\"${PASSWORD}\";|g" \ + s|\$Sqlite_db_file.*|\$Sqlite_db_file = \'/config/speedtest_telemetry.sql\';|g; \ + s|\$enable_id_obfuscation.*|\$enable_id_obfuscation = true;|g; + s|\$stats_password.*|\$stats_password = \'${PASSWORD}\';|g" \ /usr/share/webapps/librespeed/results/telemetry_settings.php if [ "$DB_TYPE" = "postgresql" ]; then sed -i "\ - s|\$db_type=\"mysql\";|\$db_type=\"${DB_TYPE}\";|g \ - s|\$PostgreSql_username=\"USERNAME\";|\$PostgreSql_username=\"${DB_USERNAME}\";|g; \ - s|\$PostgreSql_password=\"PASSWORD\";|\$PostgreSql_password=\"${DB_PASSWORD}\";|g; \ - s|\$PostgreSql_hostname=\"DB_HOSTNAME\";|\$PostgreSql_hostname=\"${DB_HOSTNAME}\";|g; \ - s|\$PostgreSql_databasename=\"DB_NAME\";|\$PostgreSql_databasename=\"${DB_NAME}\";|g" \ + s|\$db_type.*|\$db_type = \'${DB_TYPE}\';|g; \ + s|\$PostgreSql_username.*|\$PostgreSql_username = \'${DB_USERNAME}\';|g; \ + s|\$PostgreSql_password.*|\$PostgreSql_password = \'${DB_PASSWORD}\';|g; \ + s|\$PostgreSql_hostname.*|\$PostgreSql_hostname = \'${DB_HOSTNAME}\';|g; \ + s|\$PostgreSql_databasename.*|\$PostgreSql_databasename = \'${DB_NAME}\';|g" \ /usr/share/webapps/librespeed/results/telemetry_settings.php elif [ "$DB_TYPE" = "mysql" ]; then sed -i "\ - s|\$MySql_username=\"USERNAME\";|\$MySql_username=\"${DB_USERNAME}\";|g; \ - s|\$MySql_password=\"PASSWORD\";|\$MySql_password=\"${DB_PASSWORD}\";|g; \ - s|\$MySql_hostname=\"DB_HOSTNAME\";|\$MySql_hostname=\"${DB_HOSTNAME}\";|g; \ - s|\$MySql_databasename=\"DB_NAME\";|\$MySql_databasename=\"${DB_NAME}\";|g" \ + s|\$MySql_username.*|\$MySql_username = \'${DB_USERNAME}\';|g; \ + s|\$MySql_password.*|\$MySql_password = \'${DB_PASSWORD}\';|g; \ + s|\$MySql_hostname.*|\$MySql_hostname = \'${DB_HOSTNAME}\';|g; \ + s|\$MySql_databasename.*|\$MySql_databasename = \'${DB_NAME}\';|g; \ + s|\$MySql_port.*|\$MySql_port = \'${DB_PORT:-3306}\';|g" \ /usr/share/webapps/librespeed/results/telemetry_settings.php else sed -i \ - "s|\$db_type=\"mysql\";|\$db_type=\"sqlite\";|g" \ + "s|\$db_type.*|\$db_type = \'sqlite\';|g" \ /usr/share/webapps/librespeed/results/telemetry_settings.php fi