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 a8f281ef2..f99c51ffb 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 @@ -36,21 +33,20 @@ 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 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 +} - 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() { + # 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() { @@ -66,13 +62,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 diff --git a/libretime-core/bootstrap/firstrun.sh b/libretime-core/bootstrap/firstrun.sh index 65e4cf37a..52cf9e88a 100644 --- a/libretime-core/bootstrap/firstrun.sh +++ b/libretime-core/bootstrap/firstrun.sh @@ -25,7 +25,7 @@ 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