Last active
June 16, 2023 22:41
-
-
Save sullrich/fdbac3b002ce08e2d40263cd798366f6 to your computer and use it in GitHub Desktop.
Monitors streams and restarts if needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -i counter=0 | |
declare -i failcounter110=0 | |
declare -i failcounter145=0 | |
check110() { | |
if [ -f /tmp/bmitune110.lock ]; then | |
return | |
fi | |
if [ ! -f /tmp/bmitune110.playing ]; then | |
return | |
fi | |
status=$(./isconnected110.sh) | |
if [ "$status" == "true" ]; then | |
failcounter110=0 | |
return | |
else | |
((failcounter110++)) | |
if ((failcounter110 > 3)); then | |
adb -s 10.0.250.154 shell dumpsys appops --op TOAST_WINDOW > /tmp/fail.bmitune110.txt | |
failcounter110=0 | |
rm /tmp/bmitune110.* | |
echo "!!! Giving up trying to stream 110." | |
return | |
fi | |
station=$(cat /tmp/bmitune110.playing) | |
echo "!!! Performing rescue of 110 $station" | |
./bmitune110.sh "$station" | |
fi | |
} | |
check145() { | |
if [ -f /tmp/bmitune145.lock ]; then | |
return | |
fi | |
if [ ! -f /tmp/bmitune145.playing ]; then | |
return | |
fi | |
status=$(./isconnected145.sh) | |
if [ "$status" == "true" ]; then | |
failcounter145=0 | |
return | |
else | |
((failcounter145++)) | |
if ((failcounter145 > 3)); then | |
adb -s 10.0.250.153 shell dumpsys appops --op TOAST_WINDOW > /tmp/fail.bmitune145.txt | |
failcounter145=0 | |
rm /tmp/bmitune145.* | |
echo "!!! Giving up trying to stream 145." | |
return | |
fi | |
station=$(cat /tmp/bmitune145.playing) | |
echo "!!! Performing rescue of 145 $station" | |
./bmitune145.sh "$station" | |
fi | |
} | |
while [ /bin/true ]; do | |
echo "" | |
date | |
if ((counter > 60)); then | |
# keep alive 136 | |
adb connect 10.0.250.154 | |
adb -s 10.0.250.154 shell input keyevent 224 | |
adb -s 10.0.250.154 shell input keyevent 221 | |
adb -s 10.0.250.154 disconnect | |
# keep alive 153 | |
#adb connect 10.0.250.153 | |
#adb -s 10.0.250.153 shell input keyevent 224 | |
#adb -s 10.0.250.153 shell input keyevent 221 | |
#adb -s 10.0.250.153 disconnect | |
counter=0 | |
fi | |
check110 | |
check145 | |
((counter++)) | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment