aboutsummaryrefslogtreecommitdiff
path: root/files/bin/ifcheck
diff options
context:
space:
mode:
Diffstat (limited to 'files/bin/ifcheck')
-rwxr-xr-xfiles/bin/ifcheck19
1 files changed, 19 insertions, 0 deletions
diff --git a/files/bin/ifcheck b/files/bin/ifcheck
new file mode 100755
index 0000000..c66f2ad
--- /dev/null
+++ b/files/bin/ifcheck
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# Check if a network interface is up, fixing if needed.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+IFACE="$1"
+
+# Syntax check
+if [ -z "$IFACE" ]; then
+ echo "usage: $BASENAME <interface>"
+ exit 1
+fi
+
+# Run
+if ! LANG=C LC_ALL=C ifconfig $IFACE | grep -q "inet addr:"; then
+ ifup --force $IFACE
+fi