summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-09-20 10:19:11 -0500
committerDan Williams <dcbw@redhat.com>2012-09-20 10:19:11 -0500
commitaaa5d2f70fe5e0d768f17cbe274de015e34a0309 (patch)
tree3f3aa7008f4146cd02dd56e03f2592561cabfdb4
parentee22af6961bf6fb9e80d53c6eb87ac9a336a7a0f (diff)
examples: add dispatcher example for exclusive wired/wifi
-rw-r--r--configure.ac1
-rw-r--r--examples/Makefile.am3
-rwxr-xr-xexamples/dispatcher/70-wifi-wired-exclusive.sh26
-rw-r--r--examples/dispatcher/Makefile.am3
4 files changed, 32 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 0b59c80f..903c61e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -839,6 +839,7 @@ examples/ruby/Makefile
examples/C/Makefile
examples/C/glib/Makefile
examples/C/qt/Makefile
+examples/dispatcher/Makefile
vapi/Makefile
])
AC_OUTPUT
diff --git a/examples/Makefile.am b/examples/Makefile.am
index eeea8771..a227f0ea 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -2,4 +2,5 @@ SUBDIRS= \
shell \
python \
ruby \
- C
+ C \
+ dispatcher
diff --git a/examples/dispatcher/70-wifi-wired-exclusive.sh b/examples/dispatcher/70-wifi-wired-exclusive.sh
new file mode 100755
index 00000000..501f159e
--- /dev/null
+++ b/examples/dispatcher/70-wifi-wired-exclusive.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+export LC_ALL=C
+
+# This dispatcher script makes WiFi mutually exclusive with
+# wired networking. When a wired interface is connected,
+# WiFi will be set to airplane mode (rfkilled). When the wired
+# interface is disconnected, WiFi will be turned back on.
+
+enable_disable_wifi ()
+{
+ result=$(nmcli dev | grep "802-3-ethernet" | grep -w "connected")
+ if [ -n "$result" ]; then
+ nmcli nm wifi off
+ else
+ nmcli nm wifi on
+ fi
+}
+
+if [ "$2" = "up" ]; then
+ enable_disable_wifi
+fi
+
+if [ "$2" = "down" ]; then
+ enable_disable_wifi
+fi
+
diff --git a/examples/dispatcher/Makefile.am b/examples/dispatcher/Makefile.am
new file mode 100644
index 00000000..0db71a0d
--- /dev/null
+++ b/examples/dispatcher/Makefile.am
@@ -0,0 +1,3 @@
+EXTRA_DIST = \
+ 70-wifi-wired-exclusive.sh
+