mirror of
https://github.com/srlabs/blue-merle.git
synced 2024-12-22 21:59:25 -05:00
6b7e11137b
I think we can only toggle while the handler is not active. I toggled to ON and got the script running. But then I couldn't toggle OFF, presumingly because the script was still running. By sending it to the background I hope it will allow me to toggle OFF.
22 lines
531 B
Bash
22 lines
531 B
Bash
#!/bin/sh
|
|
|
|
. /lib/functions/gl_util.sh
|
|
|
|
action=$1
|
|
|
|
logger -p notice -t blue-merle-toggle "Called... ${action}"
|
|
|
|
if [ "$action" = "on" ];then
|
|
mcu_send_message "Blue Merle ${action}"
|
|
echo "on" > /tmp/sim_change_switch
|
|
flock -n /tmp/blue-merle-switch.lock /usr/bin/blue-merle-switch || logger -p notice -t blue-merle-toggle "Lockfile busy" &
|
|
|
|
elif [ "$action" = "off" ];then
|
|
mcu_send_message "Blue Merle ${action}"
|
|
echo "off" > /tmp/sim_change_switch
|
|
|
|
else
|
|
echo "off" > /tmp/sim_change_switch
|
|
fi
|
|
sleep 1
|