From 94a3c632a5fc77f652d6c7db651546a050addb00 Mon Sep 17 00:00:00 2001 From: encrypt Date: Wed, 25 Mar 2015 17:53:30 +0100 Subject: [PATCH] add on_switch_toggle callback --- etherswitch.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etherswitch.sh b/etherswitch.sh index 5b3f699..2a25623 100755 --- a/etherswitch.sh +++ b/etherswitch.sh @@ -13,18 +13,23 @@ function check_fn { function load_config { unset -f on_switch_close unset -f on_switch_open + unset -f on_switch_toggle + source $conf + if [ -z "$device" ] then >&2 echo "device is not set" exit 1 fi + # check if $device is a network device ip link show $device > /dev/null if [ $? -eq 1 ]; then exit 1; fi check_fn "on_switch_close" check_fn "on_switch_open" + check_fn "on_switch_toggle" } # handle SIGTERM @@ -42,6 +47,7 @@ do if [ $current_state -ne $switch_state ] then switch_state=$current_state + on_switch_toggle if [ $switch_state -eq 1 ] then on_switch_open