[SPARCbook] homebase script

Patrick Arnoux parnoux at condor.orli.com
Sat Aug 26 12:21:15 CDT 2000


# The following script may come in handy for people running 2.6
# who regularly switch between different networks.
# 
# The script just copies the current set of files from "/etc" to the
# directory named after the current domain name (to save modifications),
# copies the files from the requested domain name directory into "/etc"
# and changes the IP address and default gateway.
# 
# The hosts file must contain an entry by the name "router"
# to setup the default gateway
# 
# To run it the first time, just create an empty directory for the
# current domain and the modified hosts/resolv.conf/defaultdomain
# files in the target domain directory.
# 
# Pretty simple stuff, and probably more verbiage than the code is worth.
# 
# 
# In any case, I hope someone else can find it useful. Enjoy!!
# 
# Oh, and if you live an a .net or .org domain, you know what to do :)
#
#
#!/bin/sh
#
if [ $# -gt 0 ] ; then
	NEWDOMAIN=${1}.com
else
	NEWDOMAIN=XXXX.com
	echo "I need a domain name with no .com attached"
	exit 1
fi

DOMAIN=`domainname`
HOSTNAME=`hostname`
ROUTER=router

# Save current environment

# Host file
# Name server
cp /etc/hosts /etc/resolv.conf /etc/defaultdomain /usr/local/etc/${DOMAIN}

# Setup Home Base environment

domainname ${NEWDOMAIN}

# Host file
cp /usr/local/etc/${NEWDOMAIN}/hosts /etc
# Name server
cp /usr/local/etc/${NEWDOMAIN}/resolv.conf /etc
cp /usr/local/etc/${NEWDOMAIN}/defaultdomain /etc

# Reset ethernet address
ifconfig le0 down
hostadd=`grep ${HOSTNAME} /etc/hosts | cut -f 1`
ifconfig le0 $hostadd up

# We need to get places
gateway=`netstat -rn | grep default | /usr/bin/tr -s " " | cut -d' ' -f 2`
route delete default $gateway
router=`grep ${ROUTER} /etc/hosts | cut -f 1`
route add default $router







More information about the SPARCBook mailing list