Commit 85c98016 authored by Andrey Shatokhin's avatar Andrey Shatokhin

Added checkmpd

parent 2ce6a996
#!/bin/bash
ROOT_DIRECTORY=/home/icecastradio/radio_mpd/
URL=http://radio.azbyka.ru/json.xsl
STREAMS=`ls -l $ROOT_DIRECTORY | grep "^d" | awk '{print $9}'`
CONTENT=$(curl $URL)
ACTIVE_STREAMS=`grep -oP '(?<=/).*?(?=")' <<< $CONTENT`
# List information
echo -e "\nAll MPD-STREAMS:"
for ELEM in $STREAMS; do
echo $ELEM
done
echo
echo "Active MPD-STREAMS:"
for ELEM in $ACTIVE_STREAMS; do
echo $ELEM
done
echo
OFFLINE_STREAMS=()
# 2) Compare "$ACTIVE_STREAMS" and variable "STREAMS".
# If "$ELEM" not in "$ACTIVE_STREAMS" , add "$ELEM" in $OFFLINE_STREAMS.
for ELEM in $STREAMS; do
if [[ ! $ACTIVE_STREAMS =~ $ELEM ]]; then
OFFLINE_STREAMS+=( $ELEM )
fi
done
echo "Restarting following MPD-STREAMS:"
for ELEM in ${OFFLINE_STREAMS[@]}; do
ELEM_PORT=`cat $ROOT_DIRECTORY/$ELEM.mpd.conf | grep port | awk '{ print $2 ; exit; }' ' | tr -d \"`
# Start stream
mpc -q -p $ELEM_PORT play
echo $ELEM
done
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