Date: Fri, 18 Jun 1999 13:21:09 +1000 (EST) From: Bruce Campbell <bc-freebsd@vicious.dropbear.id.au> To: freebsd-mobile@FreeBSD.ORG Cc: John Sconiers <jrs@enteract.com> Subject: Re: Two Locations Message-ID: <Pine.UW2.4.10.9906161750380.28700-200000@julubu.staff.apnic.net> In-Reply-To: <Pine.BSF.4.05.9906100900580.15262-100000@adam.enteract.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---559023410-1841205112-929676069=:16861 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 10 Jun 1999, John Sconiers wrote: jrs> Has anyone created a script to change ip# information in between two jrs> locations. The overall thing is that you need to change the 'ifconfig' and 'defaultrouter' variables which pccard_ether uses. Once you've done that, the existing pccard_ether code will do it for you. I've got a perl script running inside pccard_ether which looks for a crontab-style set of entries in /etc/rc.conf , and returns some nicities. pccard_ether needs to be changed to import the variables (eg 'ifconfig') for the current time: -- /etc/pccard_ether # Suck in the various overrides. if [ -f /etc/rc.conf ]; then . /etc/rc.conf fi # Suck in overrides for the current time/location if [ -x /etc/pccard_timevals.pl ] ; then eval `/etc/pccard_timevals.pl` fi -- pccard_timevals.pl (attached) returns a series of environment variables which can be eval'd as above (eg, 'ifconfig=DHCP' for work hours, 'ifconfig=inet ...' for home times) and works through having a set of defines in /etc/rc.conf (being the easiest place to put them): -- /etc/rc.conf # Find the '_times' variable for each of the locations listed here. # First match found wins. lpccard_locations="apnic humbug1 humbug2 home" # crontab format does not express events over midnight very well :( lpccard_humbug1_times="* 15-24 * * Sat" lpccard_humbug2_times="* 0-5 * * Sun" lpccard_apnic_times="* 9-18 * * Mon-Fri" lpccard_home_times="* * * * *" # These numbers are not the real ones. (obviously) lpccard_humbug1_ifconfig="inet 192.168.1.x netmask 255.255.255.0" lpccard_humbug2_ifconfig="inet 192.168.1.x netmask 255.255.255.0" lpccard_apnic_ifconfig="DHCP" lpccard_home_ifconfig="inet 192.168.2.x netmask 255.255.255.0" lpccard_humbug1_defaultrouter="192.168.1.1" lpccard_humbug2_defaultrouter="192.168.1.1" # DHCP sets the default router and etc, unset it here. lpccard_apnic_defaultrouter="" # home is on a different network, 2.254 is gf's linux box with # masquarading options. lpccard_home_defaultrouter="192.168.2.254" -- I've also got defines for 'nameserver', 'secondary', 'search' and 'hostname' for future changes to my pccard_ether to change the nameserver config file (via an include 'named.pccard' in named.conf), /etc/resolv.conf and the local hostname. Another thing which I had thought about, is the definition of a 'ping' variable which defines a host ip (ie, the router) which should be there for that location, merely as a double check for the correct location. Currently, by the above setup, if I leave work early, and plug the machine into the home network, it will think (by the current time) that I am still at work and attempt to obtain its address via DHCP. TANSTAFFL. All of the above works in testing, however, not (currently) in practice as my wee little 3c589d is still inconsistent about its behaviour. (suspend, resume, no free configuration, suspend, resume, ok-its there now, feh) Hopefully all of the above helps you somewhat, and anyone who doesn't like my perl hackery is welcome to send me a better version ;) --==-- Bruce. ---559023410-1841205112-929676069=:16861 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="pccard_timevals.pl" Content-ID: <Pine.UW2.4.10.9906181321090.16861@julubu.staff.apnic.net> Content-Description: Content-Disposition: attachment; filename="pccard_timevals.pl" Content-Transfer-Encoding: BASE64 IyEvdXNyL2Jpbi9wZXJsDQoNCiMgQnJ1Y2UgQ2FtcGJlbGwgPGJjLWZyZWVi c2RAdmljaW91cy5kcm9wYmVhci5pZC5hdT4gMTk5OQ0KDQojIFNvbWUgRGVm aW5lcy4NCm15ICRpbnB1dGZpbGUgPSAiL2V0Yy9yYy5jb25mIjsNCm15ICRw cmVmaXhtYXRjaCA9ICJscGNjYXJkXyI7DQoNCiMgUGFyc2UgYSBjcm9udGFi LWZvcm1hdCBtZWV0aW5nIHRoZSBmb2xsb3dpbmcgc3BlYzoNCg0KIyBUaGUg bHBjY2FyZF9sb2NhdGlvbl90aW1lcyBhdHRyaWJ1dGUgaXMgYSB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JCSJmZWIiLCAiMiIsDQoJCSJtYXIiLCAiMyIs DQoJCSJhcHIiLCAiNCIsDQoJCSJtYXkiLCAiNSIsDQoJCSJqdW4iLCAiNiIs DQoJCSJqdWwiLCAiNyIsDQoJCSJhdWciLCAiOCIsDQoJCSJzZXAiLCAiOSIs DQoJCSJvY3QiLCAiMTAiLA0KCQkibm92IiwgIjExIiwNCgkJImRlYyIsICIx MiIgKTsNCg0KCW15ICR0bG9vcCA9IDA7DQoNCgl3aGlsZSggJHRzcGxpdFsk dGxvb3BdICl7DQoJCSR0c3BsaXRbJHRsb29wXSA9fiB0ci9bQS1aXS9bYS16 XS87DQoJCSR0c3BsaXRbJHRsb29wXSA9fiBzL14oW2Etel17MSwzfSkuKiQv XDEvZzsNCgkJaWYoICRjb252eyIkdHNwbGl0WyR0bG9vcF0ifSAhfiAvXlxz KiQvICl7DQoJCQkkdHNwbGl0WyR0bG9vcF0gPSAkY29udnsiJHRzcGxpdFsk dGxvb3BdIn07DQoJCX0NCgkJJHRsb29wKys7DQoJfQ0KCW15ICRyZXR2YWw9 am9pbiggJy0nLCBAdHNwbGl0ICk7DQoJcmV0dXJuKCAkcmV0dmFsICk7DQp9 DQoNCg== ---559023410-1841205112-929676069=:16861-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.UW2.4.10.9906161750380.28700-200000>