Add '10-thunderkey.sh'

This commit is contained in:
Andrea 2023-09-08 23:53:38 +08:00
parent 67ae1044e9
commit 74a4206c76

43
10-thunderkey.sh Normal file
View File

@ -0,0 +1,43 @@
#!/bin/bash
# luhf @ git.monocul.us - Andrea Santaniello
do_magic() {
local lockfile="/tmp/TBREBOOT"
if [ -e "$lockfile" ]; then
echo "Lockfile already exists. Process might be running."
else
touch "$lockfile"
echo "Lockfile created at $lockfile starting procedure."
# Beep Signal
/sbin/hal_app --se_buzzer enc_id=0,mode=100
/sbin/hal_app --se_buzzer enc_id=0,mode=101
/sbin/hal_app --se_buzzer enc_id=0,mode=100
# Restart TB services.
/etc/init.d/thunderbolt.sh stop
sleep 5
# Final Beep
/etc/init.d/thunderbolt.sh start
/sbin/hal_app --se_buzzer enc_id=0,mode=100
/sbin/hal_app --se_buzzer enc_id=0,mode=101
/sbin/hal_app --se_buzzer enc_id=0,mode=100
fi
}
while true; do
# HOW TO: get a usb drive, nothing fancy, create an empty file named RESETTB, change path here.
if [ -e "/share/external/DEV3301_1/RESETTB" ]; then
if [ -e "/tmp/TBREBOOT" ]; then
rm /tmp/TBREBOOT
/sbin/hal_app --se_buzzer enc_id=0,mode=100
/sbin/hal_app --se_buzzer enc_id=0,mode=100
fi
echo "RESETTB found!"
sleep 5
else
echo "RESETTB not found. Waiting..."
do_magic
sleep 5
fi
done