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
RevLine 
[4624b5d]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>
[7b2dc2a8]8# Thorsten Glaser <tg@freewrt.org>
[4624b5d]9#
10
[ef6c170]11config() {
12 [ x"$1" = x"1" ]
13}
14
[cb45bc1]15what=${0##*/}
[0cee642]16case $what in
17ifup)
[4624b5d]18 ;;
[0cee642]19ifdown)
[4624b5d]20 ;;
[0cee642]21*)
[4624b5d]22 echo "Usage: ifup|ifdown [options]"
23 echo "For options see man busybox"
24 exit 1
25 ;;
26esac
27
[5fade05]28. /etc/rc.conf
[ef6c170]29. /etc/network/mfunctions.sh
[964dfce1]30redirect="2>&-"
[8ebd04e]31
[ef6c170]32if config $FWIFUPDOWN_DEBUG; then
[964dfce1]33 set -x
[0cee642]34 redirect=
[4624b5d]35fi
[6537025]36[ -e /tmp/.booting ] && redirect="$redirect >/dev/console"
[4624b5d]37
[ef6c170]38# cleanup ifstate files
[7b2dc2a8]39rm -rf /tmp/ifupdown/ifstate
40mkdir -p /tmp/ifupdown/ifstate
[ef6c170]41
[d1ef2f2]42eval IFUPDOWN_ENV= $(grep '^FWIFUPDOWN_' /etc/rc.conf |sed "s/#.*//g") \
[0cee642]43 busybox $what $@ $redirect
[4624b5d]44
[7b2dc2a8]45i=0 # did we print the initialisation message?
46j=0 # timeout in seconds
47rv=0 # exit status of this script
48while sleep 1; do
[5986dbb]49 if test $j -gt 30; then
[aa2bc52f]50 mstate 1
[6537025]51 merr "bridge initialisation timed out"
[7b2dc2a8]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
[7f0f5cc]58 # print initialisation message, but once only
[aa2bc52f]59 test $i = 1 || mprint -n \
[7b2dc2a8]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
[7f0f5cc]74 j=$(expr $j + 1)
[ef6c170]75done
[aa2bc52f]76test $i = 0 || {
77 mstate $rv
[6537025]78 minfo "took $j seconds"
[aa2bc52f]79}
[ef6c170]80
[aa2bc52f]81# vim:ts=4
Note: See TracBrowser for help on using the repository browser.