From 8f8bb57fd1ccaf8f70143fbadb3da979bcfd82c7 Mon Sep 17 00:00:00 2001 From: Corwin Brust Date: Sat, 19 Jul 2025 18:59:40 -0500 Subject: [PATCH] add Makefile to guide configuration and perform installation This change replaces icecast.xml with icecast.xml.template. A complete icecast.xml is no-longer provided. Instead, to create icecast.xml run: make You can generate icecast.xml and then install it: make install This doesn't currently do any aspectss of making the system ready to run icecast (e.g. performing `sudo apt install icecast2`, or similar). --- Makefile | 83 ++++++++++ README.md | 9 +- icecast.xml => icecast.xml.template | 248 +++++++++++++++++----------- 3 files changed, 245 insertions(+), 95 deletions(-) create mode 100644 Makefile rename icecast.xml => icecast.xml.template (53%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ade15ed --- /dev/null +++ b/Makefile @@ -0,0 +1,83 @@ +# Makefile for shred.ing + +# make (default, or with: make config) +# prompt for settings unless .env file exists +# create ~/icecast.xml +# make install +# backup the live config to ~/icecast.xml +# install ~/icecast.xml to /etc/icecast2 + +# not currently used for anything +## make sure to change these +#source_pass := password_to_share_with_casters +#relay_pass := password_for_icecast2_relays +#admin_user := admin_web_and_api_username +#admin_pass := password_for_admin_access +## probably want to change this +#hostname := shred.ing + +# the "prompt" port can be left blank so +# this can be left at default +icecast2_port := 8000 + +## +## More or less internal stuffs +## +default_config_template := icecast.xml.template +ICECAST_CONFIG_TEMPLATE := $(ICECAST_CONFIG_TEMPLATE) +#ICECAST_CONFIG_TEMPLATE != [ -z "$(ICECAST_CONFIG_TEMPLATE)" ] || echo "$(default_config_template)" + +#ICECAST_CONFIG_TEMPLATE := icecast.xml.template.foo + +## generate configuration files for icecast2 + +# these targets aren't associated with files +.PHONEY: config backup-live-config install + +## main "entry point" makefile targets +config: icecast.xml .env + +backup-live-config: + sudo test -r /etc/icecast2/icecast.xml && sudo cp /etc/icecast2/icecast.xml icecast.xml~~ + +install: config backup-live-config + sudo cp icecast.xml /etc/icecast2/icecast.xml.new + +# this will prompt to build a .env file when none exists +.env: + @echo "You will receive a series of prompts to create a .env file." + @echo + @printf "Enter your icecast hostname (or IP): " + @printf "hostname=%s\n" `read i; echo $$i` >.env + @printf "Enter the port for your icecast server ($(icecast2_port)): " + @printf "icecast2_port=%s\n" "$$( i=`read i; echo $$i`; printf "%s" $$( if test -z "$$i" ; then echo "$(icecast2_port)"; else echo "$$i" ; fi ) )" >>.env + @echo "Icecast requires, potentially, several passwords." + @echo "Passwords entered now are echoed to the screen." + @echo "You can pick bogus values and then edit the .env file." + @printf "Enter a source password: " + @printf "source_pass=%s\n" `read i; echo $$i` >>.env + @printf "Enter a relay password: " + @printf "relay_pass=%s\n" `read i; echo $$i` >>.env + @printf "Enter an admin password: " + @printf "admin_pass=%s\n" `read i; echo $$i` >>.env + @echo "Finally, select a username for the admin account:" + @printf "Enter the icecast admin username: " + @printf "admin_user=%s\n" `read i; echo $$i` >>.env + +# this ensures the template icecast config exists +$(ICECAST_CONFIG_TEMPLATE): + @printf "The icecast2 configuration file template "'"'"%s"'"'"\n" "$(ICECAST_CONFIG_TEMPLATE)" + @printf "is missing or cannot be read.\n" + @echo "This can be caused by an incomplete or corrupted checkout or" + @echo "an invalid value for the ICECAST_CONFIG_TEMPLATE env variable." + false + + +### given we have a template and a .env, create the icecast config +icecast.xml: $(ICECAST_CONFIG_TEMPLATE) .env + perl -e 'BEGIN{open my$$FH,q(<),q(.env) or die $$!; for(<$$FH>){ chomp; my($$k,$$v) = split q(=); next unless $$k; $$k =~ s/^\s+|\s+$$//g; next unless $$k; $$v =~ s/^\s+|\s+//g; $$h{lc $$k} = $$v; }}' -pe 's/\@\@([^@]+)\@\@/$$h{lc $$1}/eig;' >icecast.xml <$(ICECAST_CONFIG_TEMPLATE) + +# this seems to work, too! +# cat icecast.xml.template | perl -pe 's/\@\@source_pass\@\@/$(source_pass)/ig; s/\@\@relay_pass\@\@/$(relay_pass)/ig; s/\@\@admin_user\@\@/$(admin_user)/ig; s/\@\@admin_pass\@\@/$(admin_pass)/ig; s/\@\@hostname\@\@/$(hostname)/ig; s/\@\@icecast2_port\@\@/$(icecast2_port)/ig;' > icecast.xml +# probably, so does this? +# cat icecast.xml.template | perl -e 'BEGIN{open my$FH,q(<),q(.env) or die $!; for(<$FH>){ chomp; my($k,$v) = split q(=); next unless $k; $k =~ s/^\s+|\s+$//g; next unless $k; $v =~ s/^\s+|\s+//g; $h{lc $k} = $v; }}' -pe 's/\@\@([^@]+)\@\@/$h{lc $1}/eig;' -e 'END { use Data::Dumper; warn Dumper( \%h ) } ' > foo.xml diff --git a/README.md b/README.md index 27cf7ad..a098826 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,15 @@ Stuff to install on a (nominally) Ubuntu 24 host to create (e.g.) shred.ing to c - [X] fix issue where streams HTML player disconnects after an hour - [X] create fallback streams to support switching casters - - [ ] write a tutoral explaining how to use the files in this repo to create a streaming radio station + - [-] build guided installer + - [ ] write a tutoral +# Quick Start + + git clone https://code.bru.st/corwin/shred.ing-server.git + apt-get install icecast2 + make install + links localhost:8000 # ABSTRACT diff --git a/icecast.xml b/icecast.xml.template similarity index 53% rename from icecast.xml rename to icecast.xml.template index a7be6b2..a2d0939 100644 --- a/icecast.xml +++ b/icecast.xml.template @@ -1,55 +1,36 @@ - - Earth - icemaster@localhost - - - + The Island of Misfit Toys + yo@mammy - 100 - 2 + 17q000 + 17 524288 30 15 17 - - 1 + - 65535 + - $shredsourcepassword$ + @@Source_Pass@@ - $shredrelaypassword$ - + @@Relay_Pass@@ - admin - $shredadminpassword$ + @@Admin_User@@ + @@Admin_Pass@@ - - - - - shred.ing - - + @@hostname@@ - 8000 - - + @@icecast2_port@@ - - - -
+
@@ -103,12 +57,10 @@ - - - - - 0 - 3600 + live - $shredlivepassword$ - - - -
- + @@Source_Pass@@ + 1 + /live - - - - - + + 0 + /live.ogg + live + @@Source_Pass@@ + 1 + /gold.ogg + + + 0 + /gold.ogg + 1 + /purple.ogg + live + @@Source_Pass@@ + + + 0 + /purple.ogg + 1 + /black.ogg + live + @@Source_Pass@@ + + + 0 + /black.ogg + 1 + /silver.ogg + live + @@Source_Pass@@ + + + 0 + + + /silver.ogg + 1 + /live.ogg + live + @@Source_Pass@@ + - - - - - + + 0 + 1 + /live + live + @@Source_Pass@@ + 1 + /live.mp3 + + + 0 + /live.mp3 + live + @@Source_Pass@@ + 1 + /gold + + + + 0 + /gold + 1 + /gold.mp3 + live + @@Source_Pass@@ + + + 0 + /gold.mp3 + 1 + /gold.ogg + live + @@Source_Pass@@ + + + + 0 + /purple + 1 + /purple.mp3 + live + @@Source_Pass@@ + + + 0 + /purple.mp3 + 1 + /black + live + @@Source_Pass@@ + + + + 0 + + + /black + 1 + /black.mp3 + live + @@Source_Pass@@ + + + 0 + /black.mp3 + 1 + /silver + live + @@Source_Pass@@ + + + + 0 + + + /silver + 1 + /silver.mp3 + live + @@Source_Pass@@ + + + 0 + /silver.mp3 + 1 + /live + live + @@Source_Pass@@ + - /usr/share/icecast2 - - /var/log/icecast2 /usr/share/icecast2/web /usr/share/icecast2/admin - + playlist.log 3 10000