moved to common db, music_directory, corrected delete function in radio.sh

parent 3d93be34
PORT=6755 PORT=6783
#!/bin/bash #!/bin/bash
ROOT_DIRECTORY=/home/icecastradio/radio_mpd/ ROOT_DIRECTORY=/home/icecastradio/radio_mpd/
URL=http://radio.azbyka.ru/json.xsl
cd $ROOT_DIRECTORY || exit cd $ROOT_DIRECTORY || exit
URL=http://radio2.azbyka.ru/json.xsl
STREAMS=`ls -l $ROOT_DIRECTORY | grep "^d" | awk '{print $9}'` STREAMS=`ls -l $ROOT_DIRECTORY | grep "^d" | awk '{print $9}'`
CONTENT=$(curl $URL 2>/dev/null) CONTENT=$(curl $URL 2>/dev/null)
ACTIVE_STREAMS=`grep -oP '(?<=/).*?(?=")' <<< $CONTENT` ACTIVE_STREAMS=`grep -oP '(?<=/).*?(?=")' <<< $CONTENT`
......
...@@ -43,9 +43,9 @@ elem_control() ...@@ -43,9 +43,9 @@ elem_control()
function create_stream() { function create_stream() {
local STREAM_NAME=$1
local STREAM_DIRECTORY=$ROOT_DIRECTORY/$1 local STREAM_DIRECTORY=$ROOT_DIRECTORY/$1
local ABS_PATH_TO_CFG=$STREAM_DIRECTORY/$1.mpd.conf local ABS_PATH_TO_CFG=$ROOT_DIRECTORY/$1.mpd.conf
if [[ ! -f $ABS_PATH_TO_CFG ]];then if [[ ! -f $ABS_PATH_TO_CFG ]];then
...@@ -65,21 +65,21 @@ function create_stream() { ...@@ -65,21 +65,21 @@ function create_stream() {
chmod +x $STREAM_DIRECTORY/playlists chmod +x $STREAM_DIRECTORY/playlists
# Systemd configuration # Systemd configuration
cp template.service /etc/systemd/system/$1.service sudo cp template.service /etc/systemd/system/$1.service
sed -i 's?#1?'$ABS_PATH_TO_CFG'?' /etc/systemd/system/$1.service sudo sed -i 's?#1?'$ABS_PATH_TO_CFG'?' /etc/systemd/system/$1.service
echo PORT=$((PORT+1)) > ./.port echo PORT=$((PORT+1)) > ./.port
serv daemon-reload sudo serv daemon-reload
serv $1 on sudo serv $1 on
# Enable playlist repeat # Enable playlist repeat
mpc -q $(elem_control $STREAM_NAME) repeat on sleep 1
mpc $(elem_control $STREAM_NAME) repeat on
echo "Файлы конфигураций cозданы успешно !" echo "Файлы конфигураций cозданы успешно !"
echo "Запущен mpd-поток под названием : $1 по адресу : radio.azbyka.ru:80/$1" echo "Запущен mpd-поток под названием : $1 по адресу : radio.azbyka.ru:80/$1"
#echo "Для начала работы требуется обновить базу данных mpd" #echo "Для начала работы требуется обновить базу данных mpd"
echo "Для работы с потоком : ./radio -m $1" echo "Для работы с потоком : ./radio.sh -m $1"
else else
echo -e "Поток \"$1\" уже создан.\nДля работы с ним : ./radio -m $1" echo -e "Поток \"$1\" уже создан.\nДля работы с ним : ./radio.sh -m $1"
fi fi
} }
...@@ -87,6 +87,9 @@ function create_stream() { ...@@ -87,6 +87,9 @@ function create_stream() {
function manage_stream() { function manage_stream() {
local STREAM_NAME=$1 local STREAM_NAME=$1
echo "mpc $(elem_control $STREAM_NAME) update"
mpc $(elem_control $STREAM_NAME) update
echo "ncmpc $(elem_control $STREAM_NAME)" echo "ncmpc $(elem_control $STREAM_NAME)"
ncmpc $(elem_control $STREAM_NAME) ncmpc $(elem_control $STREAM_NAME)
...@@ -94,9 +97,10 @@ function manage_stream() { ...@@ -94,9 +97,10 @@ function manage_stream() {
function delete_stream(){ function delete_stream(){
serv stop $1 serv off $1
rm -rvf ./$1* rm -rvf ./$1*
sudo rm -f /etc/systemd/system/$1.service sudo rm -fv /etc/systemd/system/$1.service
sudo systemctl daemon-reload sudo systemctl daemon-reload
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
music_directory "/var/local/media/audio" music_directory "/var/local/media/audio"
playlist_directory "#1/playlists" playlist_directory "#1/playlists"
log_file "#1/mpd.log" log_file "#1/mpd.log"
db_file "#1/mpd.db" db_file "/home/icecastradio/radio_mpd/mpd.db"
####################################################################### #######################################################################
######################## OPTIONAL PATHS ############################### ######################## OPTIONAL PATHS ###############################
...@@ -14,7 +14,7 @@ sticker_file "#1/sticker.sql" ...@@ -14,7 +14,7 @@ sticker_file "#1/sticker.sql"
######################## DAEMON OPTIONS ############################### ######################## DAEMON OPTIONS ###############################
user "icecastradio" user "icecastradio"
#bind_to_address "127.0.0.1" #bind_to_address "#1/socket"
bind_to_address "#1/mpd.socket" bind_to_address "#1/mpd.socket"
#bind_to_address "any" #bind_to_address "any"
#port "#2" #port "#2"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment