CURRENT RDSTREAM.SH
#!/bin/sh
expired=
#source $1
source /etc/rdstream.conf
cd $working_dir
#Update current title to something generic
sh ./update_sc.sh "You're listening to $station_name" &> /dev/null
#start netcat command
which netcat &> /dev/null
if [ $? -ne 0 ]
then
which nc &> /dev/null
if [ $? -ne 0 ]
then
echo "Netcat is not installed" &>1 &>2
exit
else
netcat_bin=$(which nc)
fi
else
netcat_bin=$(which netcat)
fi
$netcat_bin -l -u -p $now_and_next_port > $working_dir/temp.dat &
echo $(cat $pidfile) $(ps -ef | grep -i $netcat_bin | grep -v $(echo $pidfile) | grep -v grep | awk '{print $2}') > $pidfile
while true
do
#Grab Current
current=$(tail -n 1 ./temp.dat >&1)
# echo $current >&1
#Check if rivendell is running, if not, return the default
ps -ef | grep -i rdairplay | grep -v grep &> /dev/null
if [ $? -ne 0 ]
then
sh ./update_sc.sh "You're listening to $station_name" &> /dev/null &
fi
#if the output changed, update as necesary
if [ "$current" != "$expired" ]
then
expired=$current
#If the output is smaller than 5 characters then return the default message
if [ "${#current}" -lt "5" ]
then
sh ./update_sc.sh "You're listening to $station_name" &> /dev/null &
else
#if the output is not less than 5, update the title.
sh ./update_sc.sh "$current" &> /dev/null &
echo "$current" > /var/webpull/nowplaying/nn.temp >&1
echo Updating $sc_server title with $current. >&1
fi
fi
sleep 2
done