Set stream name/description

This commit is contained in:
Bob Mottram 2017-11-26 21:06:03 +00:00
parent 945ca4180d
commit 98b427de1a
1 changed files with 38 additions and 4 deletions

View File

@ -340,6 +340,38 @@ function icecast_enable_login {
esac esac
} }
function icecast_set_stream_name {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"Change Icecast stream details" \
--form "\n" 8 60 4 \
$"Stream name:" 1 1 "Example stream name" 1 18 40 1000 \
$"Description:" 2 1 "A short description of your stream" 2 18 40 1000 \
$"Genre:" 3 1 "Example genre" 3 18 40 1000 \
2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
stream_name=$(cat $data | sed -n 1p)
stream_description=$(cat $data | sed -n 2p)
stream_genre=$(cat $data | sed -n 3p)
if [ ${#stream_name} -gt 2 ]; then
sed -i "s|<name>.*|<name>${stream_name}</name>|g" /etc/ices2/ices-playlist.xml
fi
if [ ${#stream_description} -gt 2 ]; then
sed -i "s|<description>.*|<description>${stream_description}</description>|g" /etc/ices2/ices-playlist.xml
fi
if [ ${#stream_genre} -gt 2 ]; then
sed -i "s|<genre>.*|<genre>${stream_genre}</genre>|g" /etc/ices2/ices-playlist.xml
fi
rm $data
stop_icecast
start_icecast
}
function configure_interactive_icecast { function configure_interactive_icecast {
while true while true
do do
@ -347,7 +379,7 @@ function configure_interactive_icecast {
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \ dialog --backtitle $"Freedombone Control Panel" \
--title $"Icecast" \ --title $"Icecast" \
--radiolist $"Choose an operation:" 17 70 10 \ --radiolist $"Choose an operation:" 18 70 11 \
1 $"Import stream files from directory" off \ 1 $"Import stream files from directory" off \
2 $"Import stream files from USB drive" off \ 2 $"Import stream files from USB drive" off \
3 $"Manually edit playlist" off \ 3 $"Manually edit playlist" off \
@ -357,7 +389,8 @@ function configure_interactive_icecast {
7 $"Change password for stream visitors" off \ 7 $"Change password for stream visitors" off \
8 $"Re-scan playlist" off \ 8 $"Re-scan playlist" off \
9 $"Restart stream" off \ 9 $"Restart stream" off \
10 $"Exit" on 2> $data 10 $"Set Stream Name/Description/Genre" off \
11 $"Exit" on 2> $data
sel=$? sel=$?
case $sel in case $sel in
1) break;; 1) break;;
@ -376,9 +409,10 @@ function configure_interactive_icecast {
icecast_rescan;; icecast_rescan;;
9) clear 9) clear
echo $'Restarting Icecast stream' echo $'Restarting Icecast stream'
stop_icacast stop_icecast
start_icecast;; start_icecast;;
10) break;; 10) icecast_set_stream_name;;
11) break;;
esac esac
done done
} }