From c9a17f15501f539c49372ab99fe5484664f756e0 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Tue, 21 Nov 2017 03:38:45 +0100 Subject: rc.inet1: Factor DEBUG_ETH_UP logging to a separate function Signed-off-by: Robby Workman --- rc.inet1 | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/rc.inet1 b/rc.inet1 index 89c006f..7d5508f 100644 --- a/rc.inet1 +++ b/rc.inet1 @@ -22,6 +22,13 @@ else # output to stdout/stderr: LOGGER=/bin/cat fi +# Handy wrapper for verbose logging +debug_log() { + if [ "$DEBUG_ETH_UP" = "yes" ]; then + echo "/etc/rc.d/rc.inet1: $*" | $LOGGER + fi +} + ############################ # DETERMINE INTERFACE LIST # ############################ @@ -39,9 +46,7 @@ do IFNAME[$i]=${IFNAME[$i]:=eth${i}} i=$(($i+1)) done -if [ "$DEBUG_ETH_UP" = "yes" ]; then - echo "/etc/rc.d/rc.inet1: List of interfaces: '${IFNAME[*]}'" | $LOGGER -fi +debug_log "List of interfaces: '${IFNAME[*]}'" ###################### # LOOPBACK FUNCTIONS # @@ -140,9 +145,7 @@ if_up() { # If the interface isn't in the kernel yet (but there's an alias for it in # modules.conf), then it should be loaded first: if [ -z "${IPADDR[$i]}" ] && [ "${USE_DHCP[$i]}" != "yes" ]; then # skip unconfigured interfaces - if [ "$DEBUG_ETH_UP" = "yes" ]; then - echo "/etc/rc.d/rc.inet1: skipping ${1} early, interface is not configured in /etc/rc.d/rc.inet1.conf" | $LOGGER - fi + debug_log "skipping ${1} early, interface is not configured in /etc/rc.d/rc.inet1.conf" return 0 fi if ! grep $(echo ${1}: | cut -f 1 -d :): /proc/net/dev 1> /dev/null ; then # no interface yet @@ -228,20 +231,14 @@ if_up() { unset num fi else - if [ "$DEBUG_ETH_UP" = "yes" ]; then - echo "/etc/rc.d/rc.inet1: ${1} interface is not configured in /etc/rc.d/rc.inet1.conf" | $LOGGER - fi + debug_log "${1} interface is not configured in /etc/rc.d/rc.inet1.conf" fi fi else - if [ "$DEBUG_ETH_UP" = "yes" ]; then - echo "/etc/rc.d/rc.inet1: ${1} is already up, skipping" | $LOGGER - fi + debug_log "${1} is already up, skipping" fi else - if [ "$DEBUG_ETH_UP" = "yes" ]; then - echo "/etc/rc.d/rc.inet1: ${1} interface does not exist (yet)" | $LOGGER - fi + debug_log "${1} interface does not exist (yet)" fi } -- cgit v1.2.3