old-www/LDP/LG/issue20/laptop.html

126 lines
4.3 KiB
HTML

<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<title>Using a Laptop in Different Environments Issue 20</title>
</HEAD>
<BODY BGCOLOR="#EEE1CC" TEXT="#000000" LINK="#0000FF" VLINK="#0020F0"
ALINK="#FF0000">
<!--endcut ============================================================-->
<H4>
&quot;Linux Gazette...<I>making Linux just a little more fun!</I>&quot;
</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H2>Using a Laptop in Different Environments</H2>
<H4>By Gerd Bavendiek,
<a href="mailto:bav@rw.sni.de">bav@rw.sni.de</a></H4>
</center>
<P><HR><P>
<h1>Do you use a laptop at home ? In the office ? At a customers
site ?</h1>
If yes, you should read on. I would like to show you how I integrate
my laptop in different network environments. The basic idea is really
simple. Using <code>lilo</code> as bootmanager, I boot with an
additional variable assignment. The kernel passes this to the
init-processes shell environment. So all processes started by
<code>init</code> can use it. Example:
<p>
<code>linux netoff=</code>
<p>
This sets up the variable <code>netoff</code>. It is assigned
nothing. I use it as a flag meaning <i>&quot;now I am in the
office&quot;</i>. Booting with
<tt>linux netetc=</tt>
means <i>&quot;now I am at customer site&quot;</i>. Using lowercase
variable names is just for convenient typing. If you prefer,
you can use something like <code>NETENVIRON=123</code>.
<p>
The real work of processing this variables is done in my
<code>/etc/init.d/netenv</code>. Take a look at this code
fragment:
<pre>
NETENV=/tmp/netenv # When located in /tmp, script must be called
# AFTER wiping out /tmp has been done ...
...
elif env | grep '^netoff=' > /dev/null; then
(
echo &quot;&quot;# Networkenvironment: Laptop at office (Network-Interface: Ethernet)&quot;
echo &quot;export PROFILE=31&quot;
echo &quot;IPADDR=\&quot;123.456.78.123\&quot;&quot;
echo &quot;NETMASK=\&quot;255.255.255.0\&quot;&quot;
echo &quot;NETWORK=\&quot;123.456.78.0\&quot;&quot;
echo &quot;BROADCAST=\&quot;123.456.78.255\&quot;&quot;
echo &quot;GATEWAY=\&quot;123.456.78.1\&quot;&quot;
echo &quot;DOMAIN=\&quot;rw.sni.de\&quot;&quot;
echo &quot;DNS_1=\&quot;123.456.89.9\&quot;&quot;
echo &quot;export RLPR_PRINTHOST=printer-off&quot;
echo &quot;export PRINTER=pr1&quot;
) > $NETENV
elif env | grep '^netetc=' > /dev/null; then
(
echo &quot;# Networkenvironment: Laptop at customer site (Network-Interface: Ethernet)&quot;
echo &quot;export PROFILE=32&quot;
...
echo &quot;export RLPR_PRINTHOST=printer-etc&quot;
echo &quot;export PRINTER=pr1&quot;
) > $NETENV
</pre>
Output ist written to a world readable file. Scripts which shall use
the assignments simply have to do something like
<p>
<code>. /tmp/netenv</code>
<p>
For further details you may refer to the included
<a href="./laptoplist.html">netenv</a>.
<p>
As you can see from the code, I do assign not only network stuff, but
also a Variable <code>PROFILE</code> as well as printing
stuff. This makes it possible, to have e.g. <b>ONE</b>
<code>.fvwm95rc</code>.
<p>
I would like to show you how to do that when I come back from my
vacation.
<p>
So far !
<p>
Kind regards
<p>
Gerd
<hr>
<address><a href="mailto:bav@rw.sni.de">Gerd Bavendiek</a></address>
<!--===================================================================-->
<P> <hr> <P>
<center><H5>Copyright &copy; 1997, Gerd Bavendiek<BR>
Published in Issue 20 of the Linux Gazette, August 1997</H5></center>
<!--===================================================================-->
<P> <hr> <P>
<A HREF="./index.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif"
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../index.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
ALT="[ FRONT PAGE ]"></A>
<A HREF="./lyx.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./wkndmech.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P>
<!--startcut ==========================================================-->
</BODY>
</HTML>
<!--endcut ============================================================-->