Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc/rc.d Add proper error reporting via the return code:



details:   https://anonhg.NetBSD.org/src/rev/81895942e060
branches:  trunk
changeset: 747962:81895942e060
user:      tron <tron%NetBSD.org@localhost>
date:      Wed Oct 07 08:06:11 2009 +0000

description:
Add proper error reporting via the return code:
Remember if any of the "route" commands failed and return an error in
that case.

diffstat:

 etc/rc.d/staticroute |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (48 lines):

diff -r 1b50744bb572 -r 81895942e060 etc/rc.d/staticroute
--- a/etc/rc.d/staticroute      Wed Oct 07 07:51:28 2009 +0000
+++ b/etc/rc.d/staticroute      Wed Oct 07 08:06:11 2009 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: staticroute,v 1.4 2009/10/07 07:51:28 tron Exp $
+# $NetBSD: staticroute,v 1.5 2009/10/07 08:06:11 tron Exp $
 #
 
 # PROVIDE: staticroute
@@ -16,6 +16,8 @@
 stop_cmd="staticroute_doit Deleting delete"
 
 staticroute_doit() {
+       retval=0
+
        if [ -s /etc/route.conf ]; then
                echo "$1 static routes."
                while read args; do
@@ -24,19 +26,23 @@
                        "#"*)
                                ;;
                        "+"*)
-                               [ $2 = "add" ] && eval ${args#*+}
+                               if [ $2 = "add" ]; then
+                                       eval ${args#*+} || retval=1
+                               fi
                                ;;
                        "-"*)
-                               [ $2 = "delete" ] && eval ${args#*-}
+                               if [ $2 = "delete" ]; then
+                                       eval ${args#*-} || retval=1
+                               fi
                                ;;
                        *)
-                               route -q $2 -$args
+                               route -q $2 -$args || retval=1
                                ;;
                        esac
                done < /etc/route.conf
        fi
 
-       return 0
+       return $retval
 }
 
 load_rc_config $name



Home | Main Index | Thread Index | Old Index