Skip site navigation (1)Skip section navigation (2)
Date:      09 May 2001 21:49:15 +0100
From:      Wayne Pascoe <wayne.pascoe@realtime.co.uk>
To:        freebsd-questions@freebsd.org, freebsd-mobile@freebsd.org
Cc:        byron.schlemmer@realtime.co.uk
Subject:   Laptop on 2 networks - my solution
Message-ID:  <m1y9s6dz90.fsf@zaphod.realtime.co.uk>

next in thread | raw e-mail | index | archive | help
Hi all,

After looking at the solutions offered from my question, I've hacked
up a script to easily flick me between networks. I run this after
booting as root, before I start X or anything like that.

It assumes that you have two of every config file that you need, named
.LOCATION_NAME

Eg, 
/etc/rc.conf.home and /etc/rc.conf.work
/etc/X11/XF86Config.home and /etc/X11/XF86Config.work

You get the picture. You call the script
./location.sh LOCATION_NAME (eg home or work). To change locations,
just edit the LOCATION variable and the case names inside the case
statement.

I hope that someone will find this script useful.

--location.sh--
#!/bin/bash

# Check to see that we were called with a location
case $1 in
    home)
        LOCATION='home'
        ;;
    work)
        LOCATION='work'
        ;;
    *)
        echo "Usage: location.sh [home|work]"
        exit
        ;;
esac

# copy the appropriate rc.conf into place, and suck
# the values in
cp /etc/rc.conf.$LOCATION /etc/rc.conf
. /etc/rc.conf

# Setup the new networking
echo -n "Setting up networking... "
CURRENT_GW=`netstat -rn | grep default | cut -c20-34`
ifconfig fxp0 $ifconfig_fxp0
hostname $hostname
route delete 0.0.0.0 $CURRENT_GW >> /dev/null
route add 0.0.0.0 $defaultrouter >> /dev/null
echo "Done!"

# Copy other config files into place and restart services
echo -n "Copying config files in place... "
cp /etc/X11/XF86Config.$LOCATION /etc/X11/XF86Config
cp /usr/local/etc/exim/configure.$LOCATION
/usr/local/etc/exim/configure
echo "Done!"

# Restart any services that need restarting
echo "Restarting services... "
(/usr/local/etc/rc.d/exim.sh stop && /usr/local/etc/rc.d/exim.sh start) \
   > /dev/null &&
echo -n " exim"
echo
--end script--

-- 
- Wayne Pascoe 
E-mail: wayne.pascoe@realtime.co.uk
Phone : +44 (0) 20 7544 4668
Mobile: +44 (0) 788 431 1675

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?m1y9s6dz90.fsf>