DEVNAME=${DEVNAME##tnlcfg-}
if [[ "$CONFIG" = /* ]]; then
- if [ -f "$CONFIG" ] ; then
+ if [ -f "$CONFIG" ]; then
. "$CONFIG"
foundconfig=1
fi
- elif [ -f "/etc/sysconfig/interfaces/$CONFIG" ] ; then
+ elif [ -f "/etc/sysconfig/interfaces/$CONFIG" ]; then
. "/etc/sysconfig/interfaces/$CONFIG"
foundconfig=1
fi
if [ "$domain" ]; then
# XXX umask and possible /etc/resolv.conf symlink breakage
> /etc/resolv.conf.new
- if ! grep -q "search $domain" /etc/resolv.conf ; then
+ if ! grep -q "search $domain" /etc/resolv.conf; then
echo "search $domain" >> /etc/resolv.conf.new
fi
echo "domain $domain" >> /etc/resolv.conf.new
fi
if [ -z "$DHCP_CLIENT" ]; then
- if [ -x /sbin/dhcpcd ]; then
+ if [ "$BOOTPROTO" = "zeroconf" -a -x /usr/sbin/avahi-autoipd ]; then
+ DHCP_CLIENT=/usr/sbin/avahi-autoipd
+ elif [ -x /sbin/dhcpcd ]; then
DHCP_CLIENT=/sbin/dhcpcd
elif [ -x /sbin/dhclient ]; then
DHCP_CLIENT=/sbin/dhclient
DHCP_CLIENT=/sbin/dhcpxd
elif [ -x /sbin/pump ]; then
DHCP_CLIENT=/sbin/pump
+ elif [ "$BOOTPROTO" = "auto" -a -x /usr/sbin/avahi-autoipd ]; then
+ DHCP_CLIENT=/usr/sbin/avahi-autoipd
else
nls "Can't find a DHCP client."
exit 1
eval IP4ADDROPT="\$IP_AOPTS${IP4_PRIM_IF:-}"
eval IP4ROUTEOPT="\$IP_ROPTS${IP4_PRIM_IF:-}"
fi
- if [ "${IP6_PRIM_IF}" ] ; then
+ if [ "${IP6_PRIM_IF}" ]; then
eval IP6ADDR="\$IPADDR${IP6_PRIM_IF:-}"
eval IP6ADDROPT="\$IPV6_AOPTS${IP6_PRIM_IF:-}"
eval IP6ADDRLABEL="\$IP_LABEL${IP6_PRIM_IF:-}"
fi
- if [ "${IP4_SRC_IF}" ] ; then
+ if [ "${IP4_SRC_IF}" ]; then
eval IP4SRCADDR="\$IPADDR${IP4_SRC_IF}"
IP4SRCADDR=$(echo ${IP4SRCADDR} | awk ' { gsub(/\/.*/,NIL); print "src " $0; } ')
fi
fi
# ARP ready devices
- if [ "$ARP" ] ; then
+ if [ "$ARP" ]; then
if is_yes "$ARP"; then
ARP="arp on"
else
local args
if [ -f /etc/sysconfig/static-routes ]; then
- if [ "$1" = "on" -o "$1" = "yes" ] ; then
+ if [ "$1" = "on" -o "$1" = "yes" ]; then
grep -E "^(none|any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
/sbin/ip route add $args
done
done
fi
fi
+ is_no "$IPV6_NETWORKING" && return
+ if [ -f /etc/sysconfig/static-routes6 ]; then
+ if [ "$1" = "on" -o "$1" = "yes" ]; then
+ grep -E "^(none|any)[[:blank:]]" /etc/sysconfig/static-routes6 | while read device args; do
+ /sbin/ip -6 route add $args
+ done
+ else
+ grep -E "^(none|any)[[:blank:]]" /etc/sysconfig/static-routes6 | while read device args; do
+ /sbin/ip -6 route del $args 2>/dev/null
+ done
+ fi
+ fi
}
# Add ONLY IPv4 address (IPv6 address is added automaticly)
ip addr add 127.0.0.1/8 dev lo
fi
ip link set dev lo up
+ grep -E "^(lo|any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
+ if [[ "$args" = *:* ]]; then
+ is_no "$IPV6_NETWORKING" && continue
+ else
+ is_no "$IPV4_NETWORKING" && continue
+ fi
+ /sbin/ip route add $args dev lo
+ done
+ is_no "$IPV6_NETWORKING" && return
+ grep -E "^(lo|any)[[:blank:]]" /etc/sysconfig/static-routes6 | while read device args; do
+ /sbin/ip -6 route add $args dev lo
+ done
}
set_down_loopback()
modprobe_net()
{
- if is_yes "$IPV6_NETWORKING" && is_module "ipv6"; then
- _modprobe single ipv6
+ if is_yes "$IPV6_NETWORKING"; then
+ if is_module "ipv6"; then
+ _modprobe single ipv6
+ fi
+ elif [ -d /proc/sys/net/ipv6 ]; then
+ sysctl -w net.ipv6.conf.all.disable_ipv6=1
fi
if is_yes "$IPX" && is_module "ipx"; then
prefix=0
endp=0
- for n in $netmask ; do
- for i in 128 64 32 16 8 4 2 1 ; do
+ for n in $netmask; do
+ for i in 128 64 32 16 8 4 2 1; do
if [ $(($n & $i)) -ne 0 ]; then
if [ $endp -eq 0 ]; then
prefix=$(($prefix + 1))
fi
for i in 1 2 3 4; do
case $prefix in
- 7) a=254 ;;
- 6) a=252 ;;
- 5) a=248 ;;
- 4) a=240 ;;
- 3) a=224 ;;
- 2) a=192 ;;
- 1) a=128 ;;
+ 7) a=254;;
+ 6) a=252;;
+ 5) a=248;;
+ 4) a=240;;
+ 3) a=224;;
+ 2) a=192;;
+ 1) a=128;;
*)
[ $prefix -ge 8 ] && a=255
[ $prefix -le 0 ] && a=0
# Retrievies PPPD PID and real interface name from /var/run/ppp-*.pid
get_ppp_device_and_pid ()
{
- if [ -f "/var/run/ppp-$DEVNAME.pid" ] ; then
+ if [ -f "/var/run/ppp-$DEVNAME.pid" ]; then
eval $(
{
- read PID ; echo "PID='$PID'"
- read REALDEVICE ; echo "REALDEVICE=$REALDEVICE"
+ read PID; echo "PID='$PID'"
+ read REALDEVICE; echo "REALDEVICE=$REALDEVICE"
} < "/var/run/ppp-$DEVNAME.pid")
fi
- if [ -z "$REALDEVICE" ] ; then
+ if [ -z "$REALDEVICE" ]; then
REALDEVICE=$DEVICE
fi
}
{
local args prio from src
- if [ -f /etc/sysconfig/static-routes ] ; then
+ if [ -f /etc/sysconfig/static-routes ]; then
if is_yes "$1"; then
grep -E "^(from|to|iif|tos|fwmark|dev|pref|priority|prio)[[:blank:]]" /etc/sysconfig/static-routes | while read args; do
/sbin/ip rule add $args
done
elif is_no "$1"; then
LC_ALL=C /sbin/ip rule show | grep -vE -e "from all lookup (main|default|local) \$" -e " map-to " | while read prio from src args; do
- [ "$src" = "all" ] && ip rule delete $args || ip rule delete $from $src $args
+ [ "$src" = "all" ] && /sbin/ip rule delete $args || /sbin/ip rule delete $from $src $args
+ done
+ fi
+ fi
+ is_no "$IPV6_NETWORKING" && return
+ if [ -f /etc/sysconfig/static-routes6 ]; then
+ if is_yes "$1"; then
+ grep -E "^(from|to|iif|tos|fwmark|dev|pref|priority|prio)[[:blank:]]" /etc/sysconfig/static-routes6 | while read args; do
+ /sbin/ip -6 rule add $args
+ done
+ elif is_no "$1"; then
+ LC_ALL=C /sbin/ip -6 rule show | grep -vE -e "from all lookup (main|default|local) \$" -e " map-to " | while read prio from src args; do
+ [ "$src" = "all" ] && /sbin/ip -6 rule delete $args || /sbin/ip -6 rule delete $from $src $args
done
fi
fi
iwconfig ${device} txpower "$val"
val="$(eval echo \$${prefix}WLAN_RETRY)" && [ "$val" ] && \
iwconfig ${device} retry "$val"
- val="$(eval echo \$${prefix}WLAN_NWID)" && [ "$val" ] && \
- iwconfig ${device} nwid "$val"
# essid should be last due to network rescanning by wlan devices
val="$(eval echo \$${prefix}WLAN_ESSID)" && [ "$val" ] && \
check_iwconfig ()
{
local output
- [ -x /sbin/iwconfig ] || return 2
- output=$(LC_ALL=C iwconfig "$1" 2>&1)
- # "radio off" is ipwxxx only "feature" (and there is no "radio on")
- echo "$output" | grep -q "radio off" && return 0
# rfkill state (are there devices with multiple rfkill buttons?)
output=$(cat /sys/class/net/${1}/device/rfkill*/state 2> /dev/null)
# 1 is rfkill not active
[ "$output" = "1" ] && return 1
[ "$output" = "0" -o "$output" = "2" ] && return 0
+ [ -x /sbin/iwconfig ] || return 2
+ output=$(LC_ALL=C iwconfig "$1" 2>&1)
+ # "radio off" is ipwxxx only "feature" (and there is no "radio on")
+ echo "$output" | grep -q "radio off" && return 0
# XXX: need more generic checks for wifi
return 2
}
# returns
# 0 - link down
# 1 - link up
+# 2 - unknown/unsupported
check_link_down ()
{
- if [ -x /sbin/mii-tool -o -x /sbin/ethtool -o -x /sbin/iwconfig ]; then
- if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q UP ; then
- ip link set dev $1 up >/dev/null 2>&1
- timeout=0
- while [ $timeout -le 6 ]; do
- check_mii_tool $1
- m=$?
- check_ethtool $1
- e=$?
- check_iwconfig $1
- i=$?
- # trust ethtool and iwconfig
- if [ $i -eq 1 ] || [ $e -eq 1 ] ; then
- return 1
- fi
- # use mii check only if all other check are unsupported
- # (mii check lies too often)
- if [ $m -eq 1 ] && [ $i -eq 2 ] && [ $e -eq 2 ]; then
- return 1
- fi
- usleep 500000
- timeout=$((timeout+1))
- done
- # do not abort dhclient if all the checks are unsupported
- if [ $m -eq 2 ] && [ $i -eq 2 ] && [ $e -eq 2 ]; then
- return 2
- fi
- return 0
+ local e i m timeout device max_timeout
+ device="$1"
+ max_timeout="$2"
+
+ if [ ! -x /sbin/mii-tool -a ! -x /sbin/ethtool -a ! -x /sbin/iwconfig ]; then
+ return 2
+ fi
+
+ [ -z "$max_timeout" ] && max_timeout=6
+
+ if ! LC_ALL=C ip link show dev $device 2>/dev/null | grep -q UP; then
+ ip link set dev $device up >/dev/null 2>&1
+ fi
+ timeout=0
+ while [ $timeout -le $max_timeout ]; do
+ check_ethtool $device
+ e=$?
+ check_iwconfig $device
+ i=$?
+ # trust ethtool and iwconfig
+ if [ $i -eq 1 ] || [ $e -eq 1 ]; then
+ return 1
+ fi
+ # use mii check only if all other check are unsupported
+ # (mii check lies too often)
+ check_mii_tool $device
+ m=$?
+ if [ $m -eq 1 ] && [ $i -eq 2 ] && [ $e -eq 2 ]; then
+ return 1
fi
+ usleep 500000
+ timeout=$((timeout+1))
+ done
+ # do not abort dhclient if all the checks are unsupported
+ if [ $m -eq 2 ] && [ $i -eq 2 ] && [ $e -eq 2 ]; then
+ return 2
fi
- return 1
+ return 0
}