summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rc.inet126
1 files changed, 13 insertions, 13 deletions
diff --git a/rc.inet1 b/rc.inet1
index fbd9d59..3c9d5c2 100644
--- a/rc.inet1
+++ b/rc.inet1
@@ -75,7 +75,7 @@ lo_down() {
# Function to determine if virtual interfaces are defined
virtif_determine() {
- if [ ! -z ${VIRTIFNAME} ]; then
+ if [ -n "${VIRTIFNAME}" ]; then
virtifcount=$(($(echo ${VIRTIFNAME[@]} | wc -w) - 1))
else
return 1
@@ -138,7 +138,7 @@ if_up() {
[ -n "${BRNICS[$i]}" ] && br_open $i
# 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 [ "${IPADDR[$i]}" = "" ] && [ "${USE_DHCP[$i]}" != "yes" ]; then # skip unconfigured interfaces
+ 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
@@ -153,11 +153,11 @@ if_up() {
if grep $(echo ${1}: | cut -f 1 -d :): /proc/net/dev 1> /dev/null ; then # interface exists
if ! /sbin/ip addr show ${1} 2>/dev/null | grep -wq inet || \
! /sbin/ip link show dev ${1} | grep -wq "state UP" ; then # interface not up or not configured
- if [ ! "${HWADDR[$i]}" = "" ]; then # Set hardware address _before_ the interface goes up:
+ if [ -n "${HWADDR[$i]}" ]; then # Set hardware address _before_ the interface goes up:
echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} address ${HWADDR[$i]}" | $LOGGER
/sbin/ip link set dev ${1} address ${HWADDR[$i]}
fi
- if [ ! "${MTU[$i]}" = "" ]; then # Set MTU to something else than 1500
+ if [ -n "${MTU[$i]}" ]; then # Set MTU to something else than 1500
echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} mtu ${MTU[$i]}" | $LOGGER
/sbin/ip link set dev ${1} mtu ${MTU[$i]}
fi
@@ -171,13 +171,13 @@ if_up() {
# Clear DHCP_OPTIONS before adding new options to it:
unset DHCP_OPTIONS
# Set DHCP_OPTIONS for this interface:
- [ ${DHCP_HOSTNAME[$i]} ] && DHCP_OPTIONS="-h ${DHCP_HOSTNAME[$i]}"
+ [ -n "${DHCP_HOSTNAME[$i]}" ] && DHCP_OPTIONS="-h ${DHCP_HOSTNAME[$i]}"
[ "${DHCP_KEEPRESOLV[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -C resolv.conf"
[ "${DHCP_KEEPNTP[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -C ntp.conf"
[ "${DHCP_KEEPGW[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -G"
[ "${DHCP_DEBUG[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -d"
[ "${DHCP_NOIPV4LL[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -L"
- [ ${DHCP_IPADDR[$i]} ] && DHCP_OPTIONS="$DHCP_OPTIONS -r ${DHCP_IPADDR[$i]}"
+ [ -n "${DHCP_IPADDR[$i]}" ] && DHCP_OPTIONS="$DHCP_OPTIONS -r ${DHCP_IPADDR[$i]}"
echo "Polling for DHCP server on interface ${1}:"
# If you set a timeout, you get one, even if the kernel doesn't think that
# your device is connected, in case /sys isn't right (which it usually isn't
@@ -185,7 +185,7 @@ if_up() {
#### (start commented out)
# This is deactivated for now since the kernel has been returning incorrect
# results concerning whether the interface carrier is detected.
- #if [ "${DHCP_TIMEOUT[$i]}" = "" ]; then
+ #if [ -z "${DHCP_TIMEOUT[$i]}" ]; then
# /sbin/ip link set dev ${1} up && sleep 1
# CONNSTATUS="$(cat /sys/class/net/${1}/carrier 2> /dev/null)"
# /sbin/ip link set dev ${1} down
@@ -201,7 +201,7 @@ if_up() {
echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -L -t ${DHCP_TIMEOUT[$i]:-15} ${DHCP_OPTIONS} ${1}" | $LOGGER
/sbin/dhcpcd -L -t ${DHCP_TIMEOUT[$i]:-15} ${DHCP_OPTIONS} ${1}
# If the dhcpcd call succeeds, add extra IP addresses, if defined, to interface
- if [ "$?" == "0" ] && [ ! -z "${IPALIASES[$1]}" ]; then
+ if [ "$?" == "0" ] && [ -n "${IPALIASES[$1]}" ]; then
num=0
for ipalias in $(echo ${IPALIASES[$i]}); do
/sbin/ip address add ${ipalias}/32 dev ${1} label ${1}:${num} ;
@@ -210,7 +210,7 @@ if_up() {
unset num
fi
else # bring up interface using a static IP address
- if [ ! "${IPADDR[$i]}" = "" ]; then # skip unconfigured interfaces
+ if [ -n "${IPADDR[$i]}" ]; then # skip unconfigured interfaces
# Set up the network card:
echo "/etc/rc.d/rc.inet1: /sbin/ip address add ${IPADDR[$i]}/${NETMASK[$i]} dev ${1}" | $LOGGER
/sbin/ip address add ${IPADDR[$i]}/${NETMASK[$i]} dev ${1}
@@ -218,7 +218,7 @@ if_up() {
/sbin/ip link set dev ${1} up # Bring up interface
fi
# Add extra IP addresses, if defined, to interface
- if [ ! -z "${IPALIASES[$i]}" ]; then
+ if [ -n "${IPALIASES[$i]}" ]; then
num=0
for ipalias in $(echo ${IPALIASES[$i]}); do
/sbin/ip address add ${ipalias}/32 dev ${1} label ${1}:${num} ;
@@ -278,7 +278,7 @@ if_down() {
# Function to bring up the gateway if there is not yet a default route:
gateway_up() {
if ! /sbin/ip route show | grep -wq default ; then
- if [ ! "$GATEWAY" = "" ]; then
+ if [ -n "$GATEWAY" ]; then
echo "/etc/rc.d/rc.inet1: /sbin/ip route add default via ${GATEWAY}" | $LOGGER
/sbin/ip route add default via ${GATEWAY} | $LOGGER
fi
@@ -297,7 +297,7 @@ gateway_down() {
start() {
lo_up
virtif_determine && virtif_create
- for i in ${IFNAME[@]} ; do
+ for i in "${IFNAME[@]}" ; do
if_up $i
done
gateway_up
@@ -306,7 +306,7 @@ start() {
# Function to stop the network:
stop() {
gateway_down
- for i in ${IFNAME[@]} ; do
+ for i in "${IFNAME[@]}" ; do
if_down $i
done
virtif_determine && virtif_destroy