mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 05:18:23 +02:00
dispatcher: avoid "dirname" and "basename" calls in "10-ifcfg-rh-routes.sh" script
The script is run for every dispatcher event. Most of the events are not actually relevant, and we just need to determine that there is nothing to do and quit. Avoid calling "dirname" and "basename". The supported ifcfg-file has a very specific form. We can just check (and parse) it in one got regular expression in bash.
This commit is contained in:
parent
babd1f314e
commit
c6d53c5500
1 changed files with 5 additions and 9 deletions
|
|
@ -16,17 +16,13 @@ if [ "$2" != "pre-up" ] && [ "$2" != "down" ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
dir=$(dirname "$CONNECTION_FILENAME")
|
||||
if [ "$dir" != "/etc/sysconfig/network-scripts" ]; then
|
||||
exit 0
|
||||
fi
|
||||
file_regex='^/etc/sysconfig/network-scripts/ifcfg-([^/]+)$'
|
||||
|
||||
profile=$(basename "$CONNECTION_FILENAME" | sed -ne 's/^ifcfg-//p')
|
||||
if [ -z "$profile" ]; then
|
||||
exit 0
|
||||
fi
|
||||
[[ "$CONNECTION_FILENAME" =~ $file_regex ]] || exit 0
|
||||
|
||||
if [ ! -f "$dir/rule-$profile" ] && [ ! -f "$dir/rule6-$profile" ]; then
|
||||
profile="${BASH_REMATCH[1]}"
|
||||
|
||||
if [ ! -f "/etc/sysconfig/network-scripts/rule-$profile" ] && [ ! -f "/etc/sysconfig/network-scripts/rule6-$profile" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue