aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2016-10-23 17:02:32 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2016-10-23 17:02:32 -0700
commit7242a8d22d0a441c54824bef37c09731e4918587 (patch)
tree2259a939fb8065ef3e3e96a45f220505797a45b4
parentiproute2: handle other error case better. (diff)
downloadnetifrc-7242a8d22d0a441c54824bef37c09731e4918587.tar.gz
netifrc-7242a8d22d0a441c54824bef37c09731e4918587.tar.bz2
netifrc-7242a8d22d0a441c54824bef37c09731e4918587.zip
iproute2: clean up error output and make sure it works.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r--init.d/net.lo.in4
-rw-r--r--net/iproute2.sh28
2 files changed, 16 insertions, 16 deletions
diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 3b47f1a..dbade70 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -248,7 +248,7 @@ _get_errorhandler_behavior() {
"errh_DEFAULT_DEFAULT_DEFAULT" \
"errh" \
"fallback" ; do
- eval value="\${key}"
+ eval value="\${${key}}"
if [ -n "$value" ]; then
echo "$value" && break
fi
@@ -844,3 +844,5 @@ stop()
return 0
}
+
+# vim:filetype=gentoo-init-d:
diff --git a/net/iproute2.sh b/net/iproute2.sh
index 2c9f6bb..b6fd847 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -112,7 +112,7 @@ _add_address()
local confflaglist family raw_address family_maxnetmask
raw_address="$1" ; shift
# Extract the netmask on address if present.
- if [ "${address%\/*}" != "${address}" ]; then
+ if [ "${raw_address%\/*}" != "${raw_address}" ]; then
address="${raw_address%\/*}"
netmask="${raw_address#*\/}"
else
@@ -193,15 +193,14 @@ _add_address()
# You can completely silence this with: errh_IFVAR_address_EEXIST=continue
if [ $address_already_exists -eq 0 ]; then
eh_behavior=$(_get_errorhandler_behavior "$IFVAR" "address" "EEXIST" "warn")
- abort=0
case $eh_behavior in
- continue) msgfunc=true ;;
- info) msgfunc=einfo ;;
- warn) msgfunc=ewarn ;;
- error|fatal) msgfunc=eerror abort=1;;
+ continue) msgfunc=true rc=0 ;;
+ info) msgfunc=einfo rc=0 ;;
+ warn) msgfunc=ewarn rc=0 ;;
+ error|fatal) msgfunc=eerror rc=1;;
esac
- $msgfunc "Address ${address}${netmask:+/}${netmask} already existed: $(ip addr show to "${address}/${family_maxnetmask}" dev "${IFACE}" 2>&1)"
- [ $abort -eq 1 ] && rc=1
+ eval $msgfunc "Address ${address}${netmask:+/}${netmask} already existed!"
+ eval $msgfunc \"$(ip addr show to "${address}/${family_maxnetmask}" dev "${IFACE}" 2>&1)\"
else
: # TODO: Handle other errors
fi
@@ -265,15 +264,14 @@ _add_route()
# You can completely silence this with: errh_IFVAR_route_EEXIST=continue
if [ $route_already_exists -eq 0 ]; then
eh_behavior=$(_get_errorhandler_behavior "$IFVAR" "route" "EEXIST" "warn")
- abort=0
case $eh_behavior in
- continue) msgfunc=true ;;
- info) msgfunc=einfo ;;
- warn) msgfunc=ewarn ;;
- error|fatal) msgfunc=eerror abort=1;;
+ continue) msgfunc=true rc=0 ;;
+ info) msgfunc=einfo rc=0 ;;
+ warn) msgfunc=ewarn rc=0 ;;
+ error|fatal) msgfunc=eerror rc=1;;
esac
- $msgfunc "Route '$cmd' already existed: $(ip $family route show $cmd dev "${IFACE}" 2>&1)"
- [ $abort -eq 1 ] && rc=1
+ eval $msgfunc "Route '$cmd' already existed."
+ eval $msgfunc \"$(ip $family route show $cmd dev "${IFACE}" 2>&1)\"
else
: # TODO: Handle other errors
fi