From owner-freebsd-mobile Mon Sep 7 23:52:38 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA11511 for freebsd-mobile-outgoing; Mon, 7 Sep 1998 23:52:38 -0700 (PDT) (envelope-from owner-freebsd-mobile@FreeBSD.ORG) Received: from mrelay.jrc.it (mrelay.jrc.it [139.191.1.65]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA11494 for ; Mon, 7 Sep 1998 23:52:35 -0700 (PDT) (envelope-from dirk.vangulik@jrc.it) Received: from elpc36.jrc.it (elpc36.jrc.it [139.191.71.36]) by mrelay.jrc.it (LMC5692) with ESMTP id IAA09447; Tue, 8 Sep 1998 08:52:19 +0200 (MET DST) Received: (from dirkx@localhost) by elpc36.jrc.it (8.8.8/8.8.7) id IAA01560; Tue, 8 Sep 1998 08:52:35 +0200 (CEST) (envelope-from dirkx) Date: Tue, 8 Sep 1998 08:52:34 +0200 (CEST) From: Dirk-Willem van Gulik X-Sender: dirkx@elpc36.jrc.it To: Marc Slemko cc: Mike Smith , mobile@FreeBSD.ORG Subject: Re: my pccard changes In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-mobile@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Mon, 7 Sep 1998, Marc Slemko wrote: > On Sun, 6 Sep 1998, Mike Smith wrote: > > > > In my situation I take my laptop between multiple ethernets, and I can't > > > use DHCP because I'm unlucky. > > ... > > > and a shell script that lets me just run "location home" and have > > > pccard_location="home" put into /etc/pccard_location. The same applies > > > for any number of locations. > > > > > > Pretty simple modificatons; just FYI if anyone else was wanting to do the > > > same thing but hadn't bothered to. > > > > What you want is this: > > Except that that doesn't deal with wanting to just modify parts of a file. > > I agree that, in general, when you need changed resolv.conf, and arbitrary > other files it may make sense. > > But you still need other changes; either modifying pccard_ether with hacks > or replacing it, replacing rc.conf, etc. And it really doesn't make sense > to completely replace either of those just for one or two settings. I > don't see anywhere that I can completely replace a file to change the IP > address and default route without also having a lot more baggage around. I could not agree more ! I ended up sourcing the '. rc.conf' each time and then overriding a few. Unfortunately not all DHCP servers supply all values. So that ends up beeing messy too. Dw. #>/etc/locs # location ip mask router dns(s) webweaving DHCP behind 10.0.1.109 255.255.255.128 10.0.1.1 10.0.1.2 front 139.191.7.99 255.255.255.0 139.191.7.1 139.191.7.3 elsvier 123.7.240.9 255.255.255.0 123.7.240.254 #!/usr/local/bin/perl # dirkx@webweaving.org - for vaio $loc=lc shift or `cat /etc/.lastloc`; open(F,'/etc/locs') or die "Could not open location file:$!"; while() { chomp; next if m/^\s*\#g/; ($tloc,$ip,$net,$router,@dns)=split; ($ok=1,last) if $loc eq lc $tloc; }; die "No such location" unless $ok; open(F,'>/etc.lastloc');print F $loc;close(F); push @dns,"139.191.1.142" unless $#dns>0; %vars=( 'ifconfig_unkown' => $ip, 'ifconfig_pccard' => $ip, 'default_router' => $router ); if ($ip ne 'DHCP') { mv '/etc/resolv.conf','/etc/resolv.conf.old' or die "CNM:$!"; open(F,'>/etc/resolv.conf'); print F "# Created $0 $loc - ".gmtime(time)."\n"; print F "search webweaving.org. jrc.it .\n"; map { print F "nameserver $_\n" } @dns; close(F); $vars{ ifconfig_pccard } .=' netmask '.$net; }; $comm = ". rc.conf\n"; foreach(keys(%vars)) { $comm .= "$_ = \"$vars{$_}\"\nexport $_\n"; }; $comm .="/etc/pccard_config all\n"; exec $comm; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message