forked from anakaiti/heroku-icecast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·126 lines (115 loc) · 5.52 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
printf 'Fixing Libraries for Heroku...\n\n'
cp /app/.apt/usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-13.99.so /app/.apt/usr/lib/x86_64-linux-gnu/libpulsecommon-13.99.so
cp -a ~/.apt/lib/x86_64-linux-gnu/. ~/.dpkg/usr/bin/
printf 'Preparing Configuration...\n\n'
# ---
export CFG_ADMIN_USER=${CFG_ADMIN_USER:-"admin"}
export CFG_ADMIN_PASSWORD=${CFG_ADMIN_PASSWORD:-"hackme"}
export CFG_ADMIN=${CFG_ADMIN:-"icemaster@localhost"}
export CFG_LOCATION=${CFG_LOCATION:-"Earth"}
export CFG_RELAY_PASSWORD=${CFG_RELAY_PASSWORD:-"hackme"}
export CFG_SOURCE_PASSWORD=${CFG_SOURCE_PASSWORD:-"hackme"}
export CFG_STREAM_URL=${CFG_STREAM_URL:-"0.0.0.0"}
export CFG_MUSIC_URL=${CFG_MUSIC_URL:-"none"}
export CFG_GENRE=${CFG_GENRE:-"Unknown"}
export CFG_STREAM_NAME=${CFG_STREAM_NAME:-"Heroku Icecast2 Live Radio"}
export CFG_STREAM_DESCRIPTION=${CFG_STREAM_DESCRIPTION:-"A Heroku-powered Icecast2 Live Radio Server"}
export CFG_HOSTNAME=${CFG_HOSTNAME:-"0.0.0.0"}
export CFG_ADVERTISE=${CFG_ADVERTISE:-"0"}
export CFG_CLIENT=${CFG_CLIENT:-"liquidsoap"}
printf 'Building Configuration Files...\n\n'
# ---
sed -i -e "s/\$PORT/$PORT/g" icecast.xml
sed -i -e "s/\$CFG_ADMIN_USER/$CFG_ADMIN_USER/g" icecast.xml
sed -i -e "s/\$CFG_ADMIN_PASSWORD/$CFG_ADMIN_PASSWORD/g" icecast.xml
sed -i -e "s/\$CFG_ADMIN/$CFG_ADMIN/g" icecast.xml
sed -i -e "s/\$CFG_LOCATION/$CFG_LOCATION/g" icecast.xml
sed -i -e "s/\$CFG_RELAY_PASSWORD/$CFG_RELAY_PASSWORD/g" icecast.xml
sed -i -e "s/\$CFG_SOURCE_PASSWORD/$CFG_SOURCE_PASSWORD/g" icecast.xml
sed -i -e "s/\$CFG_STREAM_URL/${CFG_STREAM_URL//\//\\/}/g" icecast.xml
sed -i -e "s/\$CFG_GENRE/$CFG_GENRE/g" icecast.xml
sed -i -e "s/\$CFG_STREAM_NAME/$CFG_STREAM_NAME/g" icecast.xml
sed -i -e "s/\$CFG_STREAM_DESCRIPTION/$CFG_STREAM_DESCRIPTION/g" icecast.xml
sed -i -e "s/\$CFG_HOSTNAME/${CFG_HOSTNAME//\//\\/}/g" icecast.xml
sed -i -e "s/\$CFG_ADVERTISE/$CFG_ADVERTISE/g" icecast.xml
sed -i -e "s/\$CFG_CLIENT/$CFG_CLIENT/g" icecast.xml
# ---
sed -i -e "s/\$PORT/$PORT/g" ices.xml
sed -i -e "s/\$CFG_ADMIN_USER/$CFG_ADMIN_USER/g" ices.xml
sed -i -e "s/\$CFG_ADMIN_PASSWORD/$CFG_ADMIN_PASSWORD/g" ices.xml
sed -i -e "s/\$CFG_ADMIN/$CFG_ADMIN/g" ices.xml
sed -i -e "s/\$CFG_LOCATION/$CFG_LOCATION/g" ices.xml
sed -i -e "s/\$CFG_RELAY_PASSWORD/$CFG_RELAY_PASSWORD/g" ices.xml
sed -i -e "s/\$CFG_SOURCE_PASSWORD/$CFG_SOURCE_PASSWORD/g" ices.xml
sed -i -e "s/\$CFG_STREAM_URL/${CFG_STREAM_URL//\//\\/}/g" ices.xml
sed -i -e "s/\$CFG_GENRE/$CFG_GENRE/g" ices.xml
sed -i -e "s/\$CFG_STREAM_NAME/$CFG_STREAM_NAME/g" ices.xml
sed -i -e "s/\$CFG_STREAM_DESCRIPTION/$CFG_STREAM_DESCRIPTION/g" ices.xml
sed -i -e "s/\$CFG_HOSTNAME/${CFG_HOSTNAME//\//\\/}/g" ices.xml
sed -i -e "s/\$CFG_ADVERTISE/$CFG_ADVERTISE/g" ices.xml
sed -i -e "s/\$CFG_CLIENT/$CFG_CLIENT/g" ices.xml
# ---
sed -i -e "s/\$PORT/$PORT/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_ADMIN_USER/$CFG_ADMIN_USER/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_ADMIN_PASSWORD/$CFG_ADMIN_PASSWORD/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_ADMIN/$CFG_ADMIN/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_LOCATION/$CFG_LOCATION/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_RELAY_PASSWORD/$CFG_RELAY_PASSWORD/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_SOURCE_PASSWORD/$CFG_SOURCE_PASSWORD/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_STREAM_URL/${CFG_STREAM_URL//\//\\/}/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_GENRE/$CFG_GENRE/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_STREAM_NAME/$CFG_STREAM_NAME/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_STREAM_DESCRIPTION/$CFG_STREAM_DESCRIPTION/g" ~/liquidsoap.liq
sed -i -e "s/\$CFG_HOSTNAME/${CFG_HOSTNAME//\//\\/}/g" ~/liquidsoap.liq
if [ "$CFG_ADVERTISE" == 1 ]
then
sed -i -e "s/\$CFG_ADVERTISE/true/g" ~/liquidsoap.liq
else
sed -i -e "s/\$CFG_ADVERTISE/false/g" ~/liquidsoap.liq
fi
sed -i -e "s/\$CFG_CLIENT/$CFG_CLIENT/g" ~/liquidsoap.liq
# ---
printf "Fixing Radio Files... (Copying '~/.apt/usr/share/icecast2/web/.' to '~/.apt/etc/icecast2/web/.')\n\n"
cp -na ~/.apt/usr/share/icecast2/web/. ~/.apt/etc/icecast2/web/.
printf 'Testing!\nThis should be readable from your radio''s website.' > ~/.apt/etc/icecast2/web/test.txt
printf 'Starting Icecast2... (Radio Server)\n\n'
~/.apt/usr/bin/icecast2 -c icecast.xml &
printf 'Waiting for Icecast2 to Startup... (Sleeping for 10 Seconds)\n\n'
sleep 10
if [ "$CFG_MUSIC_URL" == "none" ]
then
printf "\nNo Music Archive to Download. Assuming you either have your Music Archive pre-uploaded, or your music folder pre-populated with songs? (No link specified in \$CFG_MUSIC_URL)\n"
else
printf "\nDownloading Music Archive '$CFG_MUSIC_URL'... (Link specified in \$CFG_MUSIC_URL)\n"
curl -o music.tar.gz -L $CFG_MUSIC_URL
fi
if [ -e music.tar.gz ]
then
printf "\nExtracting Music Archive to Music Folder...\n"
tar -xzvf music.tar.gz -C ~/music/ --strip-components 1
printf "\nCleanup: Deleting Now-Extracted Music Archive...\n"
rm music.tar.gz
else
printf "\nMusic Archive Doesn't Exist! Assuming you have your music folder pre-populated with songs?\n"
fi
printf 'Music Prepared!\n\n'
printf 'Building Playlist File...\n\n'
printf '%s\n' ~/music/*.ogg >> ~/playlist.txt
printf '%s\n' ~/music/*.mp3 >> ~/playlist.txt
if [ "$CFG_CLIENT" == "liquidsoap" ]
then
printf '\nStarting Liquidsoap... (Audio Streamer)\n\n'
cd ~/.dpkg/usr/bin/
liquidsoap --version
liquidsoap -v ~/liquidsoap.liq
fi
if [ "$CFG_CLIENT" == "ices2" ]
then
printf '\nStarting Ices2... (Audio Streamer)\n\n'
~/.apt/usr/bin/ices2 ices.xml
fi
printf "(Now Sleeping Forever!)\n\nYour Radio Server Webpage should now be Live!\n\nOn your App's Dashboard, Click 'Open app' in the top right to Open your Radio's Webpage!\n\n"
while true
do
sleep 10
done