-
Notifications
You must be signed in to change notification settings - Fork 16
/
install.sh
executable file
·143 lines (122 loc) · 4.6 KB
/
install.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
# Exit immediately upon error
set -eo pipefail
if [ $# -gt 0 ]
then
echo "$(basename $0): No parameters allowed, $# given."
exit 1
fi
cat <<END
"***************************************************************"
NOTE: If you need help determining configuration values to use,
installation documentation is available on GitHub:
https://github.com/kenellorando/cadence/wiki/Installation
***************************************************************
[1/5] Path to Music Directory
Set a path to a directory containing audio files (e.g. mp3, flac) to be played
on the radio. The target will be recursively searched.
END
read -ep " Music path: " CADENCE_PATH
while [ ! -d "$CADENCE_PATH" ]
do
echo "Music path must point to a directory that exists and is readable."
read -ep " Music path: " CADENCE_PATH
done
# We do need to use absolute paths here - Make sure they end up that way.
# realpath -s is used here instead of readlink -f to retain symlinks - Else,
# we'd automatically go to the destination and use that, even if the user
# changed the symlink and restarted Cadence!
# ... Despite this, symlinks inside CADENCE_PATH probably won't work, since
# they don't get mounted inside our containers. Not a lot we can do about that.
CADENCE_PATH=$(realpath -s "$CADENCE_PATH")
echo
cat <<END
[2/5] Stream Host Address
Set the stream host address. This may be a DNS name, public IP, or private IP.
Use localhost:8000 if your Cadence instance is meant for local use only.
Default: localhost:8000
END
read -p " Stream address: " CADENCE_STREAM_HOST
if [ -z "$CADENCE_STREAM_HOST" ]
then
echo "Streaming to localhost:8000."
CADENCE_STREAM_HOST='localhost:8000'
fi
echo
cat <<END
[3/5] Rate Limiter Timeout
Set a rate limit timeout in integer seconds. This prevents the same listener
from requesting songs within the configured timeframe. Set to 0 to disable.
END
read -p " Rate limit (0): " CADENCE_RATE
while ! [[ "$CADENCE_RATE" =~ ^[0-9]*$ ]]
do
echo "Rate limit must be an integer!"
read -p " Rate limit (0): " CADENCE_RATE
done
[ -z "$CADENCE_RATE" ] && CADENCE_RATE=0
echo
cat <<END
[4/5] Radio Service Password
Set a secure, unique service password. Input is hidden.
END
read -s -p " Password: " CADENCE_PASS
while [ -z "$CADENCE_PASS" ]
do
echo
echo "Password cannot be empty!"
read -s -p " Password: " CADENCE_PASS
done
echo
echo
cat <<END
[5/5] Enable Reverse Proxy?
Do you want to enable a reverse proxy? Skip if you are broadcasting locally only
or have your own reverse proxy configured. Skip if you do not know what this means.
END
ENABLE_REVERSE_PROXY="UNSET"
while ! [[ "$ENABLE_REVERSE_PROXY" =~ ^[yYnN]$ ]] && [ -n "$ENABLE_REVERSE_PROXY" ]
do
read -n1 -p " [y/N]: " ENABLE_REVERSE_PROXY
echo
done
if [[ "$ENABLE_REVERSE_PROXY" =~ ^([yY])$ ]]
then
echo "Please provide the domain name you will use for Cadence UI."
read -p " Web UI Domain: " CADENCE_WEB_HOST
while [ -z "$CADENCE_WEB_HOST" ]
do
echo "Web UI Domain cannot be empty!"
read -p " Web UI Domain: " CADENCE_WEB_HOST
done
else
echo "No reverse proxy will be configured."
fi
SCRIPT_DIR="$(dirname $(readlink -f $0))"
cd $SCRIPT_DIR
cp ./config/cadence.env.example ./config/cadence.env
cp ./config/icecast.xml.example ./config/icecast.xml
cp ./config/liquidsoap.liq.example ./config/liquidsoap.liq
cp ./config/nginx.conf.example ./config/nginx.conf
if [[ "$ENABLE_REVERSE_PROXY" =~ ^([yY])$ ]]
then
awk -v "c=$(cat ./nginx-compose-section.yml)" \
'{gsub(/NGINX_CONFIG_SECTION/,c)}1' ./docker-compose.yml.example > ./docker-compose.yml
else
sed -e 's|NGINX_CONFIG_SECTION||g' ./docker-compose.yml.example > ./docker-compose.yml
fi
sed -i 's|CADENCE_PASS_EXAMPLE|'"$CADENCE_PASS"'|g' ./config/cadence.env
sed -i 's|CADENCE_PASS_EXAMPLE|'"$CADENCE_PASS"'|g' ./config/icecast.xml
sed -i 's|CADENCE_PASS_EXAMPLE|'"$CADENCE_PASS"'|g' ./config/liquidsoap.liq
sed -i 's|CADENCE_RATE_EXAMPLE|'"$CADENCE_RATE"'|g' ./config/cadence.env
sed -i 's|CADENCE_STREAM_HOST_EXAMPLE|'"$CADENCE_STREAM_HOST"'|g' ./config/icecast.xml
sed -i 's|CADENCE_PATH_EXAMPLE|'"$CADENCE_PATH"'|g' ./config/cadence.env
sed -i 's|CADENCE_PATH_EXAMPLE|'"$CADENCE_PATH"'|g' ./config/liquidsoap.liq
sed -i 's|CADENCE_STREAM_HOST_EXAMPLE|'"$CADENCE_STREAM_HOST"'|g' ./config/nginx.conf
sed -i 's|CADENCE_WEB_HOST_EXAMPLE|'"$CADENCE_WEB_HOST"'|g' ./config/nginx.conf
sed -i 's|CADENCE_PATH_EXAMPLE|'"$CADENCE_PATH"'|g' ./docker-compose.yml
echo ""
echo "Configuration completed."
docker compose down
docker compose pull
docker compose up