]> git.pld-linux.org Git - projects/rc-scripts.git/blame - sysconfig/network-scripts/functions.network
Delay (or even skip) clock setting if /dev/rtc doesn't exist.
[projects/rc-scripts.git] / sysconfig / network-scripts / functions.network
CommitLineData
356d834b 1#!/bin/sh - keep it for file(1) to get bourne shell script result
b0443108 2#
ec8b15cb 3# $Id$
5e6dfc29 4#
7e04fe0e 5# This is not a shell script; it provides functions to network scripts
6# that source it.
7
8source_config ()
9{
1377630a 10 DEVNAME=${CONFIG##*/ifcfg-}
5e6dfc29 11
1377630a 12 if [[ "$CONFIG" = /* ]]; then
5e6dfc29
JR
13 if [ -f "$CONFIG" ] ; then
14 . "$CONFIG"
15 fi
16 elif [ -f "/etc/sysconfig/interfaces/$CONFIG" ] ; then
17 . "/etc/sysconfig/interfaces/$CONFIG"
18 fi
d100991e
ER
19
20 # This is sanity check so that if you've copied ifcfg-eth0 to ifcfg-eth1
21 # and forgot to alter DEVICE= line you won't accidentally bring down eth0
22 # while executing ifdown eth1.
23 if [ -n "$DEVICE" -a "$DEVNAME" != "$DEVICE" ]; then
24 echo >&2 "$0: DEVICE specified in $CONFIG does not match filename. Aborting!"
25 exit 1
26 fi
27
1377630a 28 if [ -n "${PREFIX}" ] && [[ "$IPADDR" != */* ]]; then
5e6dfc29
JR
29 IPADDR="$IPADDR/$PREFIX"
30 fi
7e04fe0e 31}
32
33do_netreport ()
34{
5e6dfc29
JR
35 # Notify programs that have requested notification
36 ( cd /var/run/netreport || exit
37 for i in * ; do
38 [ -f $i ] && kill -SIGIO $i >/dev/null 2>&1 || \
39 rm -f $i >/dev/null 2>&1
40 done
41 )
7e04fe0e 42}
43
44need_hostname()
45{
5411f833
ER
46 local hostname=$(hostname)
47 if [ "$hostname" = "(none)" -o "$hostname" = "localhost" -o \
48 "$hostname" = "localhost.localdomain" ]; then
5e6dfc29
JR
49 NEEDHOSTNAME=yes
50 else
51 unset NEEDHOSTNAME
52 fi
7e04fe0e 53}
54
55set_hostname()
56{
5e6dfc29
JR
57 typeset hostname domain
58
59 hostname=$(echo $1 | awk ' { gsub(/\..*$/,NIL); print $0; } ')
60 domain=$(echo $1 | awk ' { sub(/^[^\.]*\./,NIL); print $0; } ')
61
62 if [ -n "$hostname" ] ; then
63 echo "$hostname" > /etc/HOSTNAME
64 hostname $hostname
65 fi
66
67 if [ -n "$domain" ] ; then
68 >/etc/resolv.conf.new
69 if ! grep -q "search $domain" /etc/resolv.conf ; then
70 echo "search $domain" >> /etc/resolv.conf.new
71 fi
72 echo "domain $domain" >> /etc/resolv.conf.new
73 grep -v "^domain " /etc/resolv.conf >> /etc/resolv.conf.new
74 mv -f /etc/resolv.conf.new /etc/resolv.conf
75 fi
7e04fe0e 76}
77
f1dba8bc
ER
78set_dhcpclient()
79{
80 if [ "$BOOTPROTO" = "bootp" -o "$BOOTPROTO" = "pump" ]; then
81 DHCP_CLIENT=/sbin/pump
82 fi
83
84 if [ -z "$DHCP_CLIENT" ]; then
85 if [ -x /sbin/dhcpcd ]; then
86 DHCP_CLIENT=/sbin/dhcpcd
87 elif [ -x /sbin/dhclient ]; then
88 DHCP_CLIENT=/sbin/dhclient
89 elif [ -x /sbin/dhcpxd ]; then
90 DHCP_CLIENT=/sbin/dhcpxd
91 elif [ -x /sbin/pump ]; then
92 DHCP_CLIENT=/sbin/pump
93 else
94 nls "Can't find a dhcp client."
95 exit 1
96 fi
97 fi
98}
99
767c8707
AM
100# Setup Network Address Translation (NAT)
101setup_nat()
102{
5e6dfc29
JR
103 typeset src via dst
104
105 if [ -r /etc/sysconfig/static-nat ]; then
106 if [ "$1" = "on" ]; then
107 grep "^[0-9]" /etc/sysconfig/static-nat | while read src via dst; do
108 /sbin/ip route add nat $dst via $src
109 /sbin/ip rule add from $src nat $dst
110 done
111 elif [ "$1" = "off" ]; then
112 /sbin/ip route show table all | egrep "^nat[[:blank:]]" | while read nat dst via src args; do
113 /sbin/ip rule del from $src nat $dst
114 /sbin/ip route del nat $dst via $src
115 done
116 fi
117 fi
767c8707
AM
118}
119
fa8aca70
JR
120# Setup static ARP
121static_arp()
7e04fe0e 122{
5e6dfc29
JR
123 typeset rc arpdev host hwaddr flags neflags
124
125 if is_yes "$STATIC_ARP" && [ -r /etc/ethers ]; then
126 if [ -x /sbin/arp ]; then
127 run_cmd "Setting static ARP entries" /sbin/arp -f /etc/ethers
128 else
129 show "Setting static ARP entries"; busy
130 rc=0
131 arpdev=$(ip link show | awk -F':' '(/UP/) && ! (/NOARP/) && ! (/lo:/) && ! (/NONE:/) { print $2; exit }')
132 if [ -z "$arpdev" ]; then
133 rc=1
134 else
135 # ip supports only ip addresses
136 grep "^[0-9]" /etc/ethers | \
137 while read host hwaddr flags; do
138 case "$flags" in
139 *temp*)
140 neflags="nud stale"
141 ;;
142 *)
143 neflags="nud permanent"
144 ;;
145 esac
146 if ! /sbin/ip neigh add $host lladdr $hwaddr $neflags dev $arpdev; then
147 rc=1
148 fi
149 done
150 fi
151 if [ "$rc" -gt 0 ]; then
152 fail
153 fi
0a6161f2 154 fi
74a7f2e4 155 fi
7e04fe0e 156}
157
fa8aca70 158static_rarp()
7e04fe0e 159{
5e6dfc29
JR
160 if is_yes "$STATIC_RARP"; then
161 if [ ! -e /proc/net/rarp ]; then
162 _modprobe single -k rarp
163 fi
164 if [ -r /etc/ethers -a -x /sbin/rarp ]; then
165 run_cmd "Setting static RARP entries" /sbin/rarp -f /etc/ethers
166 fi
167 fi
e9e86175
AM
168}
169
fa8aca70 170vlan_setup()
e9e86175 171{
5e6dfc29
JR
172 if [ -x /sbin/vconfig -a -e /proc/net/vlan/config ] && `echo $DEVICE | grep -q ^eth`; then
173 /sbin/vconfig set_name_type DEV_PLUS_VID_NO_PAD 2>&1 > /dev/null
174 ETH_VLANS="yes"
175 else
176 ETH_VLANS="no"
177 fi
de1fc6ce
JR
178}
179
fa8aca70
JR
180# Set up all IP && IP parameter variables
181setup_ip_param ()
38198f50 182{
5e6dfc29
JR
183 # detect network device type (ie. dummy, eth for dummy0, eth0 ..)
184 if [ -z "$DEVICETYPE" ]; then
185 DEVICETYPE=$(echo $DEVICE | awk ' { gsub(/[0-9]*\.?[0-9]*$/,NUL); print $0 } ')
186 fi
187
188 # Setup DEVICETYPE for special cases.
189 if (echo ${DEVICE} | LC_ALL=C egrep -q '^[a-z0-9]+\.[0-9]+$'); then
190 DEVICETYPE=vlan
191 fi
192
193 # real name of device (ie. is eth0 for eth0,eth0:1,eth0:alias)
194 DEVICE=$(echo $DEVICE | awk ' { gsub(/:.*$/,NUL); print $0 } ')
195
196 eval IP4ADDR="\$IPADDR${IP4_PRIM_IF:-}"
197 if echo "${IP4ADDR}" | grep -q ":" ; then
198 IP6ADDR=${IP4ADDR}
199 IP4ADDR=""
200 else
201 eval IP4ADDROPT="\$IP_AOPTS${IP4_PRIM_IF:-}"
202 eval IP4ROUTEOPT="\$IP_ROPTS${IP4_PRIM_IF:-}"
203 fi
204 if [ -n "${IP6_PRIM_IF}" ] ; then
205 eval IP6ADDR="\$IPADDR${IP6_PRIM_IF:-}"
206 eval IP6ADDROPT="\$IPV6_AOPTS${IP6_PRIM_IF:-}"
207 fi
208 if [ -n "${IP4_SRC_IF}" ] ; then
209 eval IP4SRCADDR="\$IPADDR${IP4_SRC_IF}"
210 IP4SRCADDR=$(echo ${IP4SRCADDR} | awk ' { gsub(/\/.*/,NIL); print "src " $0; } ')
211 fi
212 if [ -n "${IP6_SRC_IF}" ] ; then
213 eval IP6SRCADDR="\$IPADDR${IP6_SRC_IF}"
214 IP6SRCADDR=$(echo ${IP6SRCADDR} | awk ' { gsub(/\/.*/,NIL); print "src " $0; } ')
215 fi
216
217 # new rc-scripts 0.4.x option
218 if [ -z "$HANDLING" ]; then
219 HANDLING=0
220 fi
221
222 # set handling for bridge
223 case "$DEVICETYPE" in
224 br|atm|lec|irda|vlan)
225 HANDLING=1
226 ;;
227 esac
74a7f2e4 228
5e6dfc29
JR
229 # Multicast ready devices
230 if is_yes "$MULTICAST"; then
231 MULTICAST="on"
232 else
233 case "$DEVICETYPE" in
234 eth|br)
235 MULTICAST="on"
236 ;;
237 *)
238 MULTICAST="off"
239 ;;
240 esac
241 fi
242
243 # ARP ready devices
244 if [ -n "$ARP" ] ; then
245 if is_yes "$ARP"; then
246 ARP="arp on"
247 else
248 ARP="arp off"
249 fi
250 fi
38198f50
AM
251}
252
fa8aca70 253check_device_down ()
38198f50 254{
5e6dfc29
JR
255 if (ip link show dev ${DEVICE} 2> /dev/null | grep -q UP); then
256 return 1
257 else
258 return 0
259 fi
38198f50
AM
260}
261
5e6dfc29 262setup_ip_gw_ro ()
38198f50 263{
5e6dfc29
JR
264 # IPv4 gateway
265 if is_yes "$IPV4_NETWORKING"; then
266 if [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then
267 # set up default gateway
268 if [ -n "${GATEWAY}" ]; then
b6fb522d
ER
269 ip -4 route add default via ${GATEWAY} dev ${DEVICE} ${IP4SRCADDR} onlink 2>/dev/null
270 if [ $? = 0 ]; then
271 DEFGW=${GATEWAY}
272 else
273 # The default gateway could be set via eth0, while bringing up eth1 we shouldn't set default gateway again.
274 # To prevent this message just set GATEWAYDEV=eth0 in /etc/sysconfig/network.
275 nls "Warning: Default gateway already set proably via other interface. Do you need to setup GATEWAYDEV?"
276 fi
5e6dfc29
JR
277 elif [ "${GATEWAYDEV}" = "${DEVICE}" ]; then
278 ip -4 route add default dev ${DEVICE} ${IP4SRCADDR}
279 fi
280 fi
281 fi
282
283 # IPv6 gateway && IPv6 globalroute
284 if is_yes "$IPV6_NETWORKING"; then
285 if [ -z "${GATEWAY6DEV}" -o "${GATEWAY6DEV}" = "${DEVICE}" ]; then
286 # set up default gateway
287 if [ -n "${GATEWAY6}" ]; then
288 ip -6 route add default via ${GATEWAY6} dev ${DEVICE} ${IP6SRCADDR} onlink
289 DEFGW6=${GATEWAY6}
290 elif [ "${GATEWAY6DEV}" = "${DEVICE}" ]; then
291 ip -6 route add default dev ${DEVICE} ${IP6SRCADDR}
292 fi
293 fi
294 if [ -z "${IPV6_GLOBALROUTEDEV}" -o "${IPV6_GLOBALROUTEDEV}" = "${DEVICE}" ]; then
295 # set up default route
296 if [ -n "${IPV6_GLOBALROUTEGW}" ]; then
297 ip -6 route add 2000::/3 via ${IPV6_GLOBALROUTEGW} dev ${DEVICE} ${IP6SRCADDR} onlink
298 elif [ "${IPV6_GLOBALROUTEDEV}" = "${DEVICE}" ]; then
299 ip -6 route add 2000::/3 dev ${DEVICE} ${IP6SRCADDR}
300 fi
301 fi
302 fi
0a6161f2 303}
304
fa8aca70
JR
305#
306# following function sets up routes not associated to any device
307# eg. unreachable or blackhole routes
ec8b15cb 308# (c) 1999 Jacek Konieczny <jajcus@pld-linux.org>
fa8aca70
JR
309#
310setup_routes()
0a6161f2 311{
5e6dfc29
JR
312 typeset args
313
314 if [ -f /etc/sysconfig/static-routes ]; then
315 if [ "$1" = "on" -o "$1" = "yes" ] ; then
316 egrep "^(none|any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
317 /sbin/ip route add $args
318 done
319 else
320 egrep "^(none|any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
321 /sbin/ip route del $args 2>/dev/null
322 done
323 fi
324 fi
0a6161f2 325}
38198f50 326
fa8aca70
JR
327# Add ONLY IPv4 address (IPv6 address is added automaticly)
328set_up_loopback()
0a6161f2 329{
5e6dfc29
JR
330 if is_yes "$IPV4_NETWORKING"; then
331 ip addr add 127.0.0.1/8 dev lo
332 fi
333 ip link set dev lo up
fa8aca70
JR
334}
335
336set_down_loopback()
337{
5e6dfc29
JR
338 ip addr flush dev lo 2>&1 | grep -v "Nothing to flush"
339 ip link set dev lo down
0a6161f2 340}
341
342modprobe_net()
343{
5e6dfc29
JR
344 if is_yes "$IPV6_NETWORKING" && is_module "ipv6"; then
345 _modprobe single -k ipv6
346 fi
fa8aca70 347
5e6dfc29
JR
348 if is_yes "$IPX" && is_module "ipx"; then
349 _modprobe single -k ipx
350 fi
e016cdae 351}
7e04fe0e 352
490f6163 353#
354# folowing function calculates network prefix from given network mask
490f6163 355# (c) 1999 Grzegorz Stanislawski <stangrze@open.net.pl>
356#
fa8aca70
JR
357calcprefix()
358{
5e6dfc29
JR
359 typeset len olen bad prefix
360
361 prefix=0
362 olen=8
363 bad=0
364 for i in 1 2 3 4; do
365 len=0
366 j=$(echo "$1" | awk -F"." "{ print \$${i} }")
367 case "$j" in
368 255) len=8 ;;
369 254) len=7 ;;
370 252) len=6 ;;
371 248) len=5 ;;
372 240) len=4 ;;
373 224) len=3 ;;
374 192) len=2 ;;
375 128) len=1 ;;
376 0) len=0 ;;
377 *) len=300 ;;
378 esac
379 [ "$len" -gt "$olen" ] && bad=1
380 prefix=$(($prefix + $len))
381 olen=$len
382 done
383
384 if [ "$bad" = "0" ]; then
385 echo "$prefix"
386 else
387 echo "32"
388 fi
389 return
490f6163 390}
85ebccea 391
5379c9d4 392#
393# folowing function calculates network mask from given prefix
394# (c) 1999 Grzegorz Stanislawski <stangrze@open.net.pl>
395#
fa8aca70
JR
396calcnetmask()
397{
5e6dfc29
JR
398 typeset prefix a MASK
399
400 MASK=""
401 if [ "`echo "${1}" | grep "^[0-9]"`" = "" ]; then
402 prefix=32
403 else
404 typeset -i prefix=$1
405 fi
406 for i in 1 2 3 4; do
407 case $prefix in
408 7) a=254 ;;
409 6) a=252 ;;
410 5) a=248 ;;
411 4) a=240 ;;
412 3) a=224 ;;
413 2) a=192 ;;
414 1) a=128 ;;
415 *)
416 [ $prefix -ge 8 ] && a=255
417 [ $prefix -le 0 ] && a=0
418 ;;
419 esac
420
421 prefix="$(( $prefix - 8))"
422 if [ -z "$MASK" ]; then
423 MASK=$a
424 else
425 MASK=$MASK.$a
426 fi
427 done
428
429 echo $MASK
430 return
5379c9d4 431}
47dbf68e 432
dd8b6525 433# Retrievies PPPD PID and real interface name from /var/run/ppp-*.pid
5e6dfc29
JR
434get_ppp_device_and_pid ()
435{
436 if [ -f "/var/run/ppp-$DEVNAME.pid" ] ; then
437 eval `{
438 read PID ; echo "PID='$PID'"
439 read REALDEVICE ; echo "REALDEVICE=$REALDEVICE"
440 } < "/var/run/ppp-$DEVNAME.pid"`
441 fi
442
443 if [ -z "$REALDEVICE" ] ; then
444 REALDEVICE=$DEVICE
445 fi
dd8b6525 446}
c3bd5d9f 447
e686ef49 448# following function setups advanced routing rules
ec8b15cb 449# Olgierd Pieczul <wojrus@pld-linux.org>
5e6dfc29
JR
450setup_ip_rules ()
451{
452 typeset args prio from src
453
454 if [ -f /etc/sysconfig/static-routes ] ; then
455 if is_yes "$1"; then
456 egrep "^(from|to|iif|tos|fwmark|dev|pref|priority|prio)[[:blank:]]" /etc/sysconfig/static-routes | while read args; do
457 /sbin/ip rule add $args
458 done
459 elif is_no "$1"; then
460 /sbin/ip rule show | egrep -v -e "from all lookup (main|default|local) \$" -e " map-to " | while read prio from src args; do
461 [ "$src" == "all" ] && ip rule delete $args || ip rule delete $from $src $args
462 done
463 fi
464 fi
e686ef49 465}
6d145c04 466
5e6dfc29
JR
467is_wireless_device ()
468{
469 if [ -x /sbin/iwconfig ]; then
470 LC_ALL=C iwconfig "${1}" 2>&1 | grep -q "no wireless extensions" || return 0
471 fi
472 return 1
a6c22d3d
AM
473}
474
5e6dfc29
JR
475wireless_param ()
476{
477 device="$1"
478 if [ "$2" = "br" ]; then
479 prefix="${device}_"
480 else
481 prefix=""
482 fi
483
484 if [ -z "$(eval echo \$${prefix}WLAN_NICKNAME)" ]; then
aa59debd 485 WLAN_NICKNAME="$(hostname -f 2>/dev/null || hostname 2>/dev/null || echo localhost)"
5e6dfc29 486 else
7ac73e84 487 WLAN_NICKNAME="$(eval echo \$${prefix}WLAN_NICKNAME)"
5e6dfc29
JR
488 fi
489
490 # wlan mode needs to be first
491 [ -n "$(eval echo \$${prefix}WLAN_MODE)" ] && \
492 iwconfig ${device} mode "$(eval echo \$${prefix}WLAN_MODE)"
cbe41687 493 iwconfig ${device} nick ${WLAN_NICKNAME}
5e6dfc29
JR
494 [ -n "$(eval echo \$${prefix}WLAN_NWID)" ] && \
495 iwconfig ${device} nwid "$(eval echo \$${prefix}WLAN_NWID)"
496 if [ -n "$(eval echo \$${prefix}WLAN_FREQ)" -a "$(eval echo \$${prefix}${WLAN_MODE})" != "Managed" ] ; then
497 iwconfig ${device} freq "$(eval echo \$${prefix}WLAN_FREQ)"
498 elif [ -n "$(eval echo \$${prefix}WLAN_CHANNEL)" -a "$(eval echo \$${prefix}${WLAN_MODE})" != "Managed" ]; then
499 iwconfig ${device} channel "$(eval echo \$${prefix}WLAN_CHANNEL)"
500 fi
501 [ -n "$(eval echo \$${prefix}WLAN_SENS)" ] && \
502 iwconfig ${device} sens "$(eval echo \$${prefix}WLAN_SENS)"
503 [ -n "$(eval echo \$${prefix}WLAN_AP)" ] && \
504 iwconfig ${device} ap "$(eval echo \$${prefix}WLAN_AP)"
505 [ -n "$(eval echo \$${prefix}WLAN_BITRATE)" ] && \
506 iwconfig ${device} rate "$(eval echo \$${prefix}WLAN_BITRATE)"
507 [ -n "$(eval echo \$${prefix}WLAN_RTS_THRESHOLD)" ] && \
508 iwconfig ${device} rts "$(eval echo \$${prefix}WLAN_RTS_THRESHOLD)"
509 [ -n "$(eval echo \$${prefix}WLAN_FRAGMENTATION_THRESHOLD)" ] && \
510 iwconfig ${device} frag "$(eval echo \$${prefix}WLAN_FRAGMENTATION_THRESHOLD)"
511 if [ -n "$(eval echo \$${prefix}WLAN_KEY)" ]; then
512 iwconfig ${device} key "$(eval echo \$${prefix}WLAN_KEY)"
513 [ -n "$(eval echo \$${prefix}WLAN_ENCRYPTION)" ] && \
514 iwconfig ${device} key "$(eval echo \$${prefix}WLAN_ENCRYPTION)"
515 fi
516 if is_no "$(eval echo \$${prefix}WLAN_ENCRYPTION)"; then
517 iwconfig ${device} key off
518 fi
519 [ -n "$(eval echo \$${prefix}WLAN_POWER)" ] && \
f3f7385d 520 iwconfig ${device} power "$(eval echo \$${prefix}WLAN_POWER)"
5e6dfc29 521 [ -n "$(eval echo \$${prefix}WLAN_TXPOWER)" ] && \
f3f7385d 522 iwconfig ${device} txpower "$(eval echo \$${prefix}WLAN_TXPOWER)"
5e6dfc29 523 [ -n "$(eval echo \$${prefix}WLAN_RETRY)" ] && \
f3f7385d 524 iwconfig ${device} retry "$(eval echo \$${prefix}WLAN_RETRY)"
5e6dfc29
JR
525 [ -n "$(eval echo \$${prefix}WLAN_NWID)" ] && iwconfig ${device} \
526 nwid "$(eval echo \$${prefix}WLAN_NWID)"
2ae29436 527
9a0f7d04 528 # essid should be last due to network rescanning by wlan devices
5e6dfc29
JR
529 [ -n "$(eval echo \$${prefix}WLAN_ESSID)" ] && iwconfig ${device} \
530 essid "$(eval echo \$${prefix}WLAN_ESSID)"
a1ac348c
AM
531
532 if is_yes "$(eval echo \$${prefix}WLAN_COMMIT)"; then
533 iwconfig ${device} commit
9a0f7d04 534 fi
2ae29436
AM
535}
536
0336ea13
AM
537check_mii_tool ()
538{
5e6dfc29
JR
539 [ -x /sbin/mii-tool ] || return 2
540 output=$(LC_ALL=C mii-tool $1 2>&1)
541 echo $output | LC_ALL=C grep -q "link ok" && return 1
542 echo $output | LC_ALL=C grep -q "no link" && return 0 || return 2
0336ea13
AM
543}
544
545check_ethtool ()
546{
5e6dfc29
JR
547 [ -x /sbin/ethtool ] || return 2
548 output=$(LC_ALL=C ethtool $1 2>&1)
549 echo $output | LC_ALL=C grep -q "Link detected: yes" && return 1
550 echo $output | LC_ALL=C grep -q "Link detected: no" && return 0 || return 2
0336ea13
AM
551}
552
1b85f830
AM
553check_iwconfig ()
554{
555 [ -x /sbin/iwconfig ] || return 2
556 output=$(LC_ALL=C iwconfig $1 2>&1)
557 echo $output | LC_ALL=C grep -q "radio off" && return 0 || return 2
558}
0336ea13
AM
559
560check_link_down ()
561{
1b85f830 562 if [ -x /sbin/mii-tool -o -x /sbin/ethtool -o -x /sbin/iwconfig ]; then
5e6dfc29
JR
563 if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q UP ; then
564 ip link set dev $1 up >/dev/null 2>&1
565 timeout=0
566 while [ $timeout -le 10 ]; do
567 check_mii_tool $1
568 m=$?
569 check_ethtool $1
570 e=$?
1b85f830
AM
571 check_iwconfig $1
572 i=$?
5e6dfc29
JR
573 if [ $m -eq 1 ] || [ $e -eq 1 ] ; then
574 return 1
575 fi
1b85f830 576 if [ $m -eq 2 ] && [ $e -eq 2 ] && [ $i -eq 2 ]; then
5e6dfc29
JR
577 return 1
578 fi
579 usleep 500000
580 timeout=$((timeout+1))
581 done
582 return 0
74a7f2e4 583 fi
74a7f2e4 584 fi
5e6dfc29 585 return 1
0336ea13 586}
2ae29436 587
e9e86175 588# This must be last line !
5e6dfc29 589# vi:syntax=sh
This page took 0.163157 seconds and 4 git commands to generate.