From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9514 invoked by uid 1002); 24 Mar 2003 09:13:37 -0000 Mailing-List: contact gentoo-dev-help@gentoo.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Received: (qmail 111 invoked from network); 24 Mar 2003 09:13:36 -0000 Message-ID: <52380.192.168.1.70.1048497424.squirrel@gentoo.lan> Date: Mon, 24 Mar 2003 09:17:04 -0000 (GMT) From: "Stroller" To: X-Priority: 3 Importance: Normal Reply-To: stroller@bigfoot.com X-Mailer: SquirrelMail (version 1.2.11) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: Re: [gentoo-dev] init.d net scripts & Bash wierdness X-Archives-Salt: 416b2c4b-03b7-48c6-a80c-3ba7904b892e X-Archives-Hash: 4906450114b1dcf991afc3f54ee180d8 Many thanks to the list for the excellent help with my /etc/init.d/net.br0 script. I'm disproportionately proud of myself for implementing the list's suggestions successfully. Many thanks to Sylvain for teaching me how to traverse lists in Bash scripts. I'm sure my script could do with error trapping (and a little tidying, see below), but I'm wondering if it would be worth distributing something like this as part of the bridge-utils ebuild. Is it worth me getting in touch with the maintainer..? On Saturday, March 22, 2003, at 10:54 pm, Martin Schlemmer wrote: > On Sat, 2003-03-22 at 23:35, Stroller wrote: > >> Unfortunately, for some reason my new script doesn't seem to read the >> gateway="br0/192.168.1.1" line from the config.d file, and I can't >> work >> out why not. If I use my dumb script the gateway is allocated >> correctly, >> but not when I try to read parameters from file. > > My best bet from looking at it quickly, is that you still have > 'gateway' > set in /etc/conf.d/net. If you look at /sbin/runscript.sh, you will > see: > ---------------------------------------------------------------- # > Source configuration files. > # (1) Source /etc/conf.d/basic to get common configuration. > # (2) Source /etc/conf.d/${myservice} to get initscript-specific # > configuration (if it exists). > # (3) Source /etc/conf.d/net if it is a net.* service > # (4) Source /etc/rc.conf to pick up potentially overriding > # configuration, if the system administrator chose to put it # > there (if it exists). > > [ -e /etc/conf.d/basic ] && source /etc/conf.d/basic > > [ -e "/etc/conf.d/${myservice}" ] && source > "/etc/conf.d/${myservice}" > > [ -e /etc/conf.d/net ] && \ > [ "${myservice%%.*}" = "net" ] && \ > [ "${myservice##*.}" != "${myservice}" ] && source /etc/conf.d/net > > [ -e /etc/rc.conf ] && source /etc/rc.conf > ----------------------------------------------------------------- > > Thus, it sources your /etc/conf.d/net.br0, and then sources > /etc/conf.d/net, which resets 'gateway' again, and makes the > '[ "${gateway%/*}" = "${IFACE}" ]' bit always fail. > > As I see it, you have two simple choices (other than hacking > things to pieces): > > 1) Use something other than 'gateway' for the br0 script. > > 2) Do not set gateway in /etc/conf.d/net Well, I've hacked things to pieces ;-] Then I reread you posting, and I see how I could have done things differently. You see, I've done this: for gateway in ${gateways} do if [ -n "${gateway}" ] && [ "${gateway%/*}" = "${IFACE}" ] then ebegin " Setting default gateway" /sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \ netmask 0.0.0.0 metric 1 >/dev/null || { local error=$? ifconfig ${IFACE} down &>/dev/null eend ${error} "Failed to bring ${IFACE} up" stop return ${error} } eend 0 fi done Then changed /etc/conf.d/net : # For setting the default gateway #gateway="eth0/192.168.1.1" #gateway="br0/192.168.1.1" # The above settings don't work, because Gentoo's init.d scripts will # only read the last default gateway entry hence this naffs up the # eth0 entry gateways="br0/192.168.1.1 eth0/192.168.1.1" Now, as I understand it, it would probably be tidier if I had proceeded differently: - rename the standard /etc/conf.d/net to /etc/conf.d/net.eth0 - symlink that to /etc/conf.d/net.eth1 - create a new file called conf.d/net.br0 & put the `gateway="br0/...` line (and IP address &c for br0) in there. That way the two `gateway="ethX/...` lines can co-exist without interfering with each other. I'll probably rearrange this shortly, as that seems neater than rewriting Gentoo's default rc-srcipts & because I want to diverge from the Gentoo out-of-the-box configuration as little as possible. Now, I can see (although I had to think about it) that init.d/net.* files only read one default gateway for a Good Reason (tm). What I don't understand is why not make the default configuration file to be /etc/conf.d/net.eth0 in the first place..? Why have a /etc/conf.d/net at all..? As I understand it (someone will undoubtedly correct me if I'm wrong B-] ), the naming convention of ethX is strictly arbitrary - you could name your first interface as eth7. There's been some talk here recently of folks having one network configuration for home, and another for work: as I understand it you could have ethX & ethY as different run-levels for the same physical network card, each with a different set of settings in /etc/conf.d/. In this case the same problem would be encountered as I have, and the user would have to configure /etc/conf.d/net.ethX & /etc/conf.d/net.ethY and have no /etc/conf.d/net. This probably sounds like I'm whinging because it took me a while to figure it out: "it was a hassle for me, so you should change the whole Gentoo distribution!" I don't mean it like that, but I'd be interested to hear if there's a really good reason for having /etc/conf.d/net out of the box, instead of /etc/conf.d/net.eth0. The default configuration is slightly easier if you add a 2nd NIC & want to use both together on different subnets (admittedly the common way), but users could easily copy conf.d/net.eth0 to conf.d/net.eth1 & edit, the same as they copy /init.d/net.eth0. At present there aren't even any comments in the header to say that conf.d/net overrides any conf.d/net.XXX scripts. Am I just being dumb..? Should users know that the source lines in /sbin/runscript.sh behave this way..? Many thanks to anyone who can aid my understanding. Sorry for such a long posting - I seem to have the -v flag permanently set. Stroller. -- gentoo-dev@gentoo.org mailing list