2023-10-16 10:14:00 +00:00
|
|
|
#!/bin/sh
|
2023-10-17 11:02:40 +00:00
|
|
|
action=$1
|
|
|
|
logger -p notice -t blue-merle-toggle "Called... ${action}"
|
|
|
|
|
2023-10-16 10:14:00 +00:00
|
|
|
|
2023-10-16 14:10:17 +00:00
|
|
|
. /lib/functions/gl_util.sh
|
|
|
|
|
2023-10-16 10:14:00 +00:00
|
|
|
|
2023-10-16 14:03:11 +00:00
|
|
|
|
2023-10-16 10:14:00 +00:00
|
|
|
if [ "$action" = "on" ];then
|
2023-10-16 14:10:17 +00:00
|
|
|
mcu_send_message "Blue Merle ${action}"
|
2023-10-16 10:14:00 +00:00
|
|
|
echo "on" > /tmp/sim_change_switch
|
2023-10-17 11:02:40 +00:00
|
|
|
flock -n /tmp/blue-merle-switch.lock timeout 90 /usr/bin/blue-merle-switch || logger -p notice -t blue-merle-toggle "Lockfile busy" &
|
|
|
|
logger -p notice -t blue-merle-toggle "Finished Switch"
|
2023-10-16 10:14:00 +00:00
|
|
|
|
|
|
|
elif [ "$action" = "off" ];then
|
2023-10-16 14:10:17 +00:00
|
|
|
mcu_send_message "Blue Merle ${action}"
|
2023-10-16 10:14:00 +00:00
|
|
|
echo "off" > /tmp/sim_change_switch
|
2023-10-16 14:10:17 +00:00
|
|
|
|
2023-10-16 10:14:00 +00:00
|
|
|
else
|
|
|
|
echo "off" > /tmp/sim_change_switch
|
|
|
|
fi
|
|
|
|
sleep 1
|