diff options
author | Jonathan Cave <jonathan.cave@canonical.com> | 2018-10-22 13:24:28 +0100 |
---|---|---|
committer | Jonathan Cave <jonathan.cave@canonical.com> | 2018-10-22 13:24:28 +0100 |
commit | 70931cb246037be34723a6de424bf91f3ddf7214 (patch) | |
tree | 036c5ec6c31a1b0bec30aa214973755e4f7d8d56 | |
parent | b7e2fb90de262721387953458d31d6a3d34d6ebe (diff) |
check-static: import script to go with test
-rwxr-xr-x | bin/check_static | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/check_static b/bin/check_static new file mode 100755 index 0000000..dc649d5 --- /dev/null +++ b/bin/check_static @@ -0,0 +1,28 @@ +#!/bin/bash + +IFACE="$1" + +if [ "$IFACE" = "" ]; then + echo "No interface specified" + exit 1 +fi + +CARRIER=$(nmcli -t --fields WIRED-PROPERTIES.CARRIER d show $IFACE | cut -d ":" -f 2) +if [ "$CARRIER" = "off" ]; then + echo "No cable present" + exit 1 +fi + +CONN_NAME=$(nmcli -t --fields GENERAL.CONNECTION d show $IFACE | cut -d ":" -f 2) +if [ "$CONN_NAME" = "--" ]; then + echo "No connection active on $IFACE" + exit 1 +fi +echo "Connection active on $IFACE is $CONN_NAME" + +CONN_METHOD=$(nmcli -t --fields ipv4.method c show "$CONN_NAME" | cut -d ":" -f 2) +if [ "$CONN_METHOD" = "auto" ]; then + echo "FAIL: $CONN_METHOD" + exit 1 +fi +echo "PASS: $CONN_METHOD" |