summaryrefslogtreecommitdiff
diff options
authorPMR <pmr@pmr-lander>2018-10-22 14:07:15 +0000
committerPMR <pmr@pmr-lander>2018-10-22 14:07:15 +0000
commitd546e8a546b28471b8897aa889ea611e55943c7a (patch)
tree036c5ec6c31a1b0bec30aa214973755e4f7d8d56
parentb7e2fb90de262721387953458d31d6a3d34d6ebe (diff)
parent70931cb246037be34723a6de424bf91f3ddf7214 (diff)
Merge #357622 from ~jocave/plainbox-provider-checkbox:add-check-static
-rwxr-xr-xbin/check_static28
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/check_static b/bin/check_static
new file mode 100755
index 00000000..dc649d5c
--- /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"