1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<TITLE>whereami - Location Actions</TITLE>
<!-- $Id: actions.html,v 1.6 2005/05/15 09:18:01 andrew Exp $ -->
</HEAD>
<BODY FGCOLOR="#090933" BGCOLOR="#f0ffd0">
<TABLE WIDTH=100% BORDER=0 BGCOLOR="#faea0c" CELLSPACING=0 CELLPADDING=10><TR VALIGN=BOTTOM>
<TD ALIGN=CENTER><IMG SRC=images/q1.gif WIDTH=96 HEIGHT=126></TD>
<TD VALIGN=BOTTOM BGCOLOR="#d0b030"><H1 ALIGN=RIGHT VALIGN=BOTTOM><I>whereami</I> - Actions</H1></TD>
</TR></TABLE>
<HR><H2>Actions</H2>
<P>When I arrive at a new location the main thing I need to do is configure networking.
<UL>
<LI>I run a nameserver on my laptop and I want to configure that to use the
local network nameserver as a forwarder</LI>
<LI>I want to configure <I>sendmail</I> to use the local mailserver as a relay</LI>
<LI>I want to change my Netscape settings to operate appropriately with the
caches and proxies at the location</LI>
<LI>I want to mount appropriate local network drives</LI>
<LI>When I'm docked, I want to save any changes to various important files onto a
disk in the docking station</LI>
</UL>
<HR><H2>Configuration</H2>
<P>The <TT>/etc/whereami/whereami.conf</TT> file contains lines much like a normal shell script,
except that each line is prefixed by a string consisting of:
<UL><LI>a character indicating the circumstances in which the action applies</LI>
<LI>the name of the location to which this action relates</LI>
</UL>
<H4>Circumstances</H4>
<TABLE WIDTH=95% ALIGN=CENTER BORDER=Yes>
<TR><TH>Character</TH><TH>Situation in which the action applies</TH></TR>
<TR><TH><FONT SIZE=+2>+</FONT></TH><TD>The 'plus' sign indicates that this action will be performed
when the system <I>arrives</I> at the specified location: that is, the system
is now at the specified location
but was previously at another location
</TD></TR>
<TR><TH><FONT SIZE=+2>-</FONT></TH><TD>The 'minus' sign indicates that this action will be performed
when the system <I>has left</I> the specified location: that is, the system
was previously at the specified location
but is now at another location
</TD></TR>
<TR><TH><FONT SIZE=+2>=</FONT></TH><TD>The 'equals' sign indicates that this action will be performed
when the system is now at the specified location
regardless of where it was previously
</TD></TR>
</TABLE>
<H4>Location</H4>
<P>The location name may be one of those <a href="detection.html">detected</a>,
or 'any', which matches any location.
At some point in the future I will probably rewrite <I>whereami</I> to allow the location
specification to be a regular expression.</P>
<H4>Examples</H4>
<P>Putting it all together you end up with lines like:
<PRE>=any savelog -p /home/andrew/.netscape/preferences.js
=any cat /home/andrew/.netscape/preferences.js.0 >>/home/andrew/.netscape/preferences.js
# When we're at Catalyst
+catalyst bind-forwarders 192.168.2.80
+catalyst netscape-option /home/andrew/.netscape/preferences.js smtp_server \"mail.cat-it.co.nz\"
+catalyst setmailrelay mail.catalyst.net.nz
</PRE>
<P>The first two lines above will always apply.
The following three lines will apply whenever we 'arrive' at Catalyst.
First <TT>/etc/named.conf</TT> will be modified so that <I>named</I> uses the DNS server on the LAN as a forwarder;
second, Netscape will be configured to send outbound mail through the local mail server;
finally, <TT>/etc/mail/sendmail.cf</TT> will be modified so that <I>sendmail</I> uses the local mail server as a relay.</P>
<P>I'm sure someone is wondering why I do both of those last two, but really its just because
I'm transitioning from one way to the other. :-)</P>
<P>The file can contain full shell script functionality, so this fragment:
<PRE>=catalyst if ( grep "^docked" iam >/dev/null ) then
=catalyst mount /dev/hde1 /dos/f -t vfat
=catalyst mount /dev/hde2 /dock -t ext2
=catalyst /root/bin/bkup2dock &
=catalyst fi
</PRE>
<P>will execute an 'if' statement and only do the mount and backup if the machine is docked.</P>
<HR><H2>Action scripts</H2>
<P>A number of useful scripts are included in the directory <TT>/usr/share/whereami</TT>
which is added to the end of the path for the execution of the script which <I>whereami</I> generates.</P>
<P>I'm hoping that this section will expand once people other than myself start using the program.</P>
<TABLE WIDTH=100% BORDER=1>
<TR><TH>bind-forwarders<BR> <BR> </TH>
<TD>
Use: "bind-forwarders <ip-address>"
<P>This edits your /etc/named.conf file to change to the specified forwarder.</P>
<P>The line will be changed when it contains an IP address followed by a semi-colon, followed by the string
"// bind-forwarders" For example, a string such as:</P>
<PRE> 192.168.2.80; // bind-forwarders</PRE>
<P>would be a reasonable choice to start with. Each invocation of "bind-forwarders"
would then set the IP address appropriately. Naturally this line needs to be in the right place
in your /etc/named.conf file.
</TD></TR>
<TR><TH>masqmail_route<BR> <BR> </TH>
<TD>This updates masqmail routing.</P>
<P>Use "masqmail_route <route name> "</P>
<P>Masqmail allows for multiple routing configurations to be set up in
/etc/masqmail/masqmail.conf and other masqmail routing files.</p>
<p>See the masqmail.conf(5) man page for full details of the "online_routes"
option. You will also want to look at the masqmail.route(5) manpage.</p>
</TD></TR>
<TR><TH>setmailrelay<BR> <BR> </TH>
<TD>
<P>This is configured through the /etc/whereami/mail-relay.conf file to set a default mail relay if
desired, otherwise the script will change the mail relay in your sendmail or postfix configuration
file.</P>
<P>Use "setmailrelay queue" for your 'on the road' configurations and your mail will be queued for
sending next time you are on a permanent connection. You can add an optional third agrument,
which is the IP or name of the system to use as mail relay when flushing the queue. This overrides
the default relay specified in mail-relay.conf, and is handy if you have more than one way of
dialing into the internet and need a different mail relay per connection. </P>
<P>Use "setmailrelay none" for when you don't need a smarthost at all and can send mail directly.</P>
<P>Use "setmailrelay <smarthost>" where <smarthost> is the IP name or address of the system to use as
a mail relay</P>
<P>This script was originally supplied by <A HREF=http://www.josv.com/~josv/>Jos Visser </A>
and I've made a few minor adjustments to suit this use.</p></TD>
</TR>
<TR><TH>setresolver<BR> <BR> <BR> <BR> <BR></TH>
<TD>This script is used to adjust your resolv.conf file to suit the current environment.</P>
<P>The setresolver script essentially accepts an entire resolv.conf file on one single command line,
separating it into it's correct component parts and inserting it at the start of your existing resolv.conf.</P>
<P>You should review the manpage for resolv.conf (5) for full details of the information
in this file, but in basic form you can:</P>
<UL><LI>search <domain> [<domain> ...]</LI>
<LI>nameserver <ip address> [<ip address>] [<ip address>]</LI></UL>
<P>Which is pretty much what you will want to do. The domains listed after the search keyword are
the ones that will be appended to any names queried in an attempt to resolve names. As the
resolv.conf(5) manpage will tell you though: putting too many names in there can make name
resolution slower, so keep it to a minimum.</p>
</TD>
</TR>
</TABLE>
<P>If you have any suggestions,
<A HREF="mailto:Andrew -here- catalyst -in- net -in- nz">e-mail them to me</A>
and I'll distribute them along with future releases of <I>whereami</I>.
<P> </P><HR>
<TABLE WIDTH=100%><TR>
<TD ALIGN=LEFT><FONT FACE=sans-serif SIZE=2>
<A HREF=index.html>whereami</A>
|
<A HREF=detection.html>Location Detection</A>
</FONT></TD>
<TD ALIGN=RIGHT><FONT FACE=sans-serif SIZE=2>© Andrew McMillan, 1999-2005 released under the <A HREF=http://www.gnu.org/>GPL</A></FONT></TD>
</TR></TABLE>
<HR>
</BODY>
</HTML>
|