switch: Asynchronously execute blue merle when toggled

I hope that this allows us to use the toggle again to advance the Blue
Merle logic.
If all goes well, the script finishes execution and the switch lock in
/var/lock/gl-switch.lock is released so that the button can be used
again.
This commit is contained in:
Tobias Mueller 2023-10-17 13:29:33 +02:00
parent db1c0c4c69
commit eab0633ad9

View File

@ -10,8 +10,7 @@ logger -p notice -t blue-merle-toggle "Called... ${action}"
if [ "$action" = "on" ];then if [ "$action" = "on" ];then
mcu_send_message "Blue Merle ${action}" mcu_send_message "Blue Merle ${action}"
echo "on" > /tmp/sim_change_switch echo "on" > /tmp/sim_change_switch
flock -n /tmp/blue-merle-switch.lock timeout 90 /usr/bin/blue-merle-switch || logger -p notice -t blue-merle-toggle "Lockfile busy" & ubus call file exec '{ "command": "flock", "params": ["-n", "/tmp/blue-merle-switch.lock", "timeout", "90", "/usr/bin/blue-merle-switch"] }'
logger -p notice -t blue-merle-toggle "Finished Switch"
elif [ "$action" = "off" ];then elif [ "$action" = "off" ];then
mcu_send_message "Blue Merle ${action}" mcu_send_message "Blue Merle ${action}"
@ -20,4 +19,5 @@ elif [ "$action" = "off" ];then
else else
echo "off" > /tmp/sim_change_switch echo "off" > /tmp/sim_change_switch
fi fi
logger -p notice -t blue-merle-toggle "Finished Switch"
sleep 1 sleep 1