![]() ![]() | ||
- Linux On Mobile Computers - -> Linux Mobile Guide |
Do you use your laptop in different network environments? At home? In the office? At a customers site? If yes, the small package "netenv" might be useful for you. When booting your laptop it provides you with a simple interface from which you can choose the current network environment. The first time in a new environment, you can enter the basic data and save it for later reuse. Netenv sets up a file containing variable assignments which describe the current environment. This can be used by the PCMCIA setup scheme, e.g. like the one that comes with Debian/GNU Linux and perhaps others. The netenv data can be used for things like:
Netenv is available at netenv home. It depends on dialog(1) for its menu interface. Netenv was developed by Gerd Bavendiek. SuSE's System Configuration Profile Management - SCPM software allows you to switch configuration profiles. You can boot directly into one profile and then switch to another profile at run time. This is the successor of SuSE's older "scheme" management software. divine is an utility for people who use their machines in different networks all the time. "The idea is this:
The point about divine in contrast to other solutions is that other solutions normally use ping or something like that. divine can check a large number of networks instantaneously, assuming that the machines you ping answer within one second (.4 seconds are normal on Ethernets). And pinging an unknown address will do an arp request anyway, so why not do an arp request in the first place?" From the NET3-4-HOWTO : "The term IP Mobility describes the ability of a host that is able to move its network connection from one point on the Internet to another without changing its IP address or losing connectivity. Usually when an IP host changes its point of connectivity it must also change its IP address. IP Mobility overcomes this problem by allocating a fixed IP address to the mobile host and using IP encapsulation (tunneling) with automatic routing to ensure that datagrams destined for it are routed to the actual IP address it is currently using." HUT Mobile IP is a dynamical, hierarchical Mobile IP system for Linux operating system. The implementation enables a hierarchical model for IP mobility, thus decreasing the location update times as a mobile host moves. Dynamics system has been designed Wireless LAN technology in mind, and the system has optimized functionality for mobility in WLAN. There is now a mailing list available. You can join it by sending subscribe on the subject line to <dynamics-user-request@cs.hut.fi> - or you can simply check the mail archive.
Sources: Kenneth E. Harker and Dag Brattli DHCP and BootP are also useful for working in different environments. Please see the DHCP-HOWTO and BootP-HOWTO . The pppd command can be configured via several different files: pppd file /etc/ppp/<your_options> . How can I have separate PCMCIA device setups for home and work? This is fairly easy using PCMCIA scheme support. Use two configuration schemes, called home and work. For details please read the appropriate chapter in the PCMCIA-HOWTO by David Hinds. From http://www.mjedev.demon.co.uk/index.html <Martin J. Evans martin_AT_mjedev.demon.co.uk> I have taken this recommendation: The first point to note is that init will take any arguments of the form name=value as environment variable assignments if they are not recognized as something else. This means you can set environment variables from the LILO boot prompt before your rc scripts run. I set the LOCATION environment variable depending on where I am when I boot Linux. e.g. LILO: linux LOCATION=home Or LILO: linux LOCATION=work Or simply LILO: linux where failing to set LOCATION means the same as LOCATION=home (i.e. my default). Instead of typing LOCATION=place each time you boot you can add an entry to your /etc/lilo.conf file and use the append instruction. e.g. # Linux bootable partition for booting Linux at home # image = /vmlinuz root = /dev/hda3 label = linux read-only # Linux bootable partition config ends # # Linux bootable partition for booting Linux at work # image = /vmlinuz root = /dev/hda3 label = work read-only append="LOCATION=work" # Linux bootable partition config ends With the example above you can use "linux" for booting at home and "work" for booting at work. Armed with the facility above, you can now edit the relevant rc scripts to test ENVIRONMENT before running ifconfig, setting up route etc. There are several other bootloaders which are often overlooked. Besides LILO, have a look at loadlin, CHooseOS (CHOS) (not GPL), GRand Unified Bootloader (GRUB), System Commander and take a look at ftp://metalab.unc.edu/pub/Linux/system/boot/loaders/ . The MicroSoft Windows-NT boot loader or OS/2 boot loader may even be used. From Steve <steve_AT_cygnet.co.uk> I got a configuration for X Windows with an external monitor: Note that I have introduced a neat trick! For my nice 17" monitor I start X11 with no options and get the default 16-bit 1152x864 display - but when using the LCD screen I specify a 15-bit display (startx -- -bpp 15) and get the correct 800x600 resolution automatically. This saves having to have two X11 config files. A short introduction about how to setup email on a laptop used at home (dial-up) and work (ethernet) by Peter Englmaier <ppe_AT_pa.uky.edu>: As a laptop user, I have special demands for my email setup. The setup described below, enables me to:
The configuration is based on sendmail, fetchmail, and a remote pop account for email. This is the most complicated part. Having installed the sendmail-cf package, I created a file named /usr/lib/sendmail-cf/laptop.mc:
divert(-1) include(`../m4/cf.m4') define(`confDEF_USER_ID',''8:12'') define(`confBIND_OPTS',`-DNSRCH -DEFNAMES') # here you define your domain define(`confDOMAIN_NAME',''pa.uky.edu'') OSTYPE(`linux') undefine(`UUCP_RELAY') undefine(`BITNET_RELAY') # there we send outgoing email define(`SMART_HOST',`server1.pa.uky.edu') # there we send mail to users my laptop does not know define(`LUSER_RELAY',`server1.pa.uky.edu') # again the domain, we want to be seen as MASQUERADE_AS(pa.uky.edu) FEATURE(allmasquerade) FEATURE(nouucp) FEATURE(nodns) FEATURE(nocanonify) FEATURE(redirect) FEATURE(always_add_domain) FEATURE(use_cw_file) FEATURE(local_procmail) MAILER(procmail) MAILER(smtp) HACK(check_mail3,`hash -a@JUNK /etc/mail/deny') HACK(use_ip,`/etc/mail/ip_allow') HACK(use_names,`/etc/mail/name_allow') HACK(use_relayto,`/etc/mail/relay_allow') HACK(check_rcpt4) HACK(check_relay3)
This looks more complicated as it is. All it does is, that it redirectes outbound mail to server1 (SMART_HOST) and also mail for local users which are not known (LUSER_RELAY). That way, I can write email to my colleques without using their full email address. More important: the From line in my email points back to my MASQUARADE_AS domain and not directly to my laptop. If this where not the case, email returned with the reply button might not reach me. You must restart sendmail for changes to take effect. Note: this configuration is for Redhat 5.2 systems. You may have to change some details. Now, all what is needed is to generate the /etc/sendmail.cf file m4 laptop.mc >/etc/sendmail.cf and to add all possible domain names my laptop should respond to in /etc/sendmail.cw:
# sendmail.cw - include all aliases for your machine here. laptop laptop.pa.uky.edu 128.17.18.30 guest1 guest1.somewhere.org
It is important to have all aliases in this file, otherwise sendmail will not accept the mail (and will reply we don't relay to the sender). Finally, you must now test the setup by sending email, replying to mail for all possible configurations. Any missconfiguration can result in loss of email. One method to get the email into your machine is through fetchmail. Fetchmail periodically checks for new email at one or more remote mail servers. I use the following fetchmail configuration file (in my user home directory): fetchmailrc
set postmaster "myusername" set daemon 900 poll pop.uky.edu with proto POP3 user "mypopusername" there with password "mypoppassword" is mylaptopusername here
Fetchmail will just get the email and send it to sendmail which will it deliver into your /var/spool/mail/$USER file. On my work station I have the following .forward file:
me@pop.acount.edu,me@server1
Here server1 is the machine where I keep my mailbox. All email is send to the pop account to be picked up later by my laptop (using fetchmail). However, when my laptop is connected via ethernet, I want my email to go directly to the laptop, instead of pop:
me@laptop,me@server1
In both cases, a backup of my email is send to server1 (where I also can read it, in case I cannot get my laptop). I keep/store all email on the laptop. Switching is done by three script files and a crontab file (on the workstation): forward_pop
#!/bin/sh echo "me@pop.acount.edu,me@server1" > ${HOME}/.forward
forward_laptop
#!/bin/sh echo "ppe@laptop,ppe@server1" > ${HOME}/.forward crontab ${HOME}/mycrontab ${HOME}/utl/check_laptop
check_laptop
#!/bin/sh if /usr/sbin/ping -c 1 laptop >/dev/null 2>&1 ; then : else # redirect mail to pop ${HOME}/utl/forward_pop sleep 10 if /usr/sbin/ping -c 1 laptop >/dev/null 2>&1 ; then # back to normal ${HOME}/utl/forward_laptop else # deactivate crontab check /bin/crontab -l | grep -v check_laptop >${HOME}/tmp/mycrontab.tmp /bin/crontab ${HOME}/tmp/mycrontab.tmp rm -f ${HOME}/tmp/mycrontab.tmp fi fi
mycrontab
# mycrontab 0,10,20,30,40,50 * * * * ${HOME}/utl/check_laptop
Each time I connect the laptop to the ethernet, I have to run forward_laptop, and each time I disconnect I run forward_pop. In case I forget to run forward_pop, the crontab job runs it for me less then 10 minutes later. To do all that automatically, I change the network script files on my laptop as follows: /sbin/ifdown (this script runs, whenever a network device is stopped, new stuff between BEGIN and END)
... fi # BEGIN new stuff # turn off forwarding email mail ppe <<EOF turning off forwarding email device = ${DEVICE} hostname = `hostname` EOF if "${DEVICE}" = "eth0" -a "`hostname`" = "laptop" ; then su -lc "ssh -l myusername server1 utl/forward_pop" myusername >& /dev/null fi # END new stuff ifconfig ${DEVICE} down exec /etc/sysconfig/network-scripts/ifdown-post $CONFIG
Note, that the script checks for the value of hostname. In case, I am connected to a foreign ethernet, my hostname and ip-address will be something else, e.g. guest1. /etc/sysconfig/network-scripts/ifup-post (this script is run, whenever a network device is started)
# Notify programs that have requested notification do_netreport # BEGIN new stuff # check for email -- I'm using fetchmail for this if "${DEVICE}" = "eth0" -o "${DEVICE}" = "ppp0" ; then su -lc fetchmail myusername >& /dev/null & fi # set clock if connected to ethernet, redirect email if "${DEVICE}" = "eth0" -a "`hostname`" = "zaphod" ; then ( rdate -s server1 ; hwclock --systohc --utc ) >& /dev/null & # forward email su -lc "ssh -l myusername gradj utl/forward_laptop" myusername >& /dev/null & fi # END new stuff exit 0
This step is completely optional. The above described sendmail configuration calls procmail for each received email, but you could have called procmail using the .forward file (see the procmail man page). Procmail is a handy tool to block spam and to sort incomming email. You need to setup a .procmailrc file to use procmail. See the man page for procmail, procmailrc, and procmailex (examples). My setup demonstrates, how to ignore certain email messages and split email-collections (digest) into pieces:
# -- mail filtering -- procmail is called by sendmail -- PATH=/bin:/usr/bin MAILDIR=$HOME/Mail LOGFILE=$MAILDIR/from # keep in mind: # use ":0:" when writing to a file # use ":0" when writing to a device, e.g. /dev/null, or send email # - make a backup of *all* incomming mail, but ignore mail tagged below - :0 c: *! Sissa-Repro backup # - keep only last 50 messages :0 ic | cd backup && rm -f dummy `ls -t msg.* | sed -e 1,50d` # - delete email comming through the 'postdocs' email list, when # it is not of any interest :0 * From.*postdocs * From.*Ernst Richter /dev/null :0 * From.*postdocs * Subject.*card charge /dev/null # Split mailing list from the sissa preprint server into individual emails # - this is quite complicated :( I can flip through the list much # faster and ignore preprints which have uninteresting titles. Instead of # having to browse through the whole list, my mailer will just present a # list of papers. # 1. split it in individual messages :0 * From no-reply@xxx.lanl.gov | formail +1 -de -A "Sissa-Repro: true" -s procmail # 2. reformat messages a bit # 2.1. extract 'Title:' from email-Body and add to email-header as 'Subject:' :0 b * Sissa-Repro *! Subject TITLE=| formail -xTitle: :0 a |formail -A "Subject: $TITLE " -s procmail # 2.2. store in my incomming sissa-email folder. Here, we could # also reject (and thereafter delete) uninteresting 'Subjects' # we could also mark more interesting subjects as urgend or send a copy # to regular mail box. :0: * Sissa-Repro * Subject *! replaced with sissa
By the way, there is a tk GUI tool to configure procmail (I think it is called dotfiles). Another possible solution for Email is to use UUCP. This software was made for disconnected machines, and is by far the easiest solution if you have several users on your laptop (we are talking about UNIX, remember?), each with his/her own account. Unlike what most people think, UUCP does not need a serial connection: it works fine over TCP/IP, so your UUCP partner can be any machine on the Internet, if it is reachable from your network attachment point. Here is the UUCP sys for a typical laptop: system mylaptop time any chat "" \d\d\r\c ogin: \d\L word: \P address uucp.mypartner.org port TCP
Mailsync is a way of synchronizing a collection of mailboxes. The algorithm is a 3-way diff. Two mailboxes are simultaneously compared to a record of the state of both mailboxes at last sync. New messages and message deletions are propagated between the two mailboxes. Mailsync can synchronize local mailbox files in many formats and remote mailboxes over IMAP, POP, and IMAPS. Using a Laptop in Different Environments by Gerd Bavendiek . This article appeared in the August, 1997 issue of the Linux Gazette . This is an excellent, short technical article describing an easy way to setup your Linux notebook to boot into different network and printing configurations, especially useful for those who use their machines at home as well as other locations such as in the office, at school, or at a customer site. |