Gentoo Archives: gentoo-dev

From: Stroller <GentooGimp@×××××××××.com>
To: gentoo-dev@g.o
Subject: [gentoo-dev] init.d net scripts & Bash wierdness - idiot in distress
Date: Sat, 22 Mar 2003 21:31:03
Message-Id: 51175.
1 I'm hoping someone can take a look at the attached scripts & give me
2 some pointers, becuase I'm clearly doing something extremely dumb.
4 I'm trying to run a transparent bridge for my home network, much as
5 discussed in the FAQs & tutorials at
6 &
9 I thought I'd be clever & elegant & create a new runlevel for this, so
10 that my /etc/init.d/net.br0 script is started instead of eth0 & eth1.
11 It's largely working very well & I've been very impressed by Gentoo's
12 run-levels system.
14 I initially implemented this with a very simple script in which all
15 variables, IPs & interface names are static. This is attached as
16 net.br0.old - if I copy this to /etc/init.d/net.br0 everything works
17 perfectly. All I do is type `rc bridge` and all the other services
18 shutdown before eth0 & eth1 do, then nothing happens for a moment & then
19 my bridge device finishes initialising and up everything comes again.
21 I then decided to be "clever" and edit a copy of the
22 /etc/init.d/net.eth0 script, and so my new net.br0 (or net.br1 or
23 whatever) script takes the name of it's ${IFACE} from its own filename &
24 gets it's other parameters from /etc/config.d/net.br0 (or br1 &c).
26 Unfortunately, for some reason my new script doesn't seem to read the
27 gateway="br0/" line from the config.d file, and I can't work
28 out why not. If I use my dumb script the gateway is allocated correctly,
29 but not when I try to read parameters from file.
31 You can see where I've tried `echo "foo"` and `echo "wibble"` for
32 debugging purposes. When I use this script as /etc/init.d/net.br0 & type
33 `rc bridge` the "foo" & "bar" are displayed, but not the "wibble".
34 Clearly the `if [ -n "${gateway}" ]...` line is not being returning
35 true; yet I do not understand why, as my script seems to be just the
36 same as the standard net.eth0 script in this respect, and my config file
37 (also attached) seems the same.
39 If anyone can explain what I'm doing wrong, I would be eternally
40 grateful.
42 Whilst I have your attention, I would also ideally like to have a list
43 of physical interfaces to be included in the config file. I think the
44 startup file would need a while loop to read them, as the bridge
45 interface can bridge any number of physical interfaces, as long as there
46 are at least 2 of them. Then the startup script needs to perform a
47 couple of loops through, ifconfig'ing each physical interface to IP
48 before adding it to the bridge device using the `brtcl add ...`
49 command.
51 I would guess that the list of physical devices might be stored in an
52 array, or read from a list, but I am completely inexperienced at Bash
53 scripting, so have no idea how to implement this. I found the Advanced
54 Bash Scripting Guide a bit too advanced for me - can anyone recommend an
55 alternative..? Is the O'Reilly Bash in a Nutshell any good..? I usually
56 like their books.
58 I do hope I've explained myself clearly,
59 Thanks for any pointers,
61 Stroller.


File name MIME type
net.br0.old application/octet-stream
net.br0 application/octet-stream
conf.d-net.br0 application/octet-stream