add on_switch_toggle callback

This commit is contained in:
encrypt 2015-03-25 17:53:30 +01:00
parent 117935efa8
commit 94a3c632a5

View file

@ -13,18 +13,23 @@ function check_fn {
function load_config { function load_config {
unset -f on_switch_close unset -f on_switch_close
unset -f on_switch_open unset -f on_switch_open
unset -f on_switch_toggle
source $conf source $conf
if [ -z "$device" ] if [ -z "$device" ]
then then
>&2 echo "device is not set" >&2 echo "device is not set"
exit 1 exit 1
fi fi
# check if $device is a network device # check if $device is a network device
ip link show $device > /dev/null ip link show $device > /dev/null
if [ $? -eq 1 ]; then exit 1; fi if [ $? -eq 1 ]; then exit 1; fi
check_fn "on_switch_close" check_fn "on_switch_close"
check_fn "on_switch_open" check_fn "on_switch_open"
check_fn "on_switch_toggle"
} }
# handle SIGTERM # handle SIGTERM
@ -42,6 +47,7 @@ do
if [ $current_state -ne $switch_state ] if [ $current_state -ne $switch_state ]
then then
switch_state=$current_state switch_state=$current_state
on_switch_toggle
if [ $switch_state -eq 1 ] if [ $switch_state -eq 1 ]
then then
on_switch_open on_switch_open