Thanks for loaning us your expertise and good documentation skills. I followed your procedure to get a couple of Raspberry Pi/R820T setups working.
I riffed off the email script you posted at https://github.com/tim273/weather_radio_scripts/blob/master/OPTIONAL.md
and modified it so that it attempts to restart Darkice if it doesn't see my mountpoint up on the Icecast server. I called this script check_darkice_up.sh, and put it in /home/pi:
status_code=$(curl -v $url 2>&1 | grep -o /mycity/mycallsign.mp3)
if [ "$status_code" == "" ]
sudo /usr/sbin/service darkice restart
I had to put "sudo /usr/sbin/" in front of "service darkice restart" to get it to run as a cron job. Most of the clue on why that's necessary was posted in the first answer under https://unix.stackexchange.com/questions/179042/shell-script-issue-when-added-to-cron
. Without the "sudo," cron sent me an email at /var/mail/pi telling me the script failed at /usr/sbin/service darkice restart with an "Access denied" error.
I made the script executable:
chmod +x /home/pi/check_darkice_up.sh
Then I added a line to crontab to run it once each minute:
* * * * * /home/pi/check_darkice_up.sh
I tested it by stopping darkice using
sudo service darkice stop
and letting the cron job run. I can also run the script using:
Once I found that it runs OK as a cron job, I changed the interval to 31 minutes by changing the line in crontab to
*/31 * * * * /home/pi/check_darkice_up.sh
I should have let satcop know I was working on this, because in the middle of testing it, I got an email message to the effect that "your stream is down again!"