From 36318b8eb25a5004a3df6e6a4e5e26eb4672cebf Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 8 Dec 2018 15:27:30 -0600 Subject: [PATCH 1/3] resolve EXTERNAL_HOSTNAME to 127.0.0.1 in libretime-core --- libretime-core/bootstrap/entrypoint.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libretime-core/bootstrap/entrypoint.sh b/libretime-core/bootstrap/entrypoint.sh index a8f281ef2..0894eacba 100644 --- a/libretime-core/bootstrap/entrypoint.sh +++ b/libretime-core/bootstrap/entrypoint.sh @@ -5,9 +5,6 @@ AIRTIME_APACHE_CONFIG="/etc/apache2/sites-enabled/airtime.conf" # Script that is executed to apply further customizations to airtime. CUSTOMISATIONS_SCRIPT="/etc/airtime-customisations/run.sh" -# Airtime seems to expect the hostname of 'airtime' to be set to properly function... -echo "127.0.0.1 airtime libretime" >> /etc/hosts - function setConfigFromEnvironments { # RabbitMQ @@ -53,6 +50,12 @@ function apacheFixes() { } +function fqdnFixes() { + # Airtime seems to expect the hostname of 'airtime' to be set to properly function... + # EXTERNAL_HOSTNAME necessary in order to connect to icecast when setting custom output streams + echo "127.0.0.1 airtime libretime $EXTERNAL_HOSTNAME" >> /etc/hosts +} + function customisations() { if [ -f "$CUSTOMISATIONS_SCRIPT" ]; then bash "$CUSTOMISATIONS_SCRIPT" @@ -66,13 +69,13 @@ if [ ! -f "$AIRTIME_CONFIG_FILE" ]; then /opt/libretime/firstrun.sh # update config based on environment variables... - setConfigFromEnvironments && apacheFixes && customisations + setConfigFromEnvironments && apacheFixes && customisations && fqdnFixes # Start everything up :) /usr/bin/supervisord else # Check (and update if required) any config based on environment variables.. - setConfigFromEnvironments && apacheFixes && customisations + setConfigFromEnvironments && apacheFixes && customisations && fqdnFixes # We're already installed - just run supervisor.. /usr/bin/supervisord From fe9faa814fdcde6a32e6f96e208dd9cf985ea700 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 10 Dec 2018 07:22:51 -0600 Subject: [PATCH 2/3] set EXTERNAL_HOSTNAME in install process, update apache config hack --- docker-compose.yml | 5 +++-- libretime-core/bootstrap/entrypoint.sh | 11 ++--------- libretime-core/bootstrap/firstrun.sh | 4 ++-- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8c4735bc3..06ed16369 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -72,8 +72,9 @@ services: # ######################################################################################## - # There's some apache fixes that are applied here so that you can expose the site on the internet - Specify the public FQDN name of your server here. - - "EXTERNAL_HOSTNAME=${EXTERNAL_HOSTNAME-localhost}" + # There's some apache fixes that are applied here so that you can expose the site on the internet - Specify the public FQDN name of your server using the EXTERNAL_HOSTNAME variable in your .env file. + - EXTERNAL_HOSTNAME=${EXTERNAL_HOSTNAME-localhost} + - WEB_UI_PORT=${WEB_UI_PORT-8882} # Don't change these unless you change their values in the `libretime-rabbitmq` block. - RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER-libretime} diff --git a/libretime-core/bootstrap/entrypoint.sh b/libretime-core/bootstrap/entrypoint.sh index 0894eacba..c223de42c 100644 --- a/libretime-core/bootstrap/entrypoint.sh +++ b/libretime-core/bootstrap/entrypoint.sh @@ -33,21 +33,14 @@ function setConfigFromEnvironments { function apacheFixes() { - if ! grep -q 'BEGIN:LOCALHOSTFIX--' "$AIRTIME_APACHE_CONFIG" + if ! grep -q 'BEGIN:WEBPORTFIX--' "$AIRTIME_APACHE_CONFIG" then # Add in a "Substitute" filter to apache to strip out localhost references on the fly... - sed -i 's^.*.*^ # Quick fix for iframes that reference hard coded localhost in paths.\n # BEGIN:LOCALHOSTFIX--\n \n SetOutputFilter SUBSTITUTE;DEFLATE\n AddOutputFilterByType SUBSTITUTE text/html\n Substitute "s|http://localhost//|/|ni"\n Substitute "s|https://localhost//|/|ni"\n Substitute "s|http://localhost/|/|ni"\n Substitute "s|https://localhost/|/|ni"\n \n&^' "$AIRTIME_APACHE_CONFIG" + sed -i 's^.*.*^ # Quick fix for iframes that reference hard coded localhost in paths.\n # BEGIN:WEBPORTFIX--\n \n SetOutputFilter SUBSTITUTE;DEFLATE\n AddOutputFilterByType SUBSTITUTE text/html\n Substitute "s|'$EXTERNAL_HOSTNAME'/embed|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/embed|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/js|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/js|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'//css|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'//css|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/css|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/css|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/widgets|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/widgets|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/api|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/api|ni"\n \n&^' "$AIRTIME_APACHE_CONFIG" a2enmod substitute fi - - if ! grep -q "$EXTERNAL_HOSTNAME" "$AIRTIME_APACHE_CONFIG" - then - # Fix localhost on "Radio Embed Page" - sed -i 's^.*.*^ Substitute "s|http:\\/\\/localhost:8000|http:\\/\\/'"$EXTERNAL_HOSTNAME"'|ni"\n&^' "$AIRTIME_APACHE_CONFIG" - fi - } function fqdnFixes() { diff --git a/libretime-core/bootstrap/firstrun.sh b/libretime-core/bootstrap/firstrun.sh index 65e4cf37a..66b38305c 100644 --- a/libretime-core/bootstrap/firstrun.sh +++ b/libretime-core/bootstrap/firstrun.sh @@ -25,11 +25,11 @@ curl -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ # Web Interface curl -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ -H 'Accept: application/json, text/javascript, */*; q=0.01' \ - --data "generalHost=localhost&generalPort=80&generalErr=" \ + --data "generalHost=$EXTERNAL_HOSTNAME&generalPort=80&generalErr=" \ "http://${IP}/setup/setup-functions.php?obj=GeneralSetup" # Media Settings curl -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ -H 'Accept: application/json, text/javascript, */*; q=0.01' \ --data 'mediaFolder=%2Fexternal-media%2F&mediaErr=' \ - "http://${IP}/setup/setup-functions.php?obj=MediaSetup" + "http://${IP}/setup/setup-functions.php?obj=MediaSetup" From 4775e8da4e4d6f3f4ea5e7e0a0cdb017777331da Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 10 Dec 2018 09:07:39 -0600 Subject: [PATCH 3/3] fqdn fixes cleanup --- libretime-core/bootstrap/entrypoint.sh | 2 +- libretime-core/bootstrap/firstrun.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libretime-core/bootstrap/entrypoint.sh b/libretime-core/bootstrap/entrypoint.sh index c223de42c..f99c51ffb 100644 --- a/libretime-core/bootstrap/entrypoint.sh +++ b/libretime-core/bootstrap/entrypoint.sh @@ -37,7 +37,7 @@ function apacheFixes() { then # Add in a "Substitute" filter to apache to strip out localhost references on the fly... - sed -i 's^.*.*^ # Quick fix for iframes that reference hard coded localhost in paths.\n # BEGIN:WEBPORTFIX--\n \n SetOutputFilter SUBSTITUTE;DEFLATE\n AddOutputFilterByType SUBSTITUTE text/html\n Substitute "s|'$EXTERNAL_HOSTNAME'/embed|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/embed|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/js|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/js|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'//css|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'//css|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/css|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/css|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/widgets|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/widgets|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/api|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/api|ni"\n \n&^' "$AIRTIME_APACHE_CONFIG" + sed -i 's^.*.*^ # Quick fix for iframes and assets that load the EXTERNAL_HOSTNAME without a port.\n # BEGIN:WEBPORTFIX--\n \n SetOutputFilter SUBSTITUTE;DEFLATE\n AddOutputFilterByType SUBSTITUTE text/html\n Substitute "s|'$EXTERNAL_HOSTNAME'/embed|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/embed|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/js|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/js|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'//css|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'//css|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/css|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/css|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/widgets|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/widgets|ni"\n Substitute "s|'$EXTERNAL_HOSTNAME'/api|'$EXTERNAL_HOSTNAME':'$WEB_UI_PORT'/api|ni"\n \n&^' "$AIRTIME_APACHE_CONFIG" a2enmod substitute fi diff --git a/libretime-core/bootstrap/firstrun.sh b/libretime-core/bootstrap/firstrun.sh index 66b38305c..52cf9e88a 100644 --- a/libretime-core/bootstrap/firstrun.sh +++ b/libretime-core/bootstrap/firstrun.sh @@ -32,4 +32,4 @@ curl -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ curl -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ -H 'Accept: application/json, text/javascript, */*; q=0.01' \ --data 'mediaFolder=%2Fexternal-media%2F&mediaErr=' \ - "http://${IP}/setup/setup-functions.php?obj=MediaSetup" + "http://${IP}/setup/setup-functions.php?obj=MediaSetup"