diff options
author | Thomas Haller <thaller@redhat.com> | 2019-10-04 11:09:52 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-10-04 12:37:50 +0200 |
commit | babd1f314e213388ead0e9272bc5939225383b3f (patch) | |
tree | d93d00cdef6f17d54efa981452753d010ba641e1 /examples | |
parent | 5a24ad53ad241059cf70b6593454fc124520405d (diff) | |
download | NetworkManager-babd1f314e213388ead0e9272bc5939225383b3f.tar.gz |
dispatcher: move return-early checks in "10-ifcfg-rh-routes.sh" first
A shell script is executed line-by-line. Note that for most dispatcher
events, "10-ifcfg-rh-routes.sh" has nothing to do and will just quit.
Move those checks earlier, to avoid bash executing the code that won't
be needed most of the time.
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/dispatcher/10-ifcfg-rh-routes.sh | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/examples/dispatcher/10-ifcfg-rh-routes.sh b/examples/dispatcher/10-ifcfg-rh-routes.sh index d72400aed7..45dfc40147 100755 --- a/examples/dispatcher/10-ifcfg-rh-routes.sh +++ b/examples/dispatcher/10-ifcfg-rh-routes.sh @@ -12,6 +12,24 @@ # This file is derived from scripts 'if{up,down}-routes' from # Fedora/RHEL initscripts. +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 + MATCH='^[[:space:]]*(\#.*)?$' handle_file () { @@ -45,24 +63,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 |