diff --git a/.gitignore b/.gitignore index 44ad223..1f27354 100644 --- a/.gitignore +++ b/.gitignore @@ -167,3 +167,6 @@ logs/ # env vars variables.env + +# icecast conf +icecast.xml diff --git a/config/icecast/icecast.xml.template b/config/icecast/icecast.xml.template new file mode 100644 index 0000000..44c3c0e --- /dev/null +++ b/config/icecast/icecast.xml.template @@ -0,0 +1,87 @@ + + localhost + earth + admin@localhost + 1 + + + 15 + http://dir.xiph.org/cgi-bin/yp-cgi + + + + 100 + 2 + 102400 + 30 + 15 + 10 + 1 + 65536 + + + + hackme34 + relay + hackme23 + admin + hackme12 + + + + 8000 + + + + /stream.mp3 + 100 + 3600 + /usr/share/icecast2/web/data/fallback.mp3 + 1 + 1 + 1 + streamname + description + localhost + mixed + 192 + application/mp3 + 1 + 65536 + 4096 + +
+
+
+
+ + /home/icecast/bin/source-start + /home/icecast/bin/source-end + + + + + @pkgdatadir@ + + /var/log/icecast2 + /usr/share/icecast2/web + /usr/share/icecast2/admin + /usr/share/icecast2/web/data/report-db.xml + + + + + + access.log + error.log + 3 + + + + 0 + + radio + radio + + + diff --git a/docker-compose.yml b/docker-compose.yml index e4405c1..55f7917 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -83,3 +83,23 @@ services: - net labels: - meta.role=discordbot + + icecast: + #depends_on: + # - "radiorelay" + build: ./src/icecast + image: tv-icecast:latest + env_file: + - "variables.env" + restart: unless-stopped + ports: + - "8000:8000" + volumes: + - /etc/localtime:/etc/localtime:ro + - "./config/icecast/icecast.xml.template:/etc/icecast2/icecast.xml.template" + - "./data/icecast:/usr/share/icecast2/web/data" + - "./logs/icecast:/var/log/icecast2" + networks: + - net + labels: + - meta.role=icecast diff --git a/init.sh b/init.sh index 5fb96b6..fc52ef1 100755 --- a/init.sh +++ b/init.sh @@ -1,19 +1,30 @@ #!/bin/bash echo "creating data dir structure" -mkdir -v -p data/restreamer/config -mkdir -v -p data/restreamer/data - -mkdir -v -p data/recorder/vod -mkdir -v -p data/recorder/live -mkdir -v -p data/recorder/thumb +# certbot mkdir -v -p data/certbot/etc mkdir -v -p data/certbot/var mkdir -v -p logs/certbot mkdir -v -p data/certificates +# restreamer +mkdir -v -p data/restreamer/config +mkdir -v -p data/restreamer/data + +# scheduler +mkdir -v -p data/recorder/vod +mkdir -v -p data/recorder/live +mkdir -v -p data/recorder/thumb + +# icecast +mkdir -v -p logs/icecast +touch logs/icecast/access.log +touch logs/icecast/error.log +chown 1000:1000 logs/icecast/access.log +chown 1000:1000 logs/icecast/error.log + echo "generating self signed certificates for haproxy bootstrap" cd data/certificates openssl genrsa -out default.key 2048 diff --git a/src/icecast/Dockerfile b/src/icecast/Dockerfile new file mode 100644 index 0000000..abbcde7 --- /dev/null +++ b/src/icecast/Dockerfile @@ -0,0 +1,16 @@ +FROM debian:stable-slim + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get -qq -y update; \ + apt-get -qq -y full-upgrade; \ + apt-get -qq -y install icecast2 python3-setuptools; \ + apt-get -y autoclean; \ + apt-get clean; + +RUN useradd radio ;\ + chown -R radio:radio /var/log/icecast2 + +ADD ./start.sh /start.sh + +CMD ["/start.sh"] diff --git a/src/icecast/start.sh b/src/icecast/start.sh new file mode 100755 index 0000000..f35c9dc --- /dev/null +++ b/src/icecast/start.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +env + +set -x + +set_val() { + if [ -n "$2" ]; then + sed -i "s/<$2>[^<]*<\/$2>/<$2>$1<\/$2>/g" /etc/icecast2/icecast.xml + else + echo "Setting for '$1' is missing, skipping." >&2 + fi +} + +cp -v /etc/icecast2/icecast.xml.template /etc/icecast2/icecast.xml + +set_val $ICECAST_SOURCE_PASSWORD source-password +set_val $ICECAST_RELAY_PASSWORD relay-password +set_val $ICECAST_ADMIN_PASSWORD admin-password +set_val $CORE_API_HOSTNAME hostname +set_val $CORE_API_HOSTNAME stream-url + +set -e + +icecast2 -n -c /etc/icecast2/icecast.xml diff --git a/variables.env.dist b/variables.env.dist index ba91e89..548604f 100644 --- a/variables.env.dist +++ b/variables.env.dist @@ -9,3 +9,7 @@ SCHEDULER_API_HOSTNAME=tv.example.com DISCORDBOT_TOKEN=changeme DISCORDBOT_LIVE_CHANNEL_ID=0 DISCORDBOT_LIVE_CHANNEL_UPDATE=1440 +ICECAST_SOURCE_PASSWORD=changeme +ICECAST_ADMIN_PASSWORD=changeme +ICECAST_RELAY_PASSWORD=changeme +ICECAST_PASSWORD=changeme