source: freewrt/package/fwifupdown/files/ifupdown.sh@ 2af55bb

Last change on this file since 2af55bb was aa2bc52f, checked in by Christian Fischer <spaetzle@…>, 18 years ago
  • updated wl-broadcom script to work with latest wl this is untested but the old one doesn't work and i have no time to test next days
  • removed output noise from ifup, used mprint instead of echo
  • updated manual stuff, from now manual doesn't configure iface but sets it up or down
  • removed bridge shutdown if bridge init fails not to 100 percent complete initialized bridge is better than having no network, the normal user doesn't have serial access

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

  • Property mode set to 100644
File size: 1.6 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
37# cleanup ifstate files
38rm -rf /tmp/ifupdown/ifstate
39mkdir -p /tmp/ifupdown/ifstate
40
41eval IFUPDOWN_ENV= $(grep '^FWIFUPDOWN_' /etc/rc.conf |sed "s/#.*//g") \
42 busybox $what $@ $redirect
43
44i=0 # did we print the initialisation message?
45j=0 # timeout in seconds
46rv=0 # exit status of this script
47while sleep 1; do
48 if test $j -gt 30; then
49 mstate 1
50 mprint "bridge initialisation timed out"
51 rv=1
52 break
53 fi
54 for x in /tmp/ifupdown/ifstate/bridge/*; do
55 # any bridges to check?
56 test -e "$x" || break 2 # no -> out of both loops
57 # print initialisation message, but once only
58 test $i = 1 || mprint -n \
59 "Waiting for bridge initialisation to finish"
60 i=1
61 # check this bridge for its states
62 s=ok
63 for state in $(brctl showstp ${x##*/} | \
64 fgrep state | sed "s/^.*state//"); do
65 test x"$state" = x"forwarding" && continue
66 # if only one is not forwarding, wait
67 s=no
68 break
69 done
70 test $s = ok || break # not ok? wait one second
71 rm -f $x # this bridge done, check next ones
72 done
73 j=$(expr $j + 1)
74done
75test $i = 0 || {
76 mstate $rv
77 mprint "took $j seconds"
78}
79
80# vim:ts=4
Note: See TracBrowser for help on using the repository browser.