-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·186 lines (153 loc) · 6.11 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env bash
# Load the functions library
FUNCTIONS_LIB_PATH="/tmp/functions.sh"
FUNCTIONS_LIB_URL="https://raw.githubusercontent.com/oszuidwest/bash-functions/main/common-functions.sh"
# Download the latest version of the functions library
rm -f "${FUNCTIONS_LIB_PATH}"
if ! curl -sLo "${FUNCTIONS_LIB_PATH}" "${FUNCTIONS_LIB_URL}"; then
echo -e "*** Failed to download the functions library. Please check your network connection! ***"
exit 1
fi
# Source the functions library
# shellcheck source=/tmp/functions.sh
source "${FUNCTIONS_LIB_PATH}"
# Docker files
DOCKER_COMPOSE_URL="https://raw.githubusercontent.com/oszuidwest/zwfm-liquidsoap/main/docker-compose.yml"
DOCKER_COMPOSE_PATH="/opt/liquidsoap/docker-compose.yml"
DOCKER_COMPOSE_ST_URL="https://raw.githubusercontent.com/oszuidwest/zwfm-liquidsoap/main/docker-compose.stereotool.yml"
DOCKER_COMPOSE_ST_PATH="/opt/liquidsoap/docker-compose.stereotool.yml"
# Liquidsoap configuration #
LIQUIDSOAP_CONFIG_URL="https://raw.githubusercontent.com/oszuidwest/zwfm-liquidsoap/main/radio.liq"
LIQUIDSOAP_CONFIG_PATH="/opt/liquidsoap/scripts/radio.liq"
AUDIO_FALLBACK_URL="https://upload.wikimedia.org/wikipedia/commons/6/66/Aaron_Dunn_-_Sonata_No_1_-_Movement_2.ogg"
AUDIO_FALLBACK_PATH="/opt/liquidsoap/audio/fallback.ogg"
# StereoTool configuration
STEREO_TOOL_VERSION="1041"
STEREO_TOOL_BASE_URL="https://download.thimeo.com"
STEREO_TOOL_ZIP_URL="${STEREO_TOOL_BASE_URL}/Stereo_Tool_Generic_plugin_${STEREO_TOOL_VERSION}.zip"
STEREO_TOOL_ZIP_PATH="/tmp/stereotool.zip"
# RDS configuration
RDS_RADIOTEXT_URL="https://rds.zuidwestfm.nl/?rt"
RDS_RADIOTEXT_PATH="/opt/liquidsoap/metadata/rds_rt.txt"
# General configuration
TIMEZONE="Europe/Amsterdam"
DIRECTORIES=(
"/opt/liquidsoap/scripts"
"/opt/liquidsoap/audio"
"/opt/liquidsoap/metadata"
)
OS_ARCH=$(dpkg --print-architecture)
# Environment setup
set_colors
check_user_privileges privileged
is_this_linux
is_this_os_64bit
set_timezone "${TIMEZONE}"
# Ensure Docker is installed
require_tool "docker"
# Display a welcome banner
clear
cat << "EOF"
______ _ ___ __ _ ______ __ __
|___ / (_) | \ \ / / | | | ____| \/ |
/ /_ _ _ __| |\ \ /\ / /__ ___| |_ | |__ | \ / |
/ /| | | | |/ _` | \ \/ \/ / _ \/ __| __| | __| | |\/| |
/ /_| |_| | | (_| | \ /\ / __/\__ \ |_ | | | | | |
/_____\__,_|_|\__,_| \/ \/ \___||___/\__| |_| |_| |_|
EOF
echo -e "${GREEN}⎎ Liquidsoap and StereoTool Installation${NC}\n"
# Prompt user for input
ask_user "USE_ST" "n" "Would you like to use StereoTool for sound processing? (y/n)" "y/n"
ask_user "DO_UPDATES" "y" "Would you like to perform all OS updates? (y/n)" "y/n"
if [ "${DO_UPDATES}" == "y" ]; then
update_os silent
fi
# Create required directories
echo -e "${BLUE}►► Creating directories...${NC}"
for dir in "${DIRECTORIES[@]}"; do
mkdir -p "${dir}"
done
# Backup and download configuration files
echo -e "${BLUE}►► Downloading configuration files...${NC}"
backup_file "${LIQUIDSOAP_CONFIG_PATH}"
if ! curl -sLo "${LIQUIDSOAP_CONFIG_PATH}" "${LIQUIDSOAP_CONFIG_URL}"; then
echo -e "${RED}Error: Unable to download the Liquidsoap configuration.${NC}"
exit 1
fi
backup_file "${DOCKER_COMPOSE_PATH}"
if ! curl -sLo "${DOCKER_COMPOSE_PATH}" "${DOCKER_COMPOSE_URL}"; then
echo -e "${RED}Error: Unable to download docker-compose.yml.${NC}"
exit 1
fi
if ! curl -sLo "${AUDIO_FALLBACK_PATH}" "${AUDIO_FALLBACK_URL}"; then
echo -e "${RED}Error: Unable to download the audio fallback file.${NC}"
exit 1
fi
if [ "${USE_ST}" == "y" ]; then
echo -e "${BLUE}►► Installing StereoTool...${NC}"
install_packages silent unzip
# Add RDS update cronjob if it doesn't exist yet (TODO: Integrate this in Liquidsoap)
if ! crontab -l | grep -q "${RDS_RADIOTEXT_PATH}"; then
echo "0 * * * * curl -s ${RDS_RADIOTEXT_URL} > ${RDS_RADIOTEXT_PATH} 2>/dev/null" | crontab -
fi
# Download the StereoTool-specific docker-compose configuration
backup_file "${DOCKER_COMPOSE_ST_PATH}"
if ! curl -sLo "${DOCKER_COMPOSE_ST_PATH}" "${DOCKER_COMPOSE_ST_URL}"; then
echo -e "${RED}Error: Unable to download docker-compose.stereotool.yml.${NC}"
exit 1
fi
# Download RDS metadata
if ! curl -sLo "${RDS_RADIOTEXT_PATH}" "${RDS_RADIOTEXT_URL}"; then
echo -e "${RED}Error: Unable to download RDS metadata.${NC}"
exit 1
fi
STEREO_TOOL_DIR="/opt/liquidsoap/stereotool"
mkdir -p "${STEREO_TOOL_DIR}"
# Download and extract StereoTool
if ! curl -sLo "${STEREO_TOOL_ZIP_PATH}" "${STEREO_TOOL_ZIP_URL}"; then
echo -e "${RED}Error: Unable to download StereoTool.${NC}"
exit 1
fi
TMP_DIR=$(mktemp -d)
unzip -o "${STEREO_TOOL_ZIP_PATH}" -d "${TMP_DIR}"
# Locate the extracted directory
EXTRACTED_DIR=$(find "${TMP_DIR}" -maxdepth 1 -type d -name "libStereoTool_*" | head -n 1)
if [ ! -d "${EXTRACTED_DIR}" ]; then
echo -e "${RED}Error: Unable to find the extracted StereoTool directory.${NC}"
exit 1
fi
# Copy the appropriate library based on the architecture
case "${OS_ARCH}" in
amd64)
LIB_PATH="${EXTRACTED_DIR}/lib/Linux/IntelAMD/64/libStereoTool_intel64.so"
;;
arm64)
LIB_PATH="${EXTRACTED_DIR}/lib/Linux/ARM/64/libStereoTool_arm64.so"
;;
*)
echo -e "${RED}Unsupported architecture: ${OS_ARCH}${NC}"
exit 1
;;
esac
if [ ! -f "${LIB_PATH}" ]; then
echo -e "${RED}Error: StereoTool library not found at ${LIB_PATH}.${NC}"
exit 1
fi
cp "${LIB_PATH}" "${STEREO_TOOL_DIR}/st_plugin.so"
# Clean up temporary files
rm -rf "${TMP_DIR}" "${STEREO_TOOL_ZIP_PATH}"
# Write StereoTool configuration
STEREOTOOL_RC_PATH="${STEREO_TOOL_DIR}/.liquidsoap.rc"
cat <<EOL > "${STEREOTOOL_RC_PATH}"
[Stereo Tool Configuration]
Enable web interface=1
Whitelist=/0
EOL
else
# Remove StereoTool configuration from the Liquidsoap script if not in use
sed -i '/# StereoTool implementation/,/output.dummy(radioproc)/d' "${LIQUIDSOAP_CONFIG_PATH}"
fi
# Adjust ownership for the directories
echo -e "${BLUE}►► Setting ownership for /opt/liquidsoap...${NC}"
chown -R 10000:10001 /opt/liquidsoap
echo -e "${GREEN}Installation completed successfully!${NC}"