]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
log /etc/init.d/networking errors into syslog using /usr/bin/logger
authorRoopa Prabhu <roopa@cumulusnetworks.com>
Thu, 10 Jul 2014 03:23:21 +0000 (20:23 -0700)
committerRoopa Prabhu <roopa@cumulusnetworks.com>
Thu, 10 Jul 2014 03:23:21 +0000 (20:23 -0700)
Ticket: CM-3193
Reviewed By:
Testing Done: Tested logging of errors in syslog from ifup at bootup

Example error msg:
"Jul 10 03:13:17 cumulus /etc/init.d/networking[1183]: error:
/etc/network/interfaces: line16: invalid auto line 'auto'"

This patch logs into syslog only during bootup

init.d/networking

index b539ebd598cbe8adc6b755af203f1ba9c9a6d8b5..df5e43fe7c13530e0405af7be1a781578f74e181 100644 (file)
@@ -13,6 +13,9 @@ PATH="/sbin:/bin"
 RUN_DIR="/run/network"
 IFSTATE="$RUN_DIR/ifstate"
 
+NAME=networking
+SCRIPTNAME=/etc/init.d/$NAME
+
 [ -x /sbin/ifup ] || exit 0
 [ -x /sbin/ifdown ] || exit 0
 
@@ -20,6 +23,7 @@ IFSTATE="$RUN_DIR/ifstate"
 
 CONFIGURE_INTERFACES=yes
 EXCLUDE_INTERFACES=
+REMOTE_SYSLOG_SERVER=
 VERBOSE=no
 
 verbose=
@@ -47,11 +51,20 @@ gen_examples() {
     return
 }
 
+is_bootup() {
+    # Return 0 if its bootup or return 1
+    [ -f /var/tmp/network/ifstatenew ] && return 1
+
+    return 0
+}
+
 perf_options() {
     # At bootup lets set perfmode
-    [ -f /var/tmp/network/ifstatenew ] && echo -n "" && return
-
-    echo -n "--perfmode"
+    if is_bootup ; then
+       echo -n "--perfmode"
+    else
+       echo -n ""
+    fi
 }
 
 process_exclusions() {
@@ -139,12 +152,13 @@ start)
        exclusions=$(process_exclusions)
        perfoptions=$(perf_options)
        log_action_begin_msg "Configuring network interfaces"
-       if ifup -a $verbose $perfoptions
-       then
-           log_action_end_msg $?
+       if is_bootup ; then
+           ifup -a $verbose $perfoptions 2>&1 | /usr/bin/logger \
+                       $REMOTE_SYSLOG_SERVER -s -i -t $SCRIPTNAME
        else
-           log_action_end_msg $?
+           ifup -a $verbose $perfoptions
        fi
+       log_action_end_msg $?
        ;;
 
 stop)