Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web ui stream fixes #21

Merged
merged 3 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
22 changes: 9 additions & 13 deletions libretime-core/bootstrap/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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^.*</VirtualHost>.*^ # Quick fix for iframes that reference hard coded localhost in paths.\n # BEGIN:LOCALHOSTFIX--\n <Location "/">\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 </Location>\n&^' "$AIRTIME_APACHE_CONFIG"
sed -i 's^.*</VirtualHost>.*^ # Quick fix for iframes and assets that load the EXTERNAL_HOSTNAME without a port.\n # BEGIN:WEBPORTFIX--\n <Location "/">\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 </Location>\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^.*</Location>.*^ 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() {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libretime-core/bootstrap/firstrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down