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
|
||||
|
||||
conf=~/.etherswitch
|
||||
switch_state=0
|
||||
switch_state=-1
|
||||
|
||||
function check_fn {
|
||||
type $1 &> /dev/null || {
|
||||
|
@ -38,17 +38,14 @@ load_config
|
|||
while :
|
||||
do
|
||||
ip link show $device | grep -q "LOWER_UP"
|
||||
if [ $? -eq 1 ]
|
||||
current_state=$?
|
||||
if [ $current_state -ne $switch_state ]
|
||||
then
|
||||
switch_state=$current_state
|
||||
if [ $switch_state -eq 1 ]
|
||||
then
|
||||
switch_state=0
|
||||
on_switch_open
|
||||
fi
|
||||
else
|
||||
if [ $switch_state -eq 0 ]
|
||||
then
|
||||
switch_state=1
|
||||
on_switch_close
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue