From 66d26269a83229b7340f7ace06dfc715c04df7d8 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Thu, 12 Sep 2019 12:32:36 +0200 Subject: Repalace hardcoded tests for yes and no with testing functions Resolve issue: #42 --- etc/rc.d/init.d/network | 10 ++++------ network-scripts/ifdown-eth | 8 ++++---- network-scripts/ifdown-ipv6 | 4 ++-- network-scripts/ifup | 10 +++++----- network-scripts/ifup-aliases | 12 ++++++------ network-scripts/ifup-eth | 10 +++++----- network-scripts/ifup-ippp | 40 +++++++++++++++++++-------------------- network-scripts/ifup-ipv6 | 20 ++++++++++---------- network-scripts/init.ipv6-global | 12 ++++++------ network-scripts/network-functions | 4 ++-- usr/libexec/readonly-root | 4 ++-- 11 files changed, 66 insertions(+), 68 deletions(-) diff --git a/etc/rc.d/init.d/network b/etc/rc.d/init.d/network index e3560b64..414bee06 100755 --- a/etc/rc.d/init.d/network +++ b/etc/rc.d/init.d/network @@ -28,7 +28,7 @@ fi # Check that networking is up. -[ "${NETWORKING}" = "no" ] && exit 6 +is_false "${NETWORKING}" && exit 6 # if the ip configuration utility isn't around we can't function. [ -x /sbin/ip ] || exit 1 @@ -76,13 +76,11 @@ start) # bring up loopback interface action $"Bringing up loopback interface: " ./ifup ifcfg-lo - case "$VLAN" in - yes) + if is_true "$VLAN" ; then if [ ! -d /proc/net/vlan ] && ! modprobe 8021q >/dev/null 2>&1 ; then net_log $"No 802.1Q VLAN support available in kernel." fi - ;; - esac + fi vlaninterfaces="" vpninterfaces="" @@ -99,7 +97,7 @@ start) if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi - if [ "$SLAVE" = "yes" ] && ( ! is_nm_running || is_false $NM_CONTROLLED ) ; then + if is_true "$SLAVE" && ( ! is_nm_running || is_false "$NM_CONTROLLED" ) ; then continue fi diff --git a/network-scripts/ifdown-eth b/network-scripts/ifdown-eth index c610fd20..7b457e85 100755 --- a/network-scripts/ifdown-eth +++ b/network-scripts/ifdown-eth @@ -29,13 +29,13 @@ source_config . /etc/sysconfig/network # Check to make sure the device is actually up -check_device_down ${DEVICE} && [ "$BOOTPROTO" != "dhcp" -a "$BOOTPROTO" != "bootp" ] && [ -n "$VLAN" -a "$VLAN" != "yes" ] && exit 0 +check_device_down ${DEVICE} && [ "$BOOTPROTO" != "dhcp" -a "$BOOTPROTO" != "bootp" ] && [ -n "$VLAN" ] && ! is_true "$VLAN" && exit 0 if [ -n "${TEAM_MASTER}" ] && [ ! "${DEVICETYPE}" = "TeamPort" ] && [ -x ./ifdown-TeamPort ]; then ./ifdown-TeamPort ${CONFIG} $2 fi -if [ "${SLAVE}" != "yes" -o -z "${MASTER}" ]; then +if ! is_true "${SLAVE}" || [ -z "${MASTER}" ]; then if [ -n "${HWADDR}" -a -z "${MACADDR}" ]; then FOUNDMACADDR=$(get_hwaddr ${REALDEVICE}) if [ -n "${FOUNDMACADDR}" -a "${FOUNDMACADDR}" != "${HWADDR}" ]; then @@ -125,7 +125,7 @@ if [ -d "/sys/class/net/${REALDEVICE}" ]; then ip -4 addr flush dev ${REALDEVICE} ${LABEL} scope host 2>/dev/null fi - if [ "${SLAVE}" = "yes" -a -n "${MASTER}" ]; then + if is_true "${SLAVE}" && [ -n "${MASTER}" ]; then echo "-${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null fi @@ -167,7 +167,7 @@ if [ -n "${WIRELESS_ENC_KEY}" ] && [ -x /sbin/iwconfig ]; then /sbin/iwconfig ${DEVICE} enc 0 >/dev/null 2>&1 fi -if [ "$retcode" = 0 ] ; then +if [ "$retcode" = "0" ]; then /etc/sysconfig/network-scripts/ifdown-post $CONFIG # do NOT use $? because ifdown should return whether or not # the interface went down. diff --git a/network-scripts/ifdown-ipv6 b/network-scripts/ifdown-ipv6 index 7ba3efdc..5bc08d31 100755 --- a/network-scripts/ifdown-ipv6 +++ b/network-scripts/ifdown-ipv6 @@ -62,7 +62,7 @@ if [ $? != 0 -a $? != 11 ]; then exit 1 fi -if [ ! "$IPV6_SET_SYSCTLS" = "no" ]; then +if ! is_false "$IPV6_SET_SYSCTLS"; then # Switch some sysctls to secure mode /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.forwarding=0 >/dev/null 2>&1 /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.accept_ra=0 >/dev/null 2>&1 @@ -119,7 +119,7 @@ if [ $? = 0 -o $? = 11 ]; then fi # Shutdown of 6to4, if configured -if [ "$valid6to4config" = "yes" ]; then +if is_true "$valid6to4config"; then if [ -n "$IPV6TO4_ROUTING" ]; then # Delete routes to local networks for devsuf in $IPV6TO4_ROUTING; do diff --git a/network-scripts/ifup b/network-scripts/ifup index 397dd93b..9c1380bb 100755 --- a/network-scripts/ifup +++ b/network-scripts/ifup @@ -58,11 +58,11 @@ if ! is_true ${DEPRECATION_WARNING_ISSUED}; then net_log $"It is advised to switch to 'NetworkManager' instead - it provides 'ifup/ifdown' scripts as well." warning ifup >&2 fi -if [ "foo$2" = "fooboot" ] && [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ] +if [ "foo$2" = "fooboot" ] && is_false "${ONBOOT}" then exit 0 fi -if [ -n "$IN_HOTPLUG" ] && [ "${HOTPLUG}" = "no" -o "${HOTPLUG}" = "NO" ] +if [ -n "$IN_HOTPLUG" ] && is_false "${HOTPLUG}" then exit 0 fi @@ -81,7 +81,7 @@ if [ "$_use_nm" = "true" -a -n "$UUID" -a "$REALDEVICE" != "lo" ]; then fi # Ethernet 802.1Q VLAN support -if [ "${VLAN}" = "yes" ] && [ "$ISALIAS" = "no" ] && [ -n "$DEVICE" ]; then +if is_true "${VLAN}" && is_false "$ISALIAS" && [ -n "$DEVICE" ]; then if [ -n "${VID}" ]; then if test -z "$PHYSDEV"; then net_log $"PHYSDEV should be set for device ${DEVICE}" @@ -125,11 +125,11 @@ if [ "${VLAN}" = "yes" ] && [ "$ISALIAS" = "no" ] && [ -n "$DEVICE" ]; then check_device_down ${PHYSDEV} && { ip -o link set dev ${PHYSDEV} up; } if [ ! -f /proc/net/vlan/${DEVICE} ]; then - if [ "${REORDER_HDR}" = "no" -o "${REORDER_HDR}" = "0" ]; then + if is_false "${REORDER_HDR}"; then FLAG_REORDER_HDR="reorder_hdr off" fi - if [ "${GVRP}" = "yes" -o "${GVRP}" = "1" ]; then + if is_true "${GVRP}"; then FLAG_GVRP="gvrp on" fi diff --git a/network-scripts/ifup-aliases b/network-scripts/ifup-aliases index 8a943c1b..8020f407 100755 --- a/network-scripts/ifup-aliases +++ b/network-scripts/ifup-aliases @@ -206,7 +206,7 @@ function new_interface () eval $(/bin/ipcalc --broadcast ${IPADDR}/${PREFIX}) fi - if [ "$no_devices_are_up" = "yes" ]; then + if is_true "$no_devices_are_up"; then setup_this=yes else @@ -262,8 +262,8 @@ function new_interface () /sbin/ip addr change ${IPADDR}/${PREFIX} brd ${BROADCAST} fi - if [ "$setup_this" = "yes" ] ; then - if [ "${parent_device}" != "lo" ] && [ "${ARPCHECK}" != "no" ] && \ + if is_true "$setup_this"; then + if [ "${parent_device}" != "lo" ] && ! is_false "${ARPCHECK}" && \ is_available ${parent_device} && \ ( grep -qswi "up" /sys/class/net/${parent_device}/operstate || grep -qswi "1" /sys/class/net/${parent_device}/carrier ) ; then echo $"Determining if ip address ${IPADDR} is already in use for device ${parent_device}..." @@ -287,7 +287,7 @@ function new_interface () ! is_false "$IPV6INIT" && \ /etc/sysconfig/network-scripts/ifup-ipv6 ${DEVICE} - if [ "$NO_ALIASROUTING" != yes ]; then + if ! is_true "$NO_ALIASROUTING"; then GATEWAYDEV=$network_GATEWAYDEV; @@ -317,7 +317,7 @@ for FILE in ifcfg-${parent_device}:* ; do ini_env . ./$FILE [ -z "$DEVICE" ] && DEVICE=${FILE##ifcfg-} - [ "$ONPARENT" != "no" -a "$ONPARENT" != "NO" ] && new_interface + ! is_false "$ONPARENT" && new_interface unset DEVICE done @@ -347,7 +347,7 @@ for FILE in ifcfg-${parent_device}-range* ; do IPADDR="$ipaddr_prefix.$ipaddr_num" DEVICE="$parent_device:$ipaddr_clonenum" IPV6INIT="no" - [ "$ONPARENT" != "no" -a "$ONPARENT" != "NO" ] && new_interface + ! is_false "$ONPARENT" && new_interface ipaddr_num=$(($ipaddr_num+1)) ipaddr_clonenum=$(($ipaddr_clonenum+1)) done diff --git a/network-scripts/ifup-eth b/network-scripts/ifup-eth index b559b5c4..178b5173 100755 --- a/network-scripts/ifup-eth +++ b/network-scripts/ifup-eth @@ -149,7 +149,7 @@ if [ -n "${TEAM_MASTER}" ] && [ ! "${DEVICETYPE}" = "TeamPort" ] && [ -x ./ifup- fi # slave device? -if [ "${SLAVE}" = yes -a "${ISALIAS}" = no -a "${MASTER}" != "" ]; then +if is_true "${SLAVE}" && is_false "${ISALIAS}" && [ -n "${MASTER}" ]; then install_bonding_driver ${MASTER} grep -wq "${DEVICE}" /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null || { /sbin/ip link set dev ${DEVICE} down @@ -162,7 +162,7 @@ fi # Bonding initialization. For DHCP, we need to enslave the devices early, # so it can actually get an IP. -if [ "$ISALIAS" = no ] && is_bonding_device ${DEVICE} ; then +if is_false "$ISALIAS" && is_bonding_device ${DEVICE}; then install_bonding_driver ${DEVICE} /sbin/ip link set dev ${DEVICE} up for device in $(LANG=C grep -l "^[[:space:]]*MASTER=['\"]\?${DEVICE}['\"]\?\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-*) ; do @@ -281,7 +281,7 @@ else fi if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${ipaddr[$idx]}/${prefix[$idx]}" ; then - if [ "${REALDEVICE}" != "lo" ] && [ "${arpcheck[$idx]}" != "no" ] ; then + if [ "${REALDEVICE}" != "lo" ] && ! is_false "${arpcheck[$idx]}"; then ARPING=$(/sbin/arping -c 2 -w ${ARPING_WAIT:-3} -D -I ${REALDEVICE} ${ipaddr[$idx]}) if [ $? = 1 ]; then ARPINGMAC=$(echo $ARPING | sed -ne 's/.*\[\(.*\)\].*/\1/p') @@ -312,7 +312,7 @@ else done # Set a default route. - if [ "${DEFROUTE}" != "no" ] && [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${REALDEVICE}" ]; then + if ! is_false "${DEFROUTE}" && [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${REALDEVICE}" ]; then # set up default gateway. replace if one already exists if [ -n "${GATEWAY}" ] && [ "$(ipcalc --network ${GATEWAY} ${netmask[0]} 2>/dev/null)" = "NETWORK=${NETWORK}" ]; then ip route replace default ${METRIC:+metric $METRIC} \ @@ -331,7 +331,7 @@ else fi # Add Zeroconf route. -if [ -z "${NOZEROCONF}" -a "${ISALIAS}" = "no" -a "${REALDEVICE}" != "lo" ]; then +if [ -z "${NOZEROCONF}" ] && is_false "${ISALIAS}" && [ "${REALDEVICE}" != "lo" ]; then ip route add 169.254.0.0/16 dev ${REALDEVICE} metric $((1000 + $(cat /sys/class/net/${REALDEVICE}/ifindex))) scope link fi diff --git a/network-scripts/ifup-ippp b/network-scripts/ifup-ippp index e1f08a79..b8df7c07 100755 --- a/network-scripts/ifup-ippp +++ b/network-scripts/ifup-ippp @@ -106,16 +106,16 @@ function addprovider() [ -z "$GATEWAY" ] && GATEWAY="0.0.0.0" # set default route - [ "$DEFROUTE" = "yes" ] && options="$options defaultroute deldefaultroute" + is_true "$DEFROUTE" && options="$options defaultroute deldefaultroute" # set authentication _auth=$(echo "$AUTH" | sed 's/[a-z -]*//g') if [ -n "$_auth" ]; then - if [ -z "$USER" -a "$DIALIN" != "on" ]; then + if [ -z "$USER" ] && ! is_true "$DIALIN"; then log_echo " Error: $1 (syncppp) user is not set" return 1 fi - if [ "$DIALIN" != "on" ]; then + if ! is_true "$DIALIN"; then # we should hide the user name, so i add user name to option file. if [ "$AUTH" = "-pap +chap" ]; then create_option_file "name \"$USER\"" @@ -128,7 +128,7 @@ function addprovider() # authentication options: # +pap and/or +chap does not work correct by dialout - remove # them if it's configured as dialout - [ "$DIALIN" = "on" ] || AUTH=$(echo "$AUTH" | sed 's/+[a-z]*//g') + is_true "$DIALIN" || AUTH=$(echo "$AUTH" | sed 's/+[a-z]*//g') fi # add ISDN device @@ -187,7 +187,7 @@ function addprovider() if [ "$IPADDR" = "0.0.0.0" ]; then options="$options ipcp-accept-local" else - if [ "$DIALIN" != "on" ]; then + if ! is_true "$DIALIN"; then options="$options noipdefault" fi fi @@ -195,7 +195,7 @@ function addprovider() options="$options /dev/$DEVICE" # set channel bundling - if [ "$BUNDLING" = "yes" -o "$BUNDLING" = "on" ] && [ -n "$SLAVE_DEVICE" ]; then + if is_true "$BUNDLING" && [ -n "$SLAVE_DEVICE" ]; then [ -z "$SLAVE_MSN" ] && SLAVE_MSN="$MSN" [ -z "$SLAVE_PHONE_OUT" ] && SLAVE_PHONE_OUT="$PHONE_OUT" [ -z "$SLAVE_PHONE_IN" ] && SLAVE_PHONE_IN="$PHONE_IN" @@ -207,7 +207,7 @@ function addprovider() [ -z "$SLAVE_DIALMAX" ] && SLAVE_DIALMAX="$DIALMAX" [ -z "$SLAVE_CALLBACK" ] && SLAVE_CALLBACK="$CALLBACK" [ -z "$SLAVE_CBDELAY" ] && SLAVE_CBDELAY="$CBDELAY" - if [ "$DIALIN" != "on" ] ; then + if ! is_true "$DIALIN"; then [ -z "$SLAVE_DIALMODE" ] && SLAVE_DIALMODE="auto" else # Master should not dial by default on incoming MPPP @@ -258,7 +258,7 @@ function addprovider() fi if [ "$GATEWAY" = "0.0.0.0" ]; then - if [ "$DIALIN" != "on" ]; then + if ! is_true "$DIALIN"; then options="$options ipcp-accept-remote" fi options="$IPADDR:$GATEWAY $options" @@ -268,21 +268,21 @@ function addprovider() # Van Jacobson style TCP/IP header compression and # VJ connection-ID compression - [ "$VJ" = "off" ] && options="$options -vj" - [ "$VJCCOMP" = "off" ] && options="$options -vjccomp" + is_false "$VJ" && options="$options -vj" + is_false "$VJCCOMP" && options="$options -vjccomp" # Address/Control compression, protocol field compression, - [ "$AC" = "off" ] && options="$options -ac" - [ "$PC" = "off" ] && options="$options -pc" + is_false "$AC" && options="$options -ac" + is_false "$PC" && options="$options -pc" # BSD-Compression scheme - if [ "$BSDCOMP" = "on" ] ; then + if is_true "$BSDCOMP"; then options="$options bsdcomp 9,9" else options="$options -bsdcomp" fi # Stac compression - if [ "$LZS" = "on" ] ; then + if is_true "$LZS"; then # supports LZS check mode 3 and 4 [ -n "$LZS_MODE" ] || LZS_MODE="4" [ "$LZS_MODE" = "3" ] && options="$options lzs 1" @@ -294,7 +294,7 @@ function addprovider() [ -n "$MTU" ] && options="$options mtu $MTU" # set CBCP protocoll - if [ "$CBCP" = "on" ] ; then + if is_true "$CBCP"; then if [ -n "$CBCP_MSN" ] ; then # User managed callback options="$options callback $CBCP_MSN" @@ -308,7 +308,7 @@ function addprovider() fi # set CCP protocoll - [ "$CCP" = "off" ] && options="$options noccp" + is_false "$CCP" && options="$options noccp" # set host name [ -n "$ISDN_HOSTNAME" ] && options="$options remotename $ISDN_HOSTNAME" @@ -332,7 +332,7 @@ function addprovider() fi # set debug - [ "$DEBUG" = "yes" ] && options="-d $options" + is_true "$DEBUG" && options="-d $options" # set netmask, if available [ -n "$NETMASK" ] && { @@ -350,15 +350,15 @@ function addprovider() ipppd $options $netmask >/dev/null 2>&1 # start ibod daemon - if [ "$DIALIN" != "on" ]; then - [ "$BUNDLING" = "yes" -o "$BUNDLING" = "on" ] && [ -n "$SLAVE_DEVICE" ] && start_ibod $DEVICE + if ! is_true "$DIALIN"; then + is_true "$BUNDLING" && [ -n "$SLAVE_DEVICE" ] && start_ibod $DEVICE fi fi # set default gateway for dial on demand if [ "$DIALMODE" = "auto" ] ; then echo 1 > /proc/sys/net/ipv4/ip_dynaddr - if [ "$DEFROUTE" = "yes" ] ; then + if is_true "$DEFROUTE" ; then if [ "$GATEWAY" = "0.0.0.0" ]; then ip route replace default ${METRIC:+metric $METRIC} dev ${DEVICE} >/dev/null 2>&1 else diff --git a/network-scripts/ifup-ipv6 b/network-scripts/ifup-ipv6 index ecbe5b79..55762264 100755 --- a/network-scripts/ifup-ipv6 +++ b/network-scripts/ifup-ipv6 @@ -91,7 +91,7 @@ fi ipv6_global_forwarding_current="$(/sbin/sysctl -e -n net.ipv6.conf.all.forwarding)" # Set some proc switches depending on defines -if [ "$IPV6FORWARDING" = "yes" ]; then +if is_true "$IPV6FORWARDING"; then # Global forwarding should be enabled # Check, if global IPv6 forwarding was already set by global script @@ -103,10 +103,10 @@ if [ "$IPV6FORWARDING" = "yes" ]; then ipv6_local_forwarding=1 ipv6_local_auto=0 ipv6_local_accept_ra=0 - if [ "$IPV6_ROUTER" = "no" ]; then + if is_false "$IPV6_ROUTER"; then ipv6_local_forwarding=0 fi - if [ "$IPV6_AUTOCONF" = "yes" ]; then + if is_true "$IPV6_AUTOCONF"; then ipv6_local_auto=1 ipv6_local_accept_ra=2 fi @@ -122,15 +122,15 @@ else ipv6_local_forwarding=0 ipv6_local_auto=1 ipv6_local_accept_ra=1 - if [ "$IPV6_AUTOCONF" = "no" ]; then + if is_false "$IPV6_AUTOCONF"; then ipv6_local_auto=0 - if [ ! "$IPV6_FORCE_ACCEPT_RA" = "yes" ]; then + if ! is_true "$IPV6_FORCE_ACCEPT_RA"; then ipv6_local_accept_ra=0 fi fi fi -if [ ! "$IPV6_SET_SYSCTLS" = "no" ]; then +if ! is_false "$IPV6_SET_SYSCTLS"; then /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.forwarding=$ipv6_local_forwarding >/dev/null 2>&1 /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.accept_ra=$ipv6_local_accept_ra >/dev/null 2>&1 /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.accept_redirects=$ipv6_local_auto >/dev/null 2>&1 @@ -151,7 +151,7 @@ fi # Enable IPv6 RFC3041 privacy extensions if desired if [ "$IPV6_PRIVACY" = "rfc3041" ]; then - if [ ! "$IPV6_SET_SYSCTLS" = "no" ]; then + if ! is_false "$IPV6_SET_SYSCTLS"; then /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.use_tempaddr=2 >/dev/null 2>&1 if [ $? -ne 0 ]; then net_log $"Cannot enable IPv6 privacy method '$IPV6_PRIVACY', not supported by kernel" @@ -172,7 +172,7 @@ if [ -f /etc/sysconfig/static-routes-ipv6 ]; then fi # Setup of 6to4, if configured -if [ "$IPV6TO4INIT" = "yes" ]; then +if is_true "$IPV6TO4INIT"; then valid6to4config="yes" # Test device status of 6to4 tunnel @@ -224,7 +224,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then fi # Setup 6to4 tunnel (hardwired name is "tun6to4"), if config is valid - if [ "$valid6to4config" = "yes" ]; then + if is_true "$valid6to4config"; then # Get MTU of master device ipv4mtu="$(/sbin/ip link show dev $DEVICE | awk '/\/ { print $5 }')" if [ -n "$ipv4mtu" ]; then @@ -281,7 +281,7 @@ if [ "$IPV6TO4INIT" = "yes" ]; then /sbin/ip -6 route del ::/96 dev tun6to4 /sbin/ip -6 addr del "::$ipv4addrlocal/128" dev tun6to4 - if [ "$IPV6_CONTROL_RADVD" = "yes" ]; then + if is_true "$IPV6_CONTROL_RADVD"; then # RADVD is in use, so forwarding of IPv6 packets should be enabled, display warning if [ $ipv6_global_forwarding_current -ne 1 ]; then net_log $"Using 6to4 and RADVD IPv6 forwarding usually should be enabled, but it isn't" warning diff --git a/network-scripts/init.ipv6-global b/network-scripts/init.ipv6-global index b20ff72e..0940962d 100755 --- a/network-scripts/init.ipv6-global +++ b/network-scripts/init.ipv6-global @@ -48,19 +48,19 @@ start) # IPv6 test, module loaded, exit if system is not IPv6-ready ipv6_test || exit 1 - if [ "$IPV6FORWARDING" = "yes" ]; then + if is_true "$IPV6FORWARDING"; then ipv6_global_forwarding=1 ipv6_global_auto=0 else ipv6_global_forwarding=0 - if [ "$IPV6_AUTOCONF" = "no" ]; then + if is_false "$IPV6_AUTOCONF"; then ipv6_global_auto=0 else ipv6_global_auto=1 fi fi - if [ ! "$IPV6_SET_SYSCTLS" = "no" ]; then + if ! is_false "$IPV6_SET_SYSCTLS"; then # Reset IPv6 sysctl switches for "all", "default" and still existing devices for i in /proc/sys/net/ipv6/conf/* ; do interface=${i##*/} @@ -79,7 +79,7 @@ start) # IPv6 test, module loaded, exit if system is not IPv6-ready ipv6_test || exit 1 - if [ "$IPV6_AUTOTUNNEL" = "yes" ]; then + if is_true "$IPV6_AUTOTUNNEL"; then ipv6_enable_autotunnel # autotunnel interface doesn't require a MTU setup fi @@ -103,7 +103,7 @@ start) /sbin/ip route add unreach 3ffe:ffff::/32 # Set default route for autotunnel, if specified - if [ "$IPV6_DEFAULTDEV" = "sit0" -a "$IPV6_AUTOTUNNEL" = "yes" ]; then + if [ "$IPV6_DEFAULTDEV" = "sit0" ] && is_true "$IPV6_AUTOTUNNEL"; then if [ -n "$IPV6_DEFAULTGW" ]; then ipv6_set_default_route $IPV6_DEFAULTGW $IPV6_DEFAULTDEV sit0 elif [ -n "$IPV6_DEFAULTDEV" ]; then @@ -128,7 +128,7 @@ stop) # IPv6 test, no module loaded, exit if system is not IPv6-ready ipv6_test testonly || exit 0 - if [ ! "$IPV6_SET_SYSCTLS" = "no" ]; then + if ! is_false "$IPV6_SET_SYSCTLS"; then for i in /proc/sys/net/ipv6/conf/* ; do interface=${i##*/} sinterface=${interface/.//} diff --git a/network-scripts/network-functions b/network-scripts/network-functions index 614ad490..5c6c3265 100644 --- a/network-scripts/network-functions +++ b/network-scripts/network-functions @@ -270,9 +270,9 @@ expand_config () toggle_value () { - if [ "$2" = "yes" -o "$2" = "YES" ] ; then + if is_true "$2"; then echo "$1 on" - elif [ "$2" = "no" -o "$2" = "NO" ] ; then + elif is_false "$2"; then echo "$1 off" else echo '' diff --git a/usr/libexec/readonly-root b/usr/libexec/readonly-root index a3679580..9b9c2824 100755 --- a/usr/libexec/readonly-root +++ b/usr/libexec/readonly-root @@ -43,7 +43,7 @@ if strstr "$cmdline" noreadonlyroot ; then fi MOUNTS=() -if [ "$READONLY" = "yes" -o "$TEMPORARY_STATE" = "yes" ]; then +if is_true "$READONLY" || is_true "$TEMPORARY_STATE"; then add_mount() { mnt=${1%/} @@ -80,7 +80,7 @@ if [ "$READONLY" = "yes" -o "$TEMPORARY_STATE" = "yes" ]; then rw_mount_dev=$(blkid -t LABEL="$RW_LABEL" -l -o device) bindmountopts= - [ "$SLAVE_MOUNTS" = "yes" ] && bindmountopts="--make-slave" + is_true "$SLAVE_MOUNTS" && bindmountopts="--make-slave" # First try to mount scratch storage from /etc/fstab, then any # partition with the proper label. If either succeeds, be sure -- cgit v1.2.1