From c0ebbfb925f7bb26229019688386e0656d0ae2a2 Mon Sep 17 00:00:00 2001 From: Jerry Aldrich Date: Mon, 20 Jan 2020 19:38:17 -0800 Subject: [PATCH] Initial commit --- Dockerfile | 33 ++++++ config.json | 43 ++++++++ entrypoint.sh | 70 +++++++++++++ icecast.xml | 65 ++++++++++++ player.html | 282 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 493 insertions(+) create mode 100644 Dockerfile create mode 100644 config.json create mode 100644 entrypoint.sh create mode 100644 icecast.xml create mode 100644 player.html diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0a4de43 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM alpine:latest + +LABEL maintainer "jerryaldrichiii@gmail.com" + +RUN apk add --update \ + icecast \ + mailcap \ + jq \ + && rm -rf /var/cache/apk/* + +RUN mkdir -p /etc/icecast + +RUN mv /etc/icecast.xml /etc/icecast/icecast-original.xml +COPY ./icecast.xml /etc/icecast/icecast.xml + +RUN chown -R icecast:icecast /etc/icecast +RUN chown -R icecast:icecast /var/log/icecast +RUN chown -R icecast:icecast /usr/share/icecast + +EXPOSE 8000 + +RUN mkdir /bootstrap +COPY ./config.json /bootstrap +RUN chown -R icecast:icecast /bootstrap + +COPY ./entrypoint.sh /etc/icecast/entrypoint.sh +RUN chmod +x /etc/icecast/entrypoint.sh + +COPY player.html /usr/share/icecast/web/player.html + +USER icecast:icecast + +ENTRYPOINT ["/etc/icecast/entrypoint.sh"] diff --git a/config.json b/config.json new file mode 100644 index 0000000..d632b40 --- /dev/null +++ b/config.json @@ -0,0 +1,43 @@ +{ + "title": "radio.jerryaldrichiii.com", + "hostname": "localhost", + "port": "8000", + "https_streams": false, + "streams": [ + { + "name": "DEF CON Radio", + "server":"ice2.somafm.com", + "port": 80, + "mount": "/defcon-256-mp3", + "local_mount":"/defcon" + }, + { + "name": "SF 10-33", + "server":"ice2.somafm.com", + "port": 80, + "mount": "/sf1033-128-mp3", + "local_mount":"/sf1033" + }, + { + "name": "Mission Control", + "server":"ice2.somafm.com", + "port": 80, + "mount": "/missioncontrol-128-mp3", + "local_mount":"/missioncontrol" + }, + { + "name": "Cyberia", + "server":"lainon.life", + "port": 8000, + "mount": "/cyberia.mp3", + "local_mount": "/cyberia" + }, + { + "name": "Synthwave Radio", + "server":"stream.syntheticfm.com", + "port": 8040, + "mount": "/live", + "local_mount": "/synthwave" + } + ] +} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..10c7d96 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +set -e + +set_val() { + # Combine args in case there are spaces + # https://linux.die.net/man/1/ash + val="${@#$1 }" # Remove smallest prefix pattern (space after $1 intentional) + sed -i "s/<$1>[^<]*<\/$1>/<$1>$val<\/$1>/g" /etc/icecast/icecast.xml +} + +# The below will replace values in the config with the ENV variable specified. +# If one is not specified, what follows ':-' will be used. +# NOTE: The order below matches the order seen in the config. +set_val location ${ICECAST_LOCATION:-San Francisco} +set_val admin ${ICECAST_ADMIN:-Someone Failed to Change Me} + +set_val clients ${ICECAST_LIMITS_CLIENTS:-100} +set_val sources ${ICECAST_LIMITS_SOURCES:-2} +set_val queue-size ${ICECAST_LIMITS_QUEUE_SIZE:-524288} +set_val client-timeout ${ICECAST_LIMITS_CLIENT_TIMEOUT:-30} +set_val header-timeout ${ICECAST_LIMITS_HEADER_TIMEOUT:-14} +set_val source-timeout ${ICECAST_LIMITS_SOURCE_TIMEOUT:-10} +set_val burst-on-connect ${ICECAST_LIMITS_BURST_ON_CONNECT:-1} +set_val burst-size ${ICECAST_LIMITS_BURST_SIZE:-65535} + +set_val fileserve ${ICECAST_FILESERVE:-1} + +set_val source-password ${AUTHENTICATION_SOURCE_PASSWORD:-changeorbehacked} +set_val relay-password ${AUTHENTICATION_RELAY_PASSWORD:-changeorbehacked} +set_val admin-user ${AUTHENTICATION_ADMIN_USER:-changeorbehacked} +set_val admin-password ${AUTHENTICATION_ADMIN_PASSWORD:-changeorbehacked} + +set_val relays-on-demand ${RELAYS_ON_DEMAND:-1} + +set_val loglevel ${LOG_LEVEL:-3} +set_val logsize ${LOG_SIZE:-10000} +set_val logarchive ${LOG_ARCHIVE:-0} + +# Build relay XML sections +CONFIG="$(cat /bootstrap/config.json)" +for stream in $(echo "$CONFIG" | jq -r '.streams[] | @base64'); do + _parse() { + echo ${stream} | base64 -d | jq -r ${1} + } + RELAY_XML=$(cat <<-EOX + $RELAY_XML + + + $(_parse .server) + $(_parse .port) + $(_parse .mount) + $(_parse .local_mount) + 1 + +EOX +) +done + +# Set hostname (needs to match for listen urls and such) +host=$(echo "$CONFIG" | jq -r '.hostname') +set_val hostname ${ICECAST_HOSTNAME:-$host} + +# Using | as the delimiter because of URLs containing / +sed -i "s|ICECAST_RELAYS|$(echo "$RELAY_XML" | tr "\n" "#")|g;s/#/\n/g" /etc/icecast/icecast.xml + +# Publish config.json for consumers (e.g. web player) +cp /bootstrap/config.json /usr/share/icecast/web/ + +icecast -c "/etc/icecast/icecast.xml" diff --git a/icecast.xml b/icecast.xml new file mode 100644 index 0000000..ae9eabd --- /dev/null +++ b/icecast.xml @@ -0,0 +1,65 @@ + + SEE_ENTRYPOINT + SEE_ENTRYPOINT + SEE_ENTRYPOINT + + + /etc/mime.types + + + SEE_ENTRYPOINT + SEE_ENTRYPOINT + SEE_ENTRYPOINT + SEE_ENTRYPOINT + SEE_ENTRYPOINT + SEE_ENTRYPOINT + SEE_ENTRYPOINT + SEE_ENTRYPOINT + + + + SEE_ENTRYPOINT + SEE_ENTRYPOINT + SEE_ENTRYPOINT + SEE_ENTRYPOINT + + + + 8000 + + + +
+ + + SEE_ENTRYPOINT + + SEE_ENTRYPOINT + + + /var/log/icecast + /usr/share/icecast/web + /usr/share/icecast/admin + + + + + + - + - + SEE_ENTRYPOINT + SEE_ENTRYPOINT + SEE_ENTRYPOINT + + + + 0 + + + + ICECAST_RELAYS + diff --git a/player.html b/player.html new file mode 100644 index 0000000..9dc3be2 --- /dev/null +++ b/player.html @@ -0,0 +1,282 @@ + + + + + radio.jerryaldrichiii.com + + + + + + + +
+

+      
+ + +
+ + +
+ +
+
+ + + +