From 03ff31613137b7459880e62c0bc5a3785e7c27a9 Mon Sep 17 00:00:00 2001 From: encrypt Date: Wed, 25 Mar 2015 01:21:52 +0100 Subject: [PATCH] add checks on network device --- etherswitch.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/etherswitch.sh b/etherswitch.sh index 2b8e4f8..75c3dd7 100755 --- a/etherswitch.sh +++ b/etherswitch.sh @@ -4,6 +4,16 @@ STATE=0 source ~/.etherswitch +if [ -z "$interface" ] +then + echo "interface is not set" + exit 1 +fi + +# check if $interface is a network device +ip link show $interface > /dev/null +if [ $? -eq 1 ]; then exit 1; fi + while : do ip link show $interface | grep -q "LOWER_UP"