summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Jankowski <shasta@toxcorp.com>2017-11-21 03:38:45 +0100
committerRobby Workman <rworkman@slackware.com>2017-11-21 00:07:59 -0600
commitc9a17f15501f539c49372ab99fe5484664f756e0 (patch)
tree44e7b2f15444b0245291e70b92099f623a728b15
parente21625c5bb1b03cad355590021c95009ab4246c5 (diff)
downloadslacknetsetup-c9a17f15501f539c49372ab99fe5484664f756e0.tar.xz
rc.inet1: Factor DEBUG_ETH_UP logging to a separate function
Signed-off-by: Robby Workman <rworkman@slackware.com>
-rw-r--r--rc.inet127
1 files 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
}