#****************************************************************** #ident /etc/init.d/netenv Time-stamp: <97/07/04 11:13:44 bav> #****************************************************************** # Gerd Bavendiek bav@rw.sni.de 97-05-00 # # This script is used to set up a file containing information about # the actual network environment. This can be esp. useful for a # laptop being used in multiple environment: at home, in the office, # at a customers site. # # This is done as follows: When "lilo" prompts, type e.g. # linux netoff= # This sets up an shell variable "netoff", containing nothing. The # kernel starts the init process with "netoff" as part of its # environment, so does init. So this script can check for # "netoff". Placing assignments in a file is a convenient way to # enable user processes to deal with multiple environments (login # provides user processes with a complete new environment, so they do # not longer know about "netoff"). # # I took "netoff=" just for convenient typing. Of course you can use # something like "PROFILE=34" and scan for that ... # # Right now I use this mechanism for setting up my .fvwm95rc and my # printing environment. My .fvwm95rc is pre-compiled by means of the # variable "PROFILE". This way I can use one source for different # displays and so on. # # As is this script eventually tries to set up a plip connection by # executing /etc/init.d/plip. To be able to do so, it must be called # after "kerneld" is started ! (One example: S12kerneld, ... # S30netstd_misc, S40netenv, ....) # # Another hint regarding pcmcia: # My Debian GNU/Linux 1.2 used to set up the PCMCIA-Ethernet-Card in # /etc/pcmcia/network.opts. I changed this slightly by simply # . /tmp/netenv # This way the assignments in /tmp/netenv are passed to the calling # script. You HAVE to reorder the calling sequence of scripts in # /etc/rc2.d. Example: # S10sysklogd S12kerneld S15netstd_init S18netbase S19netenv S19pcmcia # # The profiles I defined are as follows: # 1x Tower Home, system name "nana", network plip only. # 2x Desktop Office, system name "zaza", Ethernet. # 3x Laptop, system name "lulu". # 30 at home, no Ethernet, eventually connected to tower via plip # 31 in the office # 32 at customer site 1 # 33 at customer site 2 #------------------------------------------------------------------- NETENV=/tmp/netenv # When located in /tmp, script must be called # AFTER wiping out /tmp has been done ... if [ `uname -n` = "nana" ]; then ( echo "# Networkenvironment: Home Tower (Network-Interface: Plip)" echo "export PROFILE=10" ) > $NETENV /etc/init.d/plip start elif [ `uname -n` = "zaza" ]; then ( echo "# Networkenvironment: Office Desktop (Network-Interface: Ethernet)" echo "export PROFILE=20" echo "export RLPR_PRINTHOST=printer-off" echo "export PRINTER=pr1" ) > $NETENV elif env | grep '^netoff=' > /dev/null; then ( echo "# Networkenvironment: Laptop at office (Network-Interface: Ethernet)" echo "export PROFILE=31" echo "IPADDR=\"123.456.78.9\"" echo "NETMASK=\"255.255.255.0\"" echo "NETWORK=\"123.456.78.0\"" echo "BROADCAST=\"123.456.78.255\"" echo "GATEWAY=\"123.456.78.1\"" echo "DOMAIN=\"rw.sni.de\"" echo "DNS_1=\"123.456.78.9\"" echo "export RLPR_PRINTHOST=printer-off" echo "export PRINTER=pr1" ) > $NETENV elif env | grep '^netetc=' > /dev/null; then ( echo "# Networkenvironment: Laptop at customer site (Network-Interface: Ethernet)" echo "export PROFILE=32" echo "IPADDR=\"123.456.8.89\"" echo "NETMASK=\"255.255.255.0\"" echo "NETWORK=\"123.456.7.0\"" echo "BROADCAST=\"123.456.7.255\"" echo "GATEWAY=\"123.456.7.1\"" echo "export RLPR_PRINTHOST=printer-etc" echo "export PRINTER=pr1" ) > $NETENV else if [ `uname -n` = "lulu" ]; then # just to double check # We are at home, let's start the plip-Interface ( echo "# Networkenvironment: Laptop at home (Network-Interface: Plip)" echo "export PROFILE=30" ) > $NETENV /etc/init.d/plip start fi fi chmod 644 $NETENV