The only script that needs to be started on startup is detect-ads.sh. For convienience I created the radio-init.sh. This script also starts detect-ads.sh. radio-init is run on startup by creating the file in /etc/init.d (which I named /etc/init.d/myradio). All the code is present in the post.
The ez-setup button is already supported by OpenWRT. To run script on button press and release you'll need to create a file in /etc/hotplug.d/button/ (I called it /etc/hotplug.d/button/01-radio-control). The script inside the file checkes if it is a press or release and calls /root/buttonpressed.sh of /root/buttonreleased.sh respectfully.
Please note that if you press and release a few times the order of the press and release is sometimes switched. E.g. you'll get press-release-release-press. The script already takes care of this.
For your sleep function you'll need to remove the first 3 lines from mympc.sh. Namingly:
- Code: Select all
if [ "$1" != "stop" ];then
touch /tmp/lastradioinput
fi
You'll might also want to change the cron settings so it will check every minute instead of 5minutes if the sleep period has passed. Just change '*/5' to '*'
Hope this is helpful. If you have any more questions, just let me know.
Next you'll need to to change button-pressed.sh, by adding
- Code: Select all
if [ "$states" = "prp" -o "$states" = "ppr" ];then
/root/mympc.sh play
touch /tmp/lastradioinput
exit
fi
Finally you'll need to change check-sleep.sh, to make it only stop playback the first time.
Change
- Code: Select all
touch /tmp/lastradioinput
to
- Code: Select all
rm /tmp/lastradioinput