diff options
author | Miloslav Trmac <mitr@volny.cz> | 2006-07-26 01:30:02 +0000 |
---|---|---|
committer | Miloslav Trmac <mitr@volny.cz> | 2006-07-26 01:30:02 +0000 |
commit | 0d27618adb7bd5fa4300a00921d69c1c6aae68fa (patch) | |
tree | b80f344c1a8d94bec07eddada0ff4b5642e82f1e /sysconfig/network-scripts | |
parent | bafb0b214d8e0b9dbaebf5bfa6111fbb35a0039a (diff) | |
download | initscripts-0d27618adb7bd5fa4300a00921d69c1c6aae68fa.tar initscripts-0d27618adb7bd5fa4300a00921d69c1c6aae68fa.tar.gz initscripts-0d27618adb7bd5fa4300a00921d69c1c6aae68fa.tar.bz2 initscripts-0d27618adb7bd5fa4300a00921d69c1c6aae68fa.tar.xz initscripts-0d27618adb7bd5fa4300a00921d69c1c6aae68fa.zip |
Use the alias value to lookup an install line.
Use string comparisons instead of regexp matches in the awk conditions,
speeding up the awk program several times.
Diffstat (limited to 'sysconfig/network-scripts')
-rw-r--r-- | sysconfig/network-scripts/network-functions | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 36d207a7..310d9861 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -200,11 +200,18 @@ is_available () LC_ALL= LANG= ip -o link | grep -q $1 [ "$?" = "1" ] || return 0 - alias=`modprobe -c | awk "/^(alias|install)[[:space:]]+$1[[:space:]]/ { print \\$3 }"` - if [ -z "$alias" -o "$alias" = "off" -o "$alias" = "/bin/true" \ - -o "$alias" = ":" ]; then - return 2 - fi + modprobe -c | awk \ +'BEGIN { alias = ""; } +$1 == "alias" && $2 == "'"$1"'" { alias = $3; } +$1 == "install" { install[$2] = $3; } +END { + cmd = install[alias]; + if (alias == "" || alias == "off" || cmd == "/bin/true" || cmd == ":") + exit 1; + exit 0; +}' + [ $? -eq 0 ] || return 2 + modprobe $1 > /dev/null 2>&1 || { return 1 } |