source: freewrt/package/fwifupdown/files/ifupdown.sh@ 6537025

Last change on this file since 6537025 was 6537025, checked in by Christian Fischer <spaetzle@…>, 18 years ago
  • updated mprint(), use printf from now
  • moved mprint stuff to mfunctions
  • cosmetic output format changes

git-svn-id: svn://www.freewrt.org/trunk/freewrt@3094 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#!/bin/sh
2#
3# This file is part of the FreeWRT project. FreeWRT is copyrighted
4# material, please see the LICENCE file in the top-level directory
5# or at http://www.freewrt.org/licence for details.
6#
7# Christian Fischer <spaetzle@freewrt.org>
8# Thorsten Glaser <tg@freewrt.org>
9#
10
11config() {
12 [ x"$1" = x"1" ]
13}
14
15what=${0##*/}
16case $what in
17ifup)
18 ;;
19ifdown)
20 ;;
21*)
22 echo "Usage: ifup|ifdown [options]"
23 echo "For options see man busybox"
24 exit 1
25 ;;
26esac
27
28. /etc/rc.conf
29. /etc/network/mfunctions.sh
30redirect="2>&-"
31
32if config $FWIFUPDOWN_DEBUG; then
33 set -x
34 redirect=
35fi
36[ -e /tmp/.booting ] && redirect="$redirect >/dev/console"
37
38# cleanup ifstate files
39rm -rf /tmp/ifupdown/ifstate
40mkdir -p /tmp/ifupdown/ifstate
41
42eval IFUPDOWN_ENV= $(grep '^FWIFUPDOWN_' /etc/rc.conf |sed "s/#.*//g") \
43 busybox $what $@ $redirect
44
45i=0 # did we print the initialisation message?
46j=0 # timeout in seconds
47rv=0 # exit status of this script
48while sleep 1; do
49 if test $j -gt 30; then
50 mstate 1
51 merr "bridge initialisation timed out"
52 rv=1
53 break
54 fi
55 for x in /tmp/ifupdown/ifstate/bridge/*; do
56 # any bridges to check?
57 test -e "$x" || break 2 # no -> out of both loops
58 # print initialisation message, but once only
59 test $i = 1 || mprint -n \
60 "Waiting for bridge initialisation to finish"
61 i=1
62 # check this bridge for its states
63 s=ok
64 for state in $(brctl showstp ${x##*/} | \
65 fgrep state | sed "s/^.*state//"); do
66 test x"$state" = x"forwarding" && continue
67 # if only one is not forwarding, wait
68 s=no
69 break
70 done
71 test $s = ok || break # not ok? wait one second
72 rm -f $x # this bridge done, check next ones
73 done
74 j=$(expr $j + 1)
75done
76test $i = 0 || {
77 mstate $rv
78 minfo "took $j seconds"
79}
80
81# vim:ts=4
Note: See TracBrowser for help on using the repository browser.