about summary refs log tree commit diff
path: root/examples/dispatcher
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2020-01-07 16:43:07 +0100
committerSebastien Bacher <seb128@ubuntu.com>2020-01-07 16:43:07 +0100
commita524db35ac5c2099671d16318524e277e88631be (patch)
tree54b29c42a317b9a13c3049ff85b14f7dce734cf6 /examples/dispatcher
parent6917e28d2d16138d6d497dc96efafe573b4b0979 (diff)
parent724bcc5c7be3aed3646ed2b2989c34d438217176 (diff)
Merge branch 'upstream/latest' of https://salsa.debian.org/utopia-team/network-manager into upstream
Diffstat (limited to 'examples/dispatcher')
-rwxr-xr-xexamples/dispatcher/10-ifcfg-rh-routes.sh32
-rwxr-xr-xexamples/dispatcher/70-wifi-wired-exclusive.sh4
2 files changed, 16 insertions, 20 deletions
diff --git a/examples/dispatcher/10-ifcfg-rh-routes.sh b/examples/dispatcher/10-ifcfg-rh-routes.sh
index d72400ae..0f49ec2a 100755
--- a/examples/dispatcher/10-ifcfg-rh-routes.sh
+++ b/examples/dispatcher/10-ifcfg-rh-routes.sh
@@ -12,6 +12,20 @@
 # This file is derived from scripts 'if{up,down}-routes' from
 # Fedora/RHEL initscripts.
 
+if [ "$2" != "pre-up" ] && [ "$2" != "down" ]; then
+    exit 0
+fi
+
+file_regex='^/etc/sysconfig/network-scripts/ifcfg-([^/]+)$'
+
+[[ "$CONNECTION_FILENAME" =~ $file_regex ]] || exit 0
+
+profile="${BASH_REMATCH[1]}"
+
+if [ ! -f "/etc/sysconfig/network-scripts/rule-$profile" ] && [ ! -f "/etc/sysconfig/network-scripts/rule6-$profile" ]; then
+    exit 0
+fi
+
 MATCH='^[[:space:]]*(\#.*)?$'
 
 handle_file () {
@@ -45,24 +59,6 @@ handle_ip_file() {
 }
 
 
-if [ "$2" != "pre-up" ] && [ "$2" != "down" ]; then
-    exit 0
-fi
-
-dir=$(dirname "$CONNECTION_FILENAME")
-if [ "$dir" != "/etc/sysconfig/network-scripts" ]; then
-    exit 0
-fi
-
-profile=$(basename "$CONNECTION_FILENAME" | sed -ne 's/^ifcfg-//p')
-if [ -z "$profile" ]; then
-    exit 0
-fi
-
-if [ ! -f "$dir/rule-$profile" ] && [ ! -f "$dir/rule6-$profile" ]; then
-    exit 0
-fi
-
 case "$2" in
     pre-up)
         # Routes
diff --git a/examples/dispatcher/70-wifi-wired-exclusive.sh b/examples/dispatcher/70-wifi-wired-exclusive.sh
index fac18b59..b8a2336e 100755
--- a/examples/dispatcher/70-wifi-wired-exclusive.sh
+++ b/examples/dispatcher/70-wifi-wired-exclusive.sh
@@ -4,8 +4,8 @@
 # Wi-Fi will be set to airplane mode (rfkilled).  When the wired
 # interface is disconnected, Wi-Fi will be turned back on.
 #
-# Copyright 2012 Johannes Buchner <buchner.johannes@gmx.at>
-# Copyright 2012 - 2014 Red Hat, Inc.
+# Copyright (C) 2012 Johannes Buchner <buchner.johannes@gmx.at>
+# Copyright (C) 2012 - 2014 Red Hat, Inc.
 #
 
 export LC_ALL=C