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.
This commit is contained in:
Thomas Haller 2019-10-04 11:09:52 +02:00
parent 5a24ad53ad
commit babd1f314e

View file

@ -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