Gentoo Archives: gentoo-dev

From: Sylvain <asm8@×××××××.fr>
To: gentoo-dev@g.o
Subject: Re: [gentoo-dev] init.d net scripts & Bash wierdness - idiot in distress
Date: Sun, 23 Mar 2003 13:03:56
Message-Id: 20030323140349.0799e241.asm8@wanadoo.fr
In Reply to: [gentoo-dev] init.d net scripts & Bash wierdness - idiot in distress by Stroller
1 Hi !
2
3 [couic]
4 > You can see where I've tried `echo "foo"` and `echo "wibble"` for
5 > debugging purposes. When I use this script as /etc/init.d/net.br0 & type
6 > `rc bridge` the "foo" & "bar" are displayed, but not the "wibble".
7 > Clearly the `if [ -n "${gateway}" ]...` line is not being returning
8 > true; yet I do not understand why, as my script seems to be just the
9 > same as the standard net.eth0 script in this respect, and my config file
10 > (also attached) seems the same.
11 >
12
13 Maybe echoing ${gateway} ${gateway%/*} and ${IFACE} befor the 'if'
14 could help. Something like that :
15 echo "gw:-${gateway}-"
16 echo "if1:-${gateway%/*}-"
17 echo "if2:-${IFACE}-"
18
19 [couic]
20 > I would guess that the list of physical devices might be stored in an
21 > array, or read from a list, but I am completely inexperienced at Bash
22 > scripting, so have no idea how to implement this. I found the Advanced
23 > Bash Scripting Guide a bit too advanced for me - can anyone recommend an
24 > alternative..? Is the O'Reilly Bash in a Nutshell any good..? I usually
25 > like their books.
26
27 Just add a simple variable in the conf.d/net.br0 file :
28 br_interfaces="eth0 eth1 eth2" # For example
29
30 and for the loop in the init.d/net.br0 script :
31
32 for br_if in ${br_interfaces}
33 do
34 ifconfig ${br_if} 0.0.0.0
35 done
36
37 brctl addbr ${IFACE}
38
39 for br_if in ${br_interfaces}
40 do
41 brctl addif ${IFACE} ${br_if}
42 done
43
44 Maybe you could have a little training in an xterm about the 'for' loop :-)
45 for i in a b c ; do echo $i ; done
46
47 regards,
48
49 sylvain
50
51
52
53 --
54 gentoo-dev@g.o mailing list