logic refactoring, i should stop writing things in late night asd
This commit is contained in:
parent
43c9296a94
commit
117935efa8
1 changed files with 6 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env bash
|
#!/bin/env bash
|
||||||
|
|
||||||
conf=~/.etherswitch
|
conf=~/.etherswitch
|
||||||
switch_state=0
|
switch_state=-1
|
||||||
|
|
||||||
function check_fn {
|
function check_fn {
|
||||||
type $1 &> /dev/null || {
|
type $1 &> /dev/null || {
|
||||||
|
@ -37,18 +37,15 @@ load_config
|
||||||
|
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
ip link show $device | grep -q "LOWER_UP"
|
ip link show $device | grep -q "LOWER_UP"
|
||||||
if [ $? -eq 1 ]
|
current_state=$?
|
||||||
|
if [ $current_state -ne $switch_state ]
|
||||||
then
|
then
|
||||||
|
switch_state=$current_state
|
||||||
if [ $switch_state -eq 1 ]
|
if [ $switch_state -eq 1 ]
|
||||||
then
|
then
|
||||||
switch_state=0
|
|
||||||
on_switch_open
|
on_switch_open
|
||||||
fi
|
else
|
||||||
else
|
|
||||||
if [ $switch_state -eq 0 ]
|
|
||||||
then
|
|
||||||
switch_state=1
|
|
||||||
on_switch_close
|
on_switch_close
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue