whereami-0.3.34/0000755000000000000000000000000011415355664010302 5ustar whereami-0.3.34/man/0000755000000000000000000000000010767151272011053 5ustar whereami-0.3.34/man/Makefile0000644000000000000000000000033010620241635012476 0ustar all: whereami.8 detect.conf.5 whereami.conf.5 whereami.8: whereami.sgml docbook-to-man $< > $@ detect.conf.5: detect.conf.sgml docbook-to-man $< > $@ whereami.conf.5: whereami.conf.sgml docbook-to-man $< > $@ whereami-0.3.34/man/whereami.80000644000000000000000000001523110712413254012736 0ustar .TH "whereami" "8" .SH "NAME" whereami \(em non-interatively ascertain the location of the computer and reconfigure the system appropriately. .SH "SYNOPSIS" .PP \fBwhereami\fR [\fB\-\-debug \fP] [\fB\-\-scriptdebug \fP] [\fB\-\-syslog \fP] [\fB\-\-noactions \fP] [\fB\-\-nolocking \fP] [\fB\-\-mapping \fP] [\fB\-\-basedir \fIdirectory\fR \fP] [\fB\-\-statedir \fIdirectory\fR \fP] [\fB\-\-from \fIlocation_list\fR \fP] [\fB\-\-run_from \fIcalling_program_tag\fR \fP] [\fBlocation_list\fP] .SH "DESCRIPTION" .PP `whereami' provides a configurable and extensible framework for automatic location-detection and reconfiguration of computers, typically laptops. .SS "Detection" .PP Detection is handled through the use of various network and hardware probing tools. These tools have been wrapped in small shell scripts to interface them to whereami, but the end-user with different requirements may wish to extend these in some situations. .PP \fBwhereami\fR processes the file /etc/whereami/detect.conf performing the tests specified in there in order to decide which location the computer is currently located at. .PP For full detail on the discovery process, you should read the detect.conf (5) manpage. .SS "Configuration" .PP Configuration is handled through standard shell scripting. A variety of small utility scripts are provided and the author is always willing to accept more. .PP The file /etc/whereami/whereami.conf is parsed and a script built containing the actions specified there which are associated with the locations found during the detection phase. Actions may be configured for when leaving, remaining, or arriving at a location. .PP Once the script has been built, it is run to effect the necessary changes to the system configuration. .SH "OPTIONS" .PP This program follows the modern command-line syntax preceding each option with a double dash (`\-\-'). Short form options are also available, but are not documented (RTFC :\-) .IP "\fB\-\-debug\fP" 10 Run in debugging mode. A verbose output is provided and the resulting script is output to the screen and not executed. .IP "\fB\-\-scriptdebug\fP" 10 Run in script debugging mode. Each script supplied with `whereami' will `set \-o xtrace' if the environment variable `DEBUGWHEREAMI' is set to non-blank. This parameter will set that variable. The script which is built by whereami will also respond to the environment variable. .IP "\fB\-\-syslog\fP" 10 Output some logging information to syslog. The 'user' facility is used for this, and it provides an insight into which locations whereami has chosen, and why. .IP "" 10 In combination with \fB\-\-scriptdebug\fP above, this can be very useful for debugging your configuration. Also note that the default installation turns this on for apm and init actions. .IP "\fB\-\-noactions\fP" 10 Just do the detection and print the location name. Don't build and run the script from whereami.conf. .IP "" 10 You might do this if you wanted to use \fBwhereami\fR's detection, but use something else for configuration. Perhaps you could achieve the same end with a very simple whereami.conf, but there should always be two ways to do anything :\-). .IP "\fB\-\-nolocking\fP" 10 \fBwhereami\fR won't normally let two copies of whereami run at the same time. Use this option if you can come up with a scenario where you should allow this to happen! .IP "\fB\-\-mapping\fP" 10 This will persuade \fBwhereami\fR to do only the detection stage, and output a list of the detected locations, suitable for use as a mapping script with ifupdown. .IP "\fB\-\-hint \fIlocations\fR \fP" 10 Provides some hints to the detection process. The locations set by this parameter (a comma-delimited list) may be referenced by rules in your detect.conf. .IP "\fB\-\-basedir \fIdirectory\fR \fP" 10 Specifies the base directory which will contain both the detect.conf and whereami.conf. The default is `/etc/whereami' which should be right for normal use. .IP "\fB\-\-statedir \fIdirectory\fR \fP" 10 Specifies the state directory in which \fBwhereami\fR will write files indicating the current and previous locations (iam , iwas) and the script which is run for this environment (whereiam.sh). .IP "\fB\-\-from \fIlocation_list\fR \fP" 10 Overrides \fBwhereami\fR's knowledge of where you have come from. The \fIlocation_list\fR will be a comma-separated list of the locations which you are leaving. .IP "" 10 Normally `\fBwhereami\fR' maintains a history of locations, so that it knows where you have come from (and what might consequently have to be de-configured) as well as knowing that your location has changed. .IP "\fB\-\-run_from \fIcalling_program_tag\fR \fP" 10 This provides a mechanism for calling software, such as init scripts, pcmcia startup or apm events, to pass some of that source information to \fBwhereami\fR, where it is promptly ignored, at present. .IP "" 10 I have a possibly misguided idea that this might be useful somehow, but I can't think of any application of it at this point! .IP "\fBlocation_list\fP" 10 Overrides \fBwhereami\fR's testing of where you are. The \fIlocation_list\fR will be a comma-separated list of the locations which you are now at. .IP "" 10 You might use this if you wished to bypass the detection phase, using some other package to handle that. .SH "SEE ALSO" .PP detect.conf (5), whereami.conf (5) .PP There is some further documentation in HTML available in /usr/share/doc/whereami/manual .SH "FILES" .IP "\fB/etc/whereami/detect.conf\fP" 10 Defines the process of detection. .IP "\fB/etc/whereami/whereami.conf\fP" 10 Defines the actions performed as a result of entering, leaving, or remaining within a particular location. .SH "KNOWN BUGS" .PP This man page only documents the current perl version of whereami. For backward compatibility with people's setups, it is possible to configure your system to run the older shell-script, which is currently undocumented. .PP If you wish to switch from the shell script to the new perl program you will need to create an appropriate `detect.conf' file to define your location detection parameters. Your existing whereami.conf file should be compatible with this version. Once you have created a detect.conf file in /etc/whereami you should run `\fBdpkg-reconfigure whereami\fR' and respond to the questions. .SH "AUTHOR" .PP This manual page was written by Andrew McMillan for the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GPL version 2. .\" created by instant / docbook-to-man, Fri 02 Nov 2007, 07:10 whereami-0.3.34/man/detect.conf.sgml0000644000000000000000000004146010620241635014127 0ustar manpage.1'. You may view the manual page with: `docbook-to-man manpage.sgml | nroff -man | less'. A typical entry in a Makefile or Makefile.am is: detect.conf.5: detect.conf.sgml docbook-to-man $< > $@ --> Andrew"> McMillan"> November 4, 2002"> 5"> awm@debian.org"> detect.conf"> Debian GNU/Linux"> GNU"> ]>
&dhemail;
&dhfirstname; &dhsurname; 2002 &dhusername; &dhdate;
&dhucpackage; &dhsection; &dhpackage; provides the configuration for detection of locations for whereami. DESCRIPTION Syntax The detect.conf file specifies the tests that allow whereami to figure out where it is. The environment of such tests can be manipulated using the 'set' command. Tests can be performed conditionally upon the results of other tests using "if ... fi" constructs. Comments are lines starting with the `#' character. Leading whitespace is ignored on all lines, including comment lines. Internal Commands The syntax of this file is fairly straightforward. Tests are specified thus: The command testname is run with the single parameter (which may be split internally). If the return value is 0, the test is considered `successful' and the locations are considered `discovered'. locations is a list of comma separated identifiers, each one matching the regexp [[:alnum:]._-]+. On success, processing will skip all non-`always' statements up to the next `if' or `fi' keyword, whichever is earlier. If the location is in the list of locations discovered so far, then the statements in the `if' branch will be processed. Otherwise, if present, the statements in either the `elif' or the `else' (as appropriate) branch will be processed. Note that nesting of `if' blocks is not supported at this time. A test preceded by the word `always' is not skipped unless it is within the inactive branch of an `if' clause. The environment variable is defined as value for all subsequent test scripts and in the shell script eventually constructed by whereami. The locations will be added to the "discovered" list. The locations will be removed from the "discovered" list. The "quoted text string" will be displayed to the user on stdout. The parameter and locations may be lists, with a comma (",") used to separate multiple values. Tests Any program may be used as a test so long as it accepts a single parameter and returns zero on success and non-zero on failure. If a parameter of the test script must contain a space, it parameter will need to be quoted. A number of tests are included in the whereami package. testdhcp [interface,]pattern Tests for the assignment by DHCP of an IP address matching the specified address pattern. If not specified, the interface defaults to `eth0'. Note that the first execution of this test during a particular run of whereami induces a DHCP request on the specified interface. testmii interface Checks for the presence of a link on interface using the mii-tool utility. If a link is not found then the interface will be 'down'ed to limit side-effects on other detection later. testpppoe interface Tries to start a PPPoE connection on the specified interface. Success is returned if the connection starts. testarp interface,mac_address,ip_address Performs an arping (Debian package: iputils-arping) to look for the specified mac_address and ip_address combination on the network connected to interface. testping [interface,]ip_to_ping,ip_to_use Uses the fping program to perform a fast ping to look for the presence of a particular host on the local network. testpci pattern Searches for the pattern in the output of lspci -v. This enables checking for specific hardware, such as a particular type of docking station. testmodule pattern Searches for the pattern in the output of lsmod. This is useful for checking for the presence of a particular PCMCIA card, or possibly a particular kernel configuration. testap [interface,]scan testap pattern[,WEP Key] testap [interface,]pattern,WEP Key The pattern is a regexp (egrep regexp) used to match AP essids: when this regexp matches a detected essid the test is considered succesfull. This check does not require encryption to be set up to work, although it may not find stealthier equipment - use testssid in that case. The 'scan' option will cause a new scan, and the first call should have this option set. Subsequent calls will use the results of that first scan, reducing the overhead for those busy people who connect to many WLANs! If a WEP key is supplied, and a pattern match is found, the key will be assigned to that interface so that subsequent tests should work correctly. When using the WEP key you may in some cases desire to pass additional parameters to iwconfig. These parameters may be passed preceding the WEP key and separated with an underscore. For example "restricted_0123-4567-89" will force the card to be configured to insist on 'restricted' mode at the same time as the key was set. testappassive [interface,]scan testappassive pattern testap [interface,]pattern Checks whether the specified AP is present, passively. This check does not alter the essid on the interface, or set the WEP key like the testap test. It just uses iwlist interface scan. This is useful where you have another external script that sets up all the wifi settings, and running whereami a second time destroys the running wifi connection, as can happen on boot where networking is intialised before whereami starting in run level 2. The 'scan' option will cause a new scan, and the first call should have this option set. Subsequent calls will use the results of that first scan, reducing the overhead for those busy people who connect to many WLANs! testprocsys proc-or-sys-path,egrep-pattern Checks the specified /sys or /proc file to see if it contains the given egrep expression. Non-existent file results in failure, as well as a failed match. Useful for those interfaces that require to hotplug to be configured so that firmware can be loaded. On machine shutdown, hotplug can be disabled before networking interfaces, and this enables whereami to function correctly in those circumstances. testssid ssid[,key] Checks whether the wireless interface is in range of the specified ssid, using the key if supplied. The key should be formatted as for iwconfig. What works for me looks like da18babe100ea4beadb74324bc ("128" bits) or fe3d1b3ed7 (40 bits). This script will also respond to a TIMEOUT variable which is set before it is called, but waiting for $TIMEOUT seconds for the network to settle (default 2). This is useful for checking which wireless LAN is in range. testreceived [interface] Checks whether the interface in question has received any bytes. This is useful for checking which network interface is actually connected to a network. EXAMPLES The following examples show simple setups, firstly for a wired only configuration, and secondly for a mixed wireless and wired setup. A Simple Wired DHCP Configuration # Simple wired DHCP with two networks default undocked testmii eth0 lan if lan set INTERFACE eth0 testdhcp restart dhcp fi if dhcp testdhcp '192.168.1.1' home testdhcp '152.81.*.*' univ fi A Wired and Wireless Configuration # Configuration including both wired and wireless networks default undocked testmii eth0 lan # We prefer a wired network, but if we aren't wired # we will look for a WLAN. if lan set INTERFACE eth0 testdhcp restart dhcp else set INTERFACE wlan0 testap scan wlan fi # Try WLANs until it we find one that works if wlan testap homessid,dead-beef-dead-beef-dead-beef-be wlhome_enc testap homessid wlhome_open fi # If we are at a WLAN we should have the AP setup now if wlan # WLAN almost always will be DHCP testdhcp restart dhcp fi # Now identify the actual network if dhcp testdhcp '192.168.1.1' home testdhcp '192.168.1.2' wlhomeip testdhcp '152.81.*.*' work fi SEE ALSO whereami(8), whereami.conf(5) Further documentation is available in the /usr/share/doc/whereami directory. FILES /etc/whereami/detect.conf The file we are talking about in this here manpage. /etc/whereami/whereami.conf Defines the actions performed as a result of entering, leaving, or remaining at a particular location. LIMITATIONS The `if' syntax does not support nesting. AUTHOR This manual page was written by &dhusername; <&dhemail;> for the &debian; system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GPL version 2.
whereami-0.3.34/man/whereami.sgml0000644000000000000000000002755210620241635013542 0ustar manpage.1'. You may view the manual page with: `docbook-to-man manpage.sgml | nroff -man | less'. A typical entry in a Makefile or Makefile.am is: whereami.8: whereami.sgml docbook-to-man $< > $@ --> Andrew"> McMillan"> March 11, 2002"> 8"> debian@mcmillan.net.nz"> whereami"> Debian GNU/Linux"> GNU"> ]>
&dhemail;
&dhfirstname; &dhsurname; 2002 &dhusername; &dhdate;
&dhucpackage; &dhsection; &dhpackage; non-interatively ascertain the location of the computer and reconfigure the system appropriately. &dhpackage; DESCRIPTION `&dhpackage;' provides a configurable and extensible framework for automatic location-detection and reconfiguration of computers, typically laptops. Detection Detection is handled through the use of various network and hardware probing tools. These tools have been wrapped in small shell scripts to interface them to whereami, but the end-user with different requirements may wish to extend these in some situations. &dhpackage; processes the file /etc/whereami/detect.conf performing the tests specified in there in order to decide which location the computer is currently located at. For full detail on the discovery process, you should read the detect.conf (5) manpage. Configuration Configuration is handled through standard shell scripting. A variety of small utility scripts are provided and the author is always willing to accept more. The file /etc/whereami/whereami.conf is parsed and a script built containing the actions specified there which are associated with the locations found during the detection phase. Actions may be configured for when leaving, remaining, or arriving at a location. Once the script has been built, it is run to effect the necessary changes to the system configuration. OPTIONS This program follows the modern command-line syntax preceding each option with a double dash (`--'). Short form options are also available, but are not documented (RTFC :-) Run in debugging mode. A verbose output is provided and the resulting script is output to the screen and not executed. Run in script debugging mode. Each script supplied with `whereami' will `set -o xtrace' if the environment variable `DEBUGWHEREAMI' is set to non-blank. This parameter will set that variable. The script which is built by whereami will also respond to the environment variable. Output some logging information to syslog. The 'user' facility is used for this, and it provides an insight into which locations whereami has chosen, and why. In combination with above, this can be very useful for debugging your configuration. Also note that the default installation turns this on for apm and init actions. Just do the detection and print the location name. Don't build and run the script from whereami.conf. You might do this if you wanted to use &dhpackage;'s detection, but use something else for configuration. Perhaps you could achieve the same end with a very simple whereami.conf, but there should always be two ways to do anything :-). &dhpackage; won't normally let two copies of &dhpackage; run at the same time. Use this option if you can come up with a scenario where you should allow this to happen! This will persuade &dhpackage; to do only the detection stage, and output a list of the detected locations, suitable for use as a mapping script with ifupdown. Provides some hints to the detection process. The locations set by this parameter (a comma-delimited list) may be referenced by rules in your detect.conf. Specifies the base directory which will contain both the detect.conf and whereami.conf. The default is `/etc/whereami' which should be right for normal use. Specifies the state directory in which &dhpackage; will write files indicating the current and previous locations (iam , iwas) and the script which is run for this environment (whereiam.sh). Overrides &dhpackage;'s knowledge of where you have come from. The location_list will be a comma-separated list of the locations which you are leaving. Normally `&dhpackage;' maintains a history of locations, so that it knows where you have come from (and what might consequently have to be de-configured) as well as knowing that your location has changed. This provides a mechanism for calling software, such as init scripts, pcmcia startup or apm events, to pass some of that source information to &dhpackage;, where it is promptly ignored, at present. I have a possibly misguided idea that this might be useful somehow, but I can't think of any application of it at this point! Overrides &dhpackage;'s testing of where you are. The location_list will be a comma-separated list of the locations which you are now at. You might use this if you wished to bypass the detection phase, using some other package to handle that. SEE ALSO detect.conf (5), whereami.conf (5) There is some further documentation in HTML available in /usr/share/doc/&dhpackage;/manual FILES /etc/whereami/detect.conf Defines the process of detection. /etc/whereami/whereami.conf Defines the actions performed as a result of entering, leaving, or remaining within a particular location. KNOWN BUGS This man page only documents the current perl version of whereami. For backward compatibility with people's setups, it is possible to configure your system to run the older shell-script, which is currently undocumented. If you wish to switch from the shell script to the new perl program you will need to create an appropriate `detect.conf' file to define your location detection parameters. Your existing whereami.conf file should be compatible with this version. Once you have created a detect.conf file in /etc/whereami you should run `dpkg-reconfigure whereami' and respond to the questions. AUTHOR This manual page was written by &dhusername; <&dhemail;> for the &debian; system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GPL version 2.
whereami-0.3.34/man/detect.conf.50000644000000000000000000002277410767151131013343 0ustar .TH "detect.conf" "5" .SH "NAME" detect.conf \(em provides the configuration for detection of locations for \fBwhereami\fR. .SH "DESCRIPTION" .PP .SS "Syntax" .PP The \fBdetect.conf\fP file specifies the tests that allow \fBwhereami\fR to figure out where it is. The environment of such tests can be manipulated using the 'set' command. Tests can be performed conditionally upon the results of other tests using "if ... fi" constructs. .PP Comments are lines starting with the `#' character. Leading whitespace is ignored on all lines, including comment lines. .SS "Internal Commands" .PP The syntax of this file is fairly straightforward. Tests are specified thus: .IP "\fBtestname \fIparameter\fR \fIlocations\fR\fP" 10 The command \fBtestname\fR is run with the single \fIparameter\fR (which may be split internally). If the return value is 0, the test is considered `successful' and the \fIlocations\fR are considered `discovered'. .IP "" 10 \fIlocations\fR is a list of comma separated identifiers, each one matching the regexp ``\fI[[:alnum:]._\-]+\fP''. .IP "" 10 On success, processing will skip all non-`always' statements up to the next `if' or `fi' keyword, whichever is earlier. .IP "\fBif \fIlocation\fR \fIstatements ...\fR [elif \fIlocation\fR \fIstatements ...\fR]... [else \fIstatements ...\fR] fi\fP" 10 If the \fIlocation\fR is in the list of locations discovered so far, then the statements in the `if' branch will be processed. Otherwise, if present, the statements in either the `elif' or the `else' (as appropriate) branch will be processed. .IP "" 10 Note that nesting of `if' blocks is not supported at this time. .IP "\fBalways testname \fIparameter\fR \fIlocations\fR\fP" 10 A test preceded by the word `always' is not skipped unless it is within the inactive branch of an `if' clause. .IP "\fBset \fIvariable\fR \fIvalue\fR\fP" 10 The environment \fIvariable\fR is defined as \fIvalue\fR for all subsequent test scripts and in the shell script eventually constructed by \fBwhereami\fR. .IP "\fBat \fIlocations\fR\fP" 10 The \fIlocations\fR will be added to the "discovered" list. .IP "\fBnotat \fIlocations\fR\fP" 10 The \fIlocations\fR will be removed from the "discovered" list. .IP "\fBecho \fIquoted text string\fR\fP" 10 The \fI"quoted text string"\fR will be displayed to the user on stdout. .PP The \fIparameter\fR and \fIlocations\fR may be lists, with a comma (",") used to separate multiple values. .SS "Tests" .PP Any program may be used as a test so long as it accepts a single parameter and returns zero on success and non-zero on failure. .PP If a parameter of the test script must contain a space, it parameter will need to be quoted. .PP A number of tests are included in the whereami package. .IP "testdhcp \fI[interface,]pattern\fR" 10 Tests for the assignment by DHCP of an IP address matching the specified address \fIpattern\fR. If not specified, the \fIinterface\fR defaults to `eth0'. .IP "" 10 Note that the first execution of this test during a particular run of \fBwhereami\fR induces a DHCP request on the specified interface. .IP "testmii \fIinterface\fR" 10 Checks for the presence of a link on \fIinterface\fR using the \fBmii-tool\fR utility. If a link is not found then the interface will be 'down'ed to limit side-effects on other detection later. .IP "testpppoe \fIinterface\fR" 10 Tries to start a PPPoE connection on the specified interface. Success is returned if the connection starts. .IP "testarp \fIinterface\fR,\fImac_address\fR,\fIip_address\fR" 10 Performs an \fBarping\fR (Debian package: iputils-arping) to look for the specified \fImac_address\fR and \fIip_address\fR combination on the network connected to \fIinterface\fR. .IP "testping [\fIinterface\fR,]\fIip_to_ping\fR,\fIip_to_use\fR" 10 Uses the \fBfping\fR program to perform a fast ping to look for the presence of a particular host on the local network. .IP "testpci \fIpattern\fR" 10 Searches for the \fIpattern\fR in the output of \fBlspci \-v\fR. .IP "" 10 This enables checking for specific hardware, such as a particular type of docking station. .IP "testmodule \fIpattern\fR" 10 Searches for the \fIpattern\fR in the output of \fBlsmod\fR. .IP "" 10 This is useful for checking for the presence of a particular PCMCIA card, or possibly a particular kernel configuration. .IP "testap [\fIinterface\fR,]scan" 10 .IP "testap \fIpattern\fR[,\fIWEP Key\fR]" 10 .IP "testap [\fIinterface\fR,]\fIpattern\fR,\fIWEP Key\fR" 10 The \fIpattern\fR is a regexp (egrep regexp) used to match AP essids: when this regexp matches a detected essid the test is considered succesfull. .IP "" 10 This check does not require encryption to be set up to work, although it may not find stealthier equipment \- use testssid in that case. .IP "" 10 The 'scan' option will cause a new scan, and the first call should have this option set. Subsequent calls will use the results of that first scan, reducing the overhead for those busy people who connect to many WLANs! .IP "" 10 If a WEP key is supplied, and a pattern match is found, the key will be assigned to that interface so that subsequent tests should work correctly. .IP "" 10 When using the \fIWEP key\fR you may in some cases desire to pass additional parameters to iwconfig. These parameters may be passed preceding the WEP key and separated with an underscore. For example "restricted_0123-4567-89" will force the card to be configured to insist on 'restricted' mode at the same time as the key was set. .IP "testappassive [\fIinterface\fR,]scan" 10 .IP "testappassive \fIpattern\fR" 10 .IP "testap [\fIinterface\fR,]\fIpattern\fR" 10 Checks whether the specified AP is present, passively. This check does not alter the essid on the interface, or set the WEP key like the testap test. It just uses iwlist \fIinterface\fR scan. This is useful where you have another external script that sets up all the wifi settings, and running whereami a second time destroys the running wifi connection, as can happen on boot where networking is intialised before whereami starting in run level 2. .IP "" 10 The 'scan' option will cause a new scan, and the first call should have this option set. Subsequent calls will use the results of that first scan, reducing the overhead for those busy people who connect to many WLANs! .IP "testprocsys \fIproc-or-sys-path\fR,\fIegrep-pattern\fR" 10 Checks the specified /sys or /proc file to see if it contains the given egrep expression. Non-existent file results in failure, as well as a failed match. Useful for those interfaces that require to hotplug to be configured so that firmware can be loaded. On machine shutdown, hotplug can be disabled before networking interfaces, and this enables whereami to function correctly in those circumstances. .IP "testssid \fIssid\fR[,\fIkey\fR]" 10 Checks whether the wireless interface is in range of the specified \fIssid\fR, using the key if supplied. The key should be formatted as for iwconfig. What works for me looks like da18babe100ea4beadb74324bc ("128" bits) or fe3d1b3ed7 (40 bits). .IP "" 10 This script will also respond to a TIMEOUT variable which is set before it is called, but waiting for $TIMEOUT seconds for the network to settle (default 2). .IP "" 10 This is useful for checking which wireless LAN is in range. .IP "testreceived [\fIinterface\fR]" 10 Checks whether the \fIinterface\fR in question has received any bytes. .IP "" 10 This is useful for checking which network interface is actually connected to a network. .SH "EXAMPLES" .PP The following examples show simple setups, firstly for a wired only configuration, and secondly for a mixed wireless and wired setup. .PP \fBA Simple Wired DHCP Configuration\fR .PP .nf # Simple wired DHCP with two networks default undocked testmii eth0 lan if lan set INTERFACE eth0 testdhcp restart dhcp fi if dhcp testdhcp '192.168.1.1' home testdhcp '152.81.*.*' univ fi .fi .PP .PP \fBA Wired and Wireless Configuration\fR .PP .nf # Configuration including both wired and wireless networks default undocked testmii eth0 lan # We prefer a wired network, but if we aren't wired # we will look for a WLAN. if lan set INTERFACE eth0 testdhcp restart dhcp else set INTERFACE wlan0 testap scan wlan fi # Try WLANs until it we find one that works if wlan testap homessid,dead-beef-dead-beef-dead-beef-be wlhome_enc testap homessid wlhome_open fi # If we are at a WLAN we should have the AP setup now if wlan # WLAN almost always will be DHCP testdhcp restart dhcp fi # Now identify the actual network if dhcp testdhcp '192.168.1.1' home testdhcp '192.168.1.2' wlhomeip testdhcp '152.81.*.*' work fi .fi .PP .SH "SEE ALSO" .PP \fBwhereami\fR(8), \fBwhereami.conf\fR(5) .PP Further documentation is available in the /usr/share/doc/whereami directory. .SH "FILES" .IP "\fB/etc/whereami/detect.conf\fP" 10 The file we are talking about in this here manpage. .IP "\fB/etc/whereami/whereami.conf\fP" 10 Defines the actions performed as a result of entering, leaving, or remaining at a particular location. .SH "LIMITATIONS" .PP The `if' syntax does not support nesting. .SH "AUTHOR" .PP This manual page was written by Andrew McMillan for the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GPL version 2. .\" created by instant / docbook-to-man, Fri 02 Nov 2007, 07:10 whereami-0.3.34/man/whereami.conf.50000644000000000000000000000765710712413254013674 0ustar .TH "whereami.conf" "5" .SH "NAME" whereami.conf \(em configuration file for \fBwhereami\fR .SH "DESCRIPTION" .PP The \fBwhereami.conf\fP file specifies what \fBwhereami\fR does on leaving, remaining at or arriving at locations. (Locations are detected by \fBwhereami\fR according to specifications in the \fBdetect.conf\fP file.) .PP Comments are lines starting with the `#' character. Leading whitespace is ignored on all lines, including comment lines. .PP Other lines are of the form: .IP "\fB-\fP\fIlocation\fR \fIaction\fR" 10 The action is performed if your system was previously at this location, but is now at another location. .IP "\fB=\fP\fIlocation\fR \fIaction\fR" 10 The action is performed if your system is now at this location. .IP "\fB+\fP\fIlocation\fR \fIaction\fR" 10 The action is performed if your system is now at this location, but was previously at another location. .IP "\fB!\fP\fIlocation\fR \fIaction\fR" 10 The action is performed if your system is not at this location. .SH "HELPER SCRIPTS" .PP In addition to the normal commands available within any shell script, \fBwhereami\fR includes a number of helper scripts which may be useful. .IP "setmailrelay \fI(none | queue [smarthost] | smarthost)\fR" 10 Set the mail relay (i.e. smarthost) to "none" if you have a permanent connection, and can send e-mail directly to the recipient's mailserver. .IP "" 10 If you are not connected, set the relay to "queue" (optionally for a specific smarthost). .IP "" 10 Or send all mail to a specific smarthost, if that is what you need in this location. .IP "setresolver \fI\fR" 10 The \fI\fR should be something like: \fIsearch localhost mydomain.com nameserver 1.2.3.4\fR (all on one line) to specify the domain search path and the nameserver to use. .IP "" 10 If you have \fBresolvconf\fR installed, this script will interface with that to manupulate the /etc/resolv.conf file and control DNS resolution. This is recommended. .IP "" 10 If you are not using resolvconf, then this will directly rewrite your /etc/resolv.conf file, inserting a section similar to the manner in which DHCP works. .IP "setproxy \fI(start | stop | none | )\fR" 10 Use this script to reconfigure your local \fBoops\fR or \fBsquid\fR proxy server to use a specific upstream proxy, no upstream proxy, or to stop the proxy server completely. .IP "" 10 The upstream proxy should be specified as " ", e.g.: \fBsetproxy 192.168.55.3 3128\fR .IP "" 10 For a local \fBsquid\fR proxy you can optionally also provide a complete set of parameters for the "cache_peer" directive (without the "cache_peer" name itself). See the squid.conf file for full details of this syntax. e.g.: \fBsetproxy 192.168.55.3 parent 3128 3140 login=user:password\fR .IP "settimezone \fItimezone\fR" 10 Use this to set your timezone differently. .IP "masqmail_route \fIroute_name\fR" 10 Use this to reconfigure \fBmasqmail\fR to use a different masqmail routing. .SH "SEE ALSO" .PP \fBwhereami\fR(8), \fBdetect.conf\fP(5) .PP Further documentation is available in the /usr/share/doc/whereami directory. .SH "FILES" .IP "\fB/etc/whereami/whereami.conf\fP" 10 The file we are talking about in this here manpage. .IP "\fB/etc/whereami/whereiam.sh\fP" 10 The script that is built based on the information in this configuration file and then executed by \fBwhereami\fR. .SH "LIMITATIONS" .PP There should be a configuration program so that the user does not have to do any script programming. .SH "AUTHOR" .PP This manual page was written by Andrew McMillan for the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GPL version 2. .\" created by instant / docbook-to-man, Fri 02 Nov 2007, 07:10 whereami-0.3.34/man/whereami.conf.sgml0000644000000000000000000002074710620241635014465 0ustar manpage.1'. You may view the manual page with: `docbook-to-man manpage.sgml | nroff -man | less'. A typical entry in a Makefile or Makefile.am is: whereami.conf.5: whereami.conf.sgml docbook-to-man $< > $@ --> Andrew"> McMillan"> December 24, 2001"> 5"> debian@mcmillan.net.nz"> whereami.conf"> Debian GNU/Linux"> GNU"> ]>
&dhemail;
&dhfirstname; &dhsurname; 2001 &dhusername; &dhdate;
&dhucpackage; &dhsection; &dhpackage; configuration file for whereami DESCRIPTION The whereami.conf file specifies what whereami does on leaving, remaining at or arriving at locations. (Locations are detected by whereami according to specifications in the detect.conf file.) Comments are lines starting with the `#' character. Leading whitespace is ignored on all lines, including comment lines. Other lines are of the form: location action The action is performed if your system was previously at this location, but is now at another location. location action The action is performed if your system is now at this location. location action The action is performed if your system is now at this location, but was previously at another location. location action The action is performed if your system is not at this location. HELPER SCRIPTS In addition to the normal commands available within any shell script, whereami includes a number of helper scripts which may be useful. setmailrelay (none | queue [smarthost] | smarthost) Set the mail relay (i.e. smarthost) to "none" if you have a permanent connection, and can send e-mail directly to the recipient's mailserver. If you are not connected, set the relay to "queue" (optionally for a specific smarthost). Or send all mail to a specific smarthost, if that is what you need in this location. setresolver <resolv.conf stanza> The <resolv.conf stanza> should be something like: search localhost mydomain.com nameserver 1.2.3.4 (all on one line) to specify the domain search path and the nameserver to use. If you have resolvconf installed, this script will interface with that to manupulate the /etc/resolv.conf file and control DNS resolution. This is recommended. If you are not using resolvconf, then this will directly rewrite your /etc/resolv.conf file, inserting a section similar to the manner in which DHCP works. setproxy (start | stop | none | <upstream_proxy>) Use this script to reconfigure your local oops or squid proxy server to use a specific upstream proxy, no upstream proxy, or to stop the proxy server completely. The upstream proxy should be specified as "<name or ip> <port>", e.g.: setproxy 192.168.55.3 3128 For a local squid proxy you can optionally also provide a complete set of parameters for the "cache_peer" directive (without the "cache_peer" name itself). See the squid.conf file for full details of this syntax. e.g.: setproxy 192.168.55.3 parent 3128 3140 login=user:password settimezone timezone Use this to set your timezone differently. masqmail_route route_name Use this to reconfigure masqmail to use a different masqmail routing. SEE ALSO whereami(8), detect.conf(5) Further documentation is available in the /usr/share/doc/whereami directory. FILES /etc/whereami/whereami.conf The file we are talking about in this here manpage. /etc/whereami/whereiam.sh The script that is built based on the information in this configuration file and then executed by whereami. LIMITATIONS There should be a configuration program so that the user does not have to do any script programming. AUTHOR This manual page was written by &dhusername; <&dhemail;> for the &debian; system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GPL version 2.
whereami-0.3.34/Makefile0000644000000000000000000000002710622146007011725 0ustar all: cd man; $(MAKE) whereami-0.3.34/whereami.conf0000644000000000000000000000662510620241635012750 0ustar # # # # Sample configuration file for 'whereami' copyright Andrew McMillan, 1999 # # # # Regardless, we always rotate the netscape preferences file. # =any savelog -p /home/andrew/.netscape/preferences.js # =any cat /home/andrew/.netscape/preferences.js.0 >>/home/andrew/.netscape/preferences.js # # By default just send mail directly across the internet # =any MAIL_RELAY="none" # # By default send all mail via our main mailserver, since we do TLS+SASL there # =any MAIL_RELAY="smtp.mydomain.com" # By default we assume that the detection configured routing =any GATEWAY="" # By default we assume we have an unfiltered internet connection =any PROXY="none" =any NTPDAEMON=/etc/init.d/ntp-server =any NTPSERVER=ntp ## You will need to install the "resolvconf" package for these to ## work, and edit the following couple of stanzas to the right ## interface names. ## This only happens if we are not at a WLAN #!wlan ifconfig ath0 down #!wlan resolvconf -d ath0 ## This only happens if we are not at a LAN #!lan ifconfig eth0 down #!lan resolvconf -d eth0 # # Catalyst # +catalyst bind-forwarders 192.168.3.10 # +catalyst setresolver search laptop.cat-it.co.nz wgtn.cat-it.co.nz catalyst.net.nz nameserver 127.0.0.1 # +catalyst mount /plato/general # +catalyst mount /home/andrew/plato # =catalyst export PROXY="192.168.3.10 8080" # =catalyst export NTPSERVER="plato" # =catalyst export GATEWAY="192.168.3.1" # # At home # =home export PROXY="172.16.85.3 3128" # =home export NTPSERVER="adorno" # =home setresolver search localhost mcmillan.net.nz nameserver 172.16.85.2 # +home smbmount //hegel/c /hegel/c -I 172.16.85.10 -N >>/dev/null # -home umount /hegel/* >>/dev/null # # AmTrust in Auckland # +amtrust bind-forwarders 192.168.5.1 # +amtrust setresolver search laptop.cat-it.co.nz akld.capit.co.nz catalyst.net.nz nameserver 127.0.0.1 # # AGP in Sydney # +agp bind-forwarders 10.3.0.10 # +agp setresolver search laptop.cat-it.co.nz agp.com.au catalyst.net.nz nameserver 127.0.0.1 # # When we're in Sydney we want to change to the correct timezone, and # # then change it back when we leave. # +agp rm /etc/localtime # +agp ln -s /usr/share/zoneinfo/Australia/Sydney /etc/localtime # -agp rm /etc/localtime # -agp ln -s /usr/share/zoneinfo/Pacific/Auckland /etc/localtime # # TTP In Auckland # =ttpak export MAIL_RELAY=10.2.0.59 # =ttpak export PROXY="10.2.0.1 3128" # # First we mount the drives if we are in the docking station. These always # # get unmounted cleanly because we have to shut down to remove the laptop. # =catalyst if ( grep "^docked" /var/lib/whereami/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 # =docked mount /dos/f; mount /dock # =docked /root/bin/bkup2dock & # =undocked killall dhclient 2>/dev/null; killall dhclient3 2>/dev/null # =undocked MAIL_RELAY=queue # # So we can override this for any configuration # =any setmailrelay ${MAIL_RELAY} # =any setoops ${PROXY} # # Set any gateway that got called for in passing # =any [ -n "${GATEWAY}" ] && route add default gw ${GATEWAY} 2>/dev/null # # Use any reasonable NTP server # =undocked if /bin/false ; then # =any ${NTPDAEMON} stop # =any ntpdate ${NTPSERVER} # =any ${NTPDAEMON} start # =undocked fi # =any /usr/local/sbin/local-firewalling start # =any sync # =any ( /etc/init.d/cupsys stop; sleep 10; /etc/init.d/cupsys start ) >/dev/null 2>&1 & whereami-0.3.34/whereami.webprj0000644000000000000000000000333010620241635013302 0ustar Andrew McMillan debian@mcmillan.net.nz whereami-0.3.34/bin/0000755000000000000000000000000010622152557011045 5ustar whereami-0.3.34/bin/userwhereami.pl0000644000000000000000000000616110620241635014100 0ustar #!/usr/bin/perl # # by Patrice Neff, based on whereamy by Adnrew McMillan # released under the GNU GPL version 2 # # Verson: 0.1 - 13 Jul 2002 # # This is a user daemon for whereami which watches the # file /etc/whereiam/iam and executes the actions in # ~/.whereami.conf # use strict; my $home = $ENV{HOME}; my $basedir = "/etc/whereami"; ############################################################ # gather current location information and build the script # based on user configuration file ############################################################ sub process_location { my $last_locations = ""; my $now_locations = ""; my %whereiam; my %whereiwas; my ( $confname, $scriptname ) = @_; my ($k, $v); my ( $condition, $script_line ); my $found; # get location information if ( "" eq "$now_locations" ) { # Read where we last were from where we wrote it last time open ( NOWLOCN, "< $basedir/iam" ) && do { while ( ) { chomp; $whereiam{$_} = 1; $now_locations .= $_ . ","; } close NOWLOCN; chop $now_locations; }; } if ( "" eq "$last_locations" ) { # Read where we last were from where we wrote it last time open ( LASTLOCN, "< $home/.iam" ) && do { while ( ) { chomp; $whereiwas{$_} = 1; $last_locations .= $_ . ","; } close LASTLOCN; chop $last_locations; }; } # Write file of these locations for next time... open ( IAMLOC, "> $home/.iam" ) && do { while( my ($k, $v) = each( %whereiam ) ) { print "iam: $k\n"; print IAMLOC "$k\n"; } close IAMLOC; }; print "locs: $last_locations => $now_locations\n"; open ( WHEREIAM, "> $scriptname" ) or die( "Can't open \"$scriptname\" for output: "); open ( LOCN_CONFIG, "< $confname" ) or die( "Can't open \"$confname\" for input: "); printf ( WHEREIAM "#!/bin/sh\n[ \"\$DEBUGWHEREAMI\" = \"1\" ] && set -o xtrace\nLASTLOCN=%s\nLOCATION=%s\n\n", $last_locations, $now_locations ); my $start_with = "+"; if ( $now_locations eq $last_locations ) { return 0; } while ( ) { /^\s*$/ && next; /^\s*#/ && next; s/^\s+//; ($condition, $script_line) = split( /\s+/, $_, 2); if ( $start_with eq "=" ) { $found = 0; while( ($k, $v) = each( %whereiam ) ) { next if ( $found ); $condition =~ /=$k$/ && do { print WHEREIAM "$script_line"; $found = 1; }; } } else { $found = 0; while( ($k, $v) = each( %whereiwas ) ) { next if ( $found ); $condition =~ /-$k$/ && do { print WHEREIAM "$script_line"; $found = 1; }; } $found = 0; while( ($k, $v) = each( %whereiam ) ) { next if ( $found ); $condition =~ /[+=]$k$/ && do { print WHEREIAM "$script_line"; $found = 1; }; } } } close WHEREIAM; close LOCN_CONFIG; return 1; } while(1) { print "waking up\n"; if(process_location("$home/.whereami.conf", "$home/.whereiam.sh")) { system("sh -c \". $home/.whereiam.sh\""); } sleep(60); } whereami-0.3.34/bin/whereami.init0000755000000000000000000000075310620241635013535 0ustar #!/bin/sh # # Start or stop 'whereami' # # Andrew McMillan # # Only the 'start' case is actually interesting at this point test -x /usr/sbin/whereami || exit 0 case "$1" in start) echo -n "Where Am I: " start-stop-daemon --start --quiet --exec /usr/sbin/whereami echo "." ;; stop) ;; restart) ;; force-reload) ;; *) echo "Usage: /etc/init.d/whereami {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0 whereami-0.3.34/bin/whereami.apm0000644000000000000000000000200210620241635013331 0ustar #!/bin/sh # $Id: whereami.apm,v 1.6 2004/01/09 12:05:50 andrew Exp $ # This script will run whereami on suspend and resume of the machine. # If you have logger installed, whereami output will be sent to syslog. # # On suspend/resume, whereami will change to the location specified in # the config file for SUSPEND_LOCATION and RESUME_LOCATION. # If the location is 'auto', whereami performs location detection. # # For example: # SUSPEND_LOCATION=disconnected # RESUME_LOCATION=auto WHEREAMI=/usr/sbin/whereami CONFIG=/etc/whereami/apm.conf [ -r $CONFIG ] || exit 0 [ -x $WHEREAMI ] || exit 0 . $CONFIG case "$1,$2" in suspend,*|standby,*) LOCATION=$SUSPEND_LOCATION ;; resume,suspend|resume,standby) LOCATION=$RESUME_LOCATION ;; esac [ -n "$LOCATION" ] || exit 0 [ "$LOCATION" = "auto" ] && LOCATION= if [ -x /usr/bin/logger ] ; then logger -t whereami "APM event $1 $2 whereami $LOCATION" $WHEREAMI --run_from apm --syslog $LOCATION | logger -t whereami else $WHEREAMI --run_from apm --syslog $LOCATION fi whereami-0.3.34/bin/whereami0000755000000000000000000004615110620241635012575 0ustar #!/usr/bin/perl # # $Id: whereami.pl,v 1.33 2007/02/25 18:53:11 andrew Exp $ # # by Andrew McMillan, Catalyst IT Ltd, (c) 2001-2005 licensed # for use under the Gnu GPL version 2 # use strict; use Getopt::Long qw(:config permute); # allow mixed args. my $debug = 0; my $syslogging = 0; my $doactions = 1; my $mapping = 0; my $locking = 1; my $scriptdebugging = 0; my $helpmeplease = 0; my $basedir = "/etc/whereami"; my $lockdir = "/var/run"; my $statedir = "/var/lib/whereami"; my $scriptbase = "/usr/share/whereami"; my $caller = ""; my $run_from = ""; my $default = "none"; my $last_locations = ""; my $now_locations = ""; my $hint_locations = ""; my %whereiam; my %whereiwas; my $locn_seq = 1; # Can't think why, but sorting might become important sub handle_location_specs { # Note global variable... $now_locations .= "," if ( $now_locations ); $now_locations .= $_[0] ; } GetOptions ('debug!' => \$debug, 'syslog!' => \$syslogging, 'actions!' => \$doactions, 'mapping' => \$mapping, 'locking!' => \$locking, 'scriptdebug!' => \$scriptdebugging, 'basedir=s' => \$basedir, 'statedir=s' => \$statedir, 'scriptbase=s' => \$scriptbase, # Deliberately undocumented! 'from=s' => \$last_locations, 'run_from=s' => \$caller, 'hint=s' => \$hint_locations, 'help' => \$helpmeplease, '<>' => \&handle_location_specs ); show_usage() if ( $helpmeplease ); if ( $syslogging ) { use Sys::Syslog; openlog( 'whereami', 'pid', 'user'); } my $LOCKFILENAME = "$lockdir/whereami.started"; if ( $locking && ! create_process_lock() ) { syslog "warning", "It seems that another whereami is already running. Exiting to avoid conflict." if ( $syslogging ); print "whereami is already running - I shall exit.\n" if ( $debug || $scriptdebugging ); exit 0; } if ( $mapping ) { $doactions = 0; } print "BaseDir: $basedir\n" if ( $debug ); # Set a bunch of important environment for scripts to use $ENV{'BASEDIR'} =$basedir; $ENV{'STATEDIR'} =$statedir; $ENV{'LOCKDIR'} =$lockdir; $ENV{'PATH'} = "$scriptbase/tests:$scriptbase/actions:$scriptbase:/bin:/usr/bin:/sbin:/usr/sbin:$basedir/tests:/usr/local/share/whereami"; $ENV{'DEBUGWHEREAMI'} = "1" if ( $debug || $scriptdebugging ); if ( "" eq "$last_locations" ) { # Read where we last were from where we wrote it last time open ( LASTLOCN, "< $statedir/iam" ) && do { while ( ) { chomp; $whereiwas{$_} = 1; $last_locations .= $_ . ","; } close LASTLOCN; chop $last_locations; }; } print "Last: $last_locations\n" if ( $debug ); if ( "" eq "$now_locations" ) { if ( "" ne "$hint_locations" ) { # Add any hint locations into the starting mix foreach( split( /[,]+/, $hint_locations ) ) { printf ( "*hint**location: %s\n", $_) if ( $debug ); $whereiam{$_} = $locn_seq++; } } # Actually do the detection. detect_location( "$basedir/detect.conf" ); } else { # Then we just are wherever we were told on the command line. foreach( split( /[,]+/, $now_locations ) ) { printf ( "*******location: %s\n", $_) if ( $debug ); $whereiam{$_} = $locn_seq++; } } save_locations() if ( $now_locations ne $last_locations ); $whereiam{'any'} = 0; # We are always in the 'any' location. if ( $doactions ) { # Create a script for all of those locations process_location("$basedir/whereami.conf", "$statedir/whereiam.sh"); if ( $debug ) { # Show it to us open( SCRIPTFILE, "< $statedir/whereiam.sh" ) or die_cleanly( "Can't read script file"); while( ) { print; } close SCRIPTFILE; } # Run the script we have constructed chmod 0755, "$statedir/whereiam.sh"; system( "sh", "-c", "$statedir/whereiam.sh" ); } elsif ( $mapping) { # Print a list of mappings for ifupdown's mapping mechanism print "$now_locations\n"; } else { # Just enumerate what we would otherwise do, for debugging while( my ($k, $v) = each ( %whereiam ) ) { print "$k\n"; } } # Delete our locking file / timestamp exit_cleanly(0); # We should never reach here. exit 255; ############################################################ # Miscellaneous routines ############################################################ ############################################################ # We should call this, rather than exit, after we have # created our process lock ############################################################ sub exit_cleanly { my $exit_code = shift; remove_process_lock(); closelog if ( $syslogging); exit $exit_code; } ############################################################ # We should call this, rather than die, after we have created # our process lock. ############################################################ sub die_cleanly { # If die-ing is clean in the first place... print STDERR @_, "\n"; exit_cleanly(1); } ############################################################ # Tell the nice user how we do things. Short and sweet. ############################################################ sub show_usage { print < $LOCKFILENAME.$$" ) or die "Can't write PID file to $LOCKFILENAME.$$"; print LOCKFILEOUT "$$"; close LOCKFILEOUT; if ( ! link( "$LOCKFILENAME.$$", "$LOCKFILENAME" ) ) { # Read the PID from the existing lockfile. open( LOCKFILEIN, "< $LOCKFILENAME") or die "Can't open existing lock file $LOCKFILENAME for checking"; my $oldpid = ; close LOCKFILEIN; if ( -d "/proc/$oldpid" ) { # Process still running so no lock. Of course this is not a _guarantee_ # (another process might have that PID now) but at least it errs in the # conservative direction warn "create_process_lock(): another process ($oldpid) is running.\n" if ( $debug ); unlink( "$LOCKFILENAME.$$" ); return 0; } # OK, so try and remove the lock... unlink( "$LOCKFILENAME" ) or do { warn "failed to remove stale lockfile (PID $oldpid). Help!\n" if ( $debug ); unlink( "$LOCKFILENAME.$$" ); return 0; }; warn "create_process_lock(): removed stale lockfile from PID $oldpid.\n" if ( $debug ); # Now attempt to put _our_ lock in there. if ( ! link( "$LOCKFILENAME.$$", "$LOCKFILENAME" ) ) { warn "failed to acquire lock after removing stale lock.\n" if ( $debug ); unlink( "$LOCKFILENAME.$$" ); return 0; } warn "successfully acquired lock\n" if ( $debug ); } # And so now we can unlink the other directory entry unlink( "$LOCKFILENAME.$$" ); return 1; } ############################################################ # Remove the lock file when we have finished processing ############################################################ sub remove_process_lock { if ( -f $LOCKFILENAME ) { # Check that the lock PID matches our PID open LOCKFILE, "< $LOCKFILENAME"; my $oldpid = ; close LOCKFILE; if ( "$$" ne "$oldpid" ) { warn "Lock not removed as it doesn't match our PID!\n"; syslog( "warning", "Lock not removed as it doesn't match our PID!\n") if ( $syslogging ); return; } unlink $LOCKFILENAME; } else { warn "Hmmmm... Strange. Our lockfile is missing!\n"; syslog( "warning", "Hmmmm... Strange. Our lockfile is missing!\n") if ( $syslogging ); } } ############################################################ # Save the location we have found for next time. ############################################################ sub save_locations { # Rotate saved 'where we were' files. for ( my $i=5; $i >= 0; $i-- ) { rename "$statedir/iwas.$i", "$statedir/iwas." . ($i + 1); } rename "$statedir/iwas", "$statedir/iwas.0"; rename "$statedir/iam", "$statedir/iwas"; # Write file of these locations for next time... open ( LASTLOCN, "> $statedir/iam" ) && do { while( my ($k, $v) = each( %whereiam ) ) { print LASTLOCN "$k\n"; } close LASTLOCN; }; } ############################################################# ## remove quotes from the parameter variable ############################################################# sub remove_quotes { my $in = shift; $in =~ /^(['"])(.*)['"]$/ && do { $in =~ /^[$1](.*)[$1]$/ && do { return $1; }; }; return $in; } ############################################################ # Try and figure out where we actually are ############################################################ sub detect_location { my ( $confname ) = @_; open( DETECT, "< $confname" ) or die_cleanly( "Can't open detect configuration file: $confname"); my $state = "looking"; my $startstate = "looking"; my $dhcp = ""; my $lno=0; my @splitup; my $testname; my $params; my $locations; print "Line State : Script\n" if ( $debug ); print "---- ----------:----------------------------------------------------\n" if ( $debug ); syslog "debug", "Line State : Script\n" if ( $syslogging ); syslog "debug", "---- ----------:----------------------------------------------------\n" if ( $syslogging ); while( ) { $lno++; chomp; next if ( /^\s*#/ ); next if ( /^\s*$/ ); $startstate = $state; # Trim leading blanks s/^\s+//; /^echo\s+(\S.*)$/i && do { # Inform the nice user :-) print remove_quotes($1), "\n"; next; }; /^else/i && do { # Note the test for 'success', in case the 'if' clause was successful. That # would imply that 'if' was true before that, and that we should still skip # the else clause contents... if ( $state =~ /^(if)|(success)|(!else)/ ) { $state = "!else"; } elsif ( $state eq "!if" ) { $state = "else"; } else { die_cleanly "$confname ($lno): 'else' without prior 'if'"; } next; }; # Deal to a 'fi ...' line /^fi/i && do { if ( $state =~ /^!?(if)|(else)|(success)/ ) { $state = "looking"; } else { die_cleanly "$confname ($lno): 'fi' without prior 'if' or 'else'"; } next; }; # Deal to an 'if location[,...]' line /^if\s+(\S.*)$/i && do { if ( $state =~ /^!?(if)|(else)/ ) { die_cleanly "$confname ($lno): 'if' may not be nested at this time"; } $state = "!if"; foreach( split( /[,]+/ , $1) ) { if ( exists( $whereiam{$_} ) ) { $state = "if"; last; } } next; }; # Deal to an 'elif location[,...]' line /^elif\s+(\S.*)$/i && do { if ( $state =~ /^(if)|(success)|(!else)/ ) { # If any 'if' has been successful then we skip everything $state = "!else"; next; } $state = "!if"; foreach( split( /[,]/ , $1) ) { if ( exists( $whereiam{$_} ) ) { $state = "if"; last; } } next; }; # So we just go to the next line if we are inside a non-processing chunk next if ( $state =~ /^[\!#]/ ); # Skip to the next if we have been successful and we don't always do this. next if ( $state =~ /^success/ && $_ !~ /^always/i ); # Shouldn't really have any whitespace lines here, but ignore anyway next if ( /^\s*$/ ); # Skip to the next if this is a comment next if ( /^\s*#/ ); printf ( "%#4d %-10.10s %s\n", $lno, $state, $_) if ( $debug ); syslog ( "debug", "%#4d %-10.10s: %s\n", $lno, $state, $_ ) if ( $syslogging ); # Strip the always, if it is there. s/^always\s+//i; # Now using a more complex process to split the line, so that we # can handle spaces, quoting and commas inside the parameters. s/^(\S+)\s*// && do { $testname = $1; }; s/\s*([[:alnum:].,_-]+)$// && do { $locations = $1; }; $params = $_; printf( "testname[%s] parameters[%s], locations[%s]\n", $testname, $params, $locations ) if($debug); # get rid of quote characters in params. # this is a bit tricky... $params = remove_quotes($params); printf("unquoted parameters: [%s]\n",$params) if($debug); # In future we might implement some of the commoner tests directly # in here. Especially DHCP, where we can do one pass to resolve # all possibilities... # For now we will run a script for each test we want to be available # which makes things more easily extensible, especially by end users. # The script needs to take one parameter, and give a zero exit # result on success. if ( $testname =~ /^set$/i ) { # The "set name value" syntax doesn't change the processing state $ENV{$params} = $locations; } elsif ( $testname =~ /^default$/i ) { # The "default name" syntax doesn't change the processing state $default = $locations; } elsif ( $testname =~ /^at$/i ) { # Force a location $state = "success"; printf ( "****************> Internal 'at' - adding locations: %s\n", $locations) if ( $debug ); syslog ( "notice", "****************> Internal 'at' - adding locations: %s\n", $locations) if ( $syslogging ); foreach( split( /[,]+/, $locations ) ) { printf ( "*******location: %s\n", $_) if ( $debug ); $whereiam{$_} = $locn_seq++; } } elsif ( $testname =~ /^notat$/i ) { # Force removal of a location $state = "success"; printf ( "****************> Internal 'notat' - removing locations: %s\n", $locations) if ( $debug ); syslog ( "notice", "****************> Internal 'notat' - removing locations: %s\n", $locations) if ( $syslogging ); foreach( split( /[,]+/, $locations ) ) { next if ( ! defined $whereiam{$_} ); printf ( "******* not at : %s\n", $_) if ( $debug ); delete $whereiam{$_}; } } elsif ( 0 == system( $testname, $params ) ) { $state = "success"; printf ( "****************> Test successful - adding locations: %s\n", $locations) if ( $debug ); syslog ( "notice", "****************> Test successful - adding locations: %s\n", $locations) if ( $syslogging ); foreach( split( /[,]+/, $locations ) ) { printf ( "*******location: %s\n", $_) if ( $debug ); $whereiam{$_} = $locn_seq++; } } } $now_locations = ""; while( my ($k, $v) = each( %whereiam ) ) { print "$k\n" if( $debug ); $now_locations .= $k . ","; } chop $now_locations; if ( "$now_locations" eq "" ) { $now_locations = $default; $whereiam{$default} = $locn_seq++; } } ############################################################ # Process the locations we have found to apply. ############################################################ sub process_location { my ( $confname, $scriptname ) = @_; my ($k, $v); my ( $condition, $script_line ); my $found; open ( WHEREIAM, "> $scriptname" ) or die_cleanly( "Can't open \"$scriptname\" for output: "); open ( LOCN_CONFIG, "< $confname" ) or die_cleanly( "Can't open \"$confname\" for input: "); printf ( WHEREIAM "#!/bin/sh\n[ \"\$DEBUGWHEREAMI\" = \"1\" ] && set -o xtrace\nLASTLOCN=%s; export LASTLOCN\nLOCATION=%s; export LOCATION\n\n", $last_locations, $now_locations ); my $start_with = "+"; if ( $now_locations eq $last_locations ) { printf( "Continuing at %s\n", $now_locations); syslog( "notice", "Continuing at %s\n", $now_locations) if ( $syslogging ) ; $start_with = "=" } else { printf( "Moving from %s to %s\n", $last_locations, $now_locations); syslog ( "notice", "Moving from %s to %s", $last_locations, $now_locations ) if ( $syslogging ); } while ( ) { /^\s*$/ && next; /^\s*#/ && next; s/^\s+//; ($condition, $script_line) = split( /\s+/, $_, 2); if ( $start_with eq "=" ) { if ( $condition =~ /^=/ ) { $found = 0; while( ($k, $v) = each( %whereiam ) ) { next if ( $found ); $condition =~ /=$k$/ && do { print "=>$condition<=|=>$k<|>$script_line" if ( $debug ); print WHEREIAM "$script_line"; syslog( "debug", "$condition $script_line") if ( $syslogging ); $found = 1; }; } } elsif ( $condition =~ /^!/ ) { my $not_locn = substr( $condition, 1); if ( ! exists( $whereiam{$not_locn} ) ) { print WHEREIAM "$script_line"; print "=>$condition<=|=>$k<|>$script_line" if ( $debug ); syslog( "debug", "$condition $script_line") if ( $syslogging ); } } } else { if ( $condition =~ /^-/ ) { $found = 0; while( ($k, $v) = each( %whereiwas ) ) { next if ( $found ); $condition =~ /-$k$/ && do { print "->$condition<-|->$k<|>$script_line" if ( $debug ); print WHEREIAM "$script_line"; syslog( "debug", "$condition $script_line") if ( $syslogging ); $found = 1; } unless ( exists $whereiam{$k} ); } } elsif ( $condition =~ /^[+=]/ ) { $found = 0; while( ($k, $v) = each( %whereiam ) ) { next if ( $found ); $condition =~ /[+=]$k$/ && do { print "+>$condition<+|+>$k<|>$script_line" if ( $debug ); print WHEREIAM "$script_line"; syslog( "debug", "$condition $script_line") if ( $syslogging ); $found = 1; } unless ( exists $whereiwas{$k} && $condition =~ /^[+]/ ); } } elsif ( $condition =~ /^!/ ) { my $not_locn = substr( $condition, 1); if ( ! exists( $whereiam{$not_locn} ) ) { print WHEREIAM "$script_line"; print "=>$condition<=|=>$k<|>$script_line" if ( $debug ); syslog( "debug", "$condition $script_line") if ( $syslogging ); } } } } close WHEREIAM; close LOCN_CONFIG; } whereami-0.3.34/AUTHORS0000644000000000000000000000004610620241635011337 0ustar Andrew McMillan whereami-0.3.34/html/0000755000000000000000000000000010620241635011233 5ustar whereami-0.3.34/html/actions.html0000644000000000000000000001774510620241635013577 0ustar whereami - Location Actions

whereami - Actions


Actions

When I arrive at a new location the main thing I need to do is configure networking.

  • I run a nameserver on my laptop and I want to configure that to use the local network nameserver as a forwarder
  • I want to configure sendmail to use the local mailserver as a relay
  • I want to change my Netscape settings to operate appropriately with the caches and proxies at the location
  • I want to mount appropriate local network drives
  • When I'm docked, I want to save any changes to various important files onto a disk in the docking station

Configuration

The /etc/whereami/whereami.conf file contains lines much like a normal shell script, except that each line is prefixed by a string consisting of:

  • a character indicating the circumstances in which the action applies
  • the name of the location to which this action relates

Circumstances

CharacterSituation in which the action applies
+The 'plus' sign indicates that this action will be performed when the system arrives at the specified location: that is, the system is now at the specified location but was previously at another location
-The 'minus' sign indicates that this action will be performed when the system has left the specified location: that is, the system was previously at the specified location but is now at another location
=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

Location

The location name may be one of those detected, or 'any', which matches any location. At some point in the future I will probably rewrite whereami to allow the location specification to be a regular expression.

Examples

Putting it all together you end up with lines like:

=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

The first two lines above will always apply. The following three lines will apply whenever we 'arrive' at Catalyst. First /etc/named.conf will be modified so that named 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, /etc/mail/sendmail.cf will be modified so that sendmail uses the local mail server as a relay.

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. :-)

The file can contain full shell script functionality, so this fragment:

=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

will execute an 'if' statement and only do the mount and backup if the machine is docked.


Action scripts

A number of useful scripts are included in the directory /usr/share/whereami which is added to the end of the path for the execution of the script which whereami generates.

I'm hoping that this section will expand once people other than myself start using the program.

bind-forwarders
 
 
Use: "bind-forwarders <ip-address>"

This edits your /etc/named.conf file to change to the specified forwarder.

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:

		192.168.2.80;	// bind-forwarders

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.

masqmail_route
 
 
This updates masqmail routing.

Use "masqmail_route <route name> "

Masqmail allows for multiple routing configurations to be set up in /etc/masqmail/masqmail.conf and other masqmail routing files.

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.

setmailrelay
 
 

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.

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.

Use "setmailrelay none" for when you don't need a smarthost at all and can send mail directly.

Use "setmailrelay <smarthost>" where <smarthost> is the IP name or address of the system to use as a mail relay

This script was originally supplied by Jos Visser and I've made a few minor adjustments to suit this use.

setresolver
 
 
 
 
This script is used to adjust your resolv.conf file to suit the current environment.

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.

You should review the manpage for resolv.conf (5) for full details of the information in this file, but in basic form you can:

  • search <domain> [<domain> ...]
  • nameserver <ip address> [<ip address>] [<ip address>]

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.

If you have any suggestions, e-mail them to me and I'll distribute them along with future releases of whereami.

 


whereami   |   Location Detection   © Andrew McMillan, 1999-2005 released under the GPL

whereami-0.3.34/html/images/0000755000000000000000000000000010620241635012500 5ustar whereami-0.3.34/html/images/q1.gif0000644000000000000000000001125510620241635013514 0ustar GIF87a`~FB oh ϵƸȒ-0{t*`HE$#Q]X#ٙB.,?Djjbc\ ^}yC4-,&YRRL让jay,^^XŸwŻL{{t$66/TN FED= :6 ?,`~pH,ȤrlSШtJZجv;uzK.^MVx{Ϸh\bNEpCqCP5YDm]R=QX)UPWo)lS5"ŮqpҀJسٷQ+"""0 ةXOD)5V0BA`A vkl5SyiSRP!@T8p! bL"rÅq>|0|`!GXsP &0~@ OXT%{j붴)A/F/GY-{2G$rǍ hk׊i@A6ӘZJ ;sA9f043fР_8er,kت_Z. IKh~p8phQ6( x*;HzHxDy0U} px.p ,pBPrӅdbBrW_ Р݋( <)*<]xY=FBa*%B4t`:Y'RPv! CnFQ]C!-̀ q^,秞꩝,P/Rp cԘYfrvX}/)*yp 6*v=\ )IS:Ibj"Ć+, Q`:@&YKSȀ+up r*z 3P 1[(?kt1&k08$\ZAQ:C:Dy,% "'jҎt胒7r 4/4 9`AZ.8f5 +*C@q70F=#Lz=pѣpo}1IڢpK5(&=4%vl2'ԟisʌ% [-iVz ;z-4Q | - -`#sfDj &>z6v<^v+@@WF$|{38 n͊K ^}I`yJLkх]+6sKhЁ5mRR1'!kʖn.Nէi4]LU`kBM0Nu@ -9@ ` čRT8!Q2t ^, RFt+ ޯ)$HZO < XGI'\f>8K`Y nUg4 R4 =t`ܧ}p*թ DG*D‚ְC2@`V.E-B2!Cua*P,']zx itp\TS#Y3J ЊN ČXgGPzěPd:@ėDDŽ@ٔ!0A xA,ePs gQI-J1(Ā@@ְ0Gt IG uڀ {z#G x;;tBΕo;iN7Ғy(To53چNs]́ DŽ @ 0x,s[ݷi:U!b $\íФU||(0 9P":Z\ W ! itw@Km4 JAV| @2bxG1DRQtTCfcŒWqY4mnE&%@a Ԩv+nW_Pb׬aTh75kA_ ,WsR8ׁۖ/ `0ܑX@JW>@"+0Q~@ TER Ukf%p3i{Hx Ű 2i N@m9T9f0\AiK(B$XB1xL CN4d`n" sP+ rL^ ԕ}+}T0a7GxJPH}U2 }G\e oQLA !`)'.xo)V{fb 22? ((+x 1\J%O))rHR$=pe*X&jS0O%0C",HHBReb{]7^pbEQH>mtzH!av xavZ0pW&qz1@se4q/W#Z\ RLS26V>-e.__wD"X8_5ev,XvIqXE$20WT荶q:%dR[8X&Ȍj1Xbz1^8q&o0QCjc '_qD]j55C# SIVF_g3I {p"Q̰9Ve$_&|P;1oHvyyizS_ @!P)"ncBAzIdӏw+Aؑa~X-D3;V "??+uzӡor  %JGs(sG (ͣ]1 p)/91f5%{GьQdLafhHԁR b>Q%c2h0iα+q)"r"u("Iasne7"֜ '$)*/P@{,0_n :!qUeW'"%bVtb. *NI>!+(\hHv#s)U6@W z. Bc7i?lsdK;w2DY6=3v_V4_I B`2=iDT0ps!3K&jX i9sfSIDDsDR!?)lE(`sV7?wxUgY#PV7iG@AqKu\?9v6sZa8eCI/ N-?0%|9K('}Jޤ>T4DE鈎C:;Y ^T}S-K:[72dvàw Ez*,Od4DZMvXv?0#ME{Y.*Sz 74)*.tW?҂Y4` IrHg4[HpGz7QI~,{lC0W˱m x\{ fyJH^+q%9jS|jsw;Y*qW2wugo"34e`w꘣OIQD$N"tčX6q|G /Ɉ wPS!;nHBKGv. !\ |ThR4ɊH5$ڂ@ cAecTi]a{OG TNS@@qM%5vq} t?#@"RKhckUb}i1$2''HlCZz&tAlIYs7b?晞(~{ i:VQEQ]|̫F2iGϚW˩ ӥjeQ q6(K&il@ 0+Eh-Z4 ty,}X5% u,PksK:ۧč l| SW{嚘ܧy Жu@b( 9' YV;whereami-0.3.34/html/index.html0000644000000000000000000001325710620241635013240 0ustar Whereami? - Network Autoconfiguration Utility

whereami - Automatic Configuration Utility


What?

whereami can automatically configure the system during boot, whenever a PCMCIA network card is inserted or removed, and whenever there is an APM event. It can:

  • examine the system's network environment in order to detect the current location
  • adapt the system configuration to that environment

Since this all happens on PCMCIA card removal or insertion (or whenever else you set it to happen), it should be easy to automate all the actions you would normally take when you arrive at a new location.


Why?

I work at quite a variety of places. When I arrive at a new location I find it a pain if it takes me half a morning to get the network set up. Well, I could write scripts to tell my computer where I am, but that's no challenge!

So I like to have my computer automatically know where it is, set the mail relay, DNS forwarder and so forth automatically without me having to worry about it and I can concentrate on getting my job done :-)

Other considerations which have made me design this framework in this way include:

  • easy extension to new situations
  • easy to enhance functionality through new helper scripts
  • a component-based framework which I (and others) can enhance piecemeal

How?

whereami splits the problem of re-configuration into several parts:

  • triggering of location detection
  • detecting the current location
  • adapting to the current location

Triggering location detection

My feeling is that there are only a few times when a laptop might find itself in a new 'location': during the boot process, when a PCMCIA (network) card is inserted or removed and after waking up. whereami can run at any or all of these times, after basic hardware initialisation, to detect and configure the more high-level components of the system such as named and sendmail.

By default, whereami is run at boot time and on ifup.

whereami can also be run by the PCMCIA card manager, cardmgr, if the pcmcia-cs package is appropriately set up.

You can also configure whereami to run before APM suspend or after APM resume. This might be useful, for example, for configuring a built-in network adapter when one changes location. You can enable this by editing /etc/whereami/apm.conf.

Detecting the current location

Location detection is configured by editing /etc/whereami/detect.conf. Here one specifies the unique characteristics of a location that can be discovered by performing tests.

Since version 1.0, whereami allows for one to be at multiple locations at the same time; for example, both 'docked' and 'atwork'.

Go here for full details of setting up location detection in whereami, or read the detect.conf(5) manual page.

Adapting to the location

Once the current location has been detected, whereami performs actions that are specified for:

  • when one 'leaves' a location
  • when one 'arrives' at a location
  • when one 'is at' a location

For full details of configuration actions, go here, or read the whereami.conf(5) manual page.

Overriding location detection

Sometimes it is desirable to tell whereami where we are rather than let it try to work it out. This can be used, e.g., to ensure that network drives are unmounted cleanly before going somewhere else. To override the location, give the name of the location as an argument to whereami:

      whereami <location>

For example, I often use "whereami undocked" when I am about to disconnect from my current network to ensure that all nfs drives are unmounted before the network is physically disconnected.

The whereami command accepts other options. Enter:

      whereami --help

or read the whereami(5) manual page for more information.


Where?

Since version 0.8, whereami is included in Debian. E-Mail me if you would be interested in using this utility in other distributions, and if you are willing to be a guinea pig for me!


Who?

whereami was written by Andrew McMillan, with contributions from various other users, most notably Chris Halls. See the AUTHORS file for full details.

 


Andrew's Linux Page  |   'Whereami' home page  |   Location Detection  |   Actions  |   © Andrew McMillan, 1999-2002 released under the GPL v2

whereami-0.3.34/html/detection.html0000644000000000000000000001727710620241635014115 0ustar whereami - Location Detection

whereami - Location Detection


Detection

/etc/whereami/detect.conf tells whereami how to detect the current location.

The simplest detect.conf is composed of lines specifying 'tests' as follows:

  testdhcp    '*.*.*.*'    dhcp
  testarp     eth0,00:24:5e:17:12:11,10.2.0.4  auckland
  testping    172.16.100.2,172.16.100.86       ceo7k

where each 'test' line is composed of three parts:
   <command> <parameter> <location>

Syntax

default <location> Set this at the top of your scripts to choose the name of the location to use when all tests fail.
set <variable> <value> Sets an environment variable. These variables may be referred to within the scripts. Most standard scripts use $INTERFACE, for example, to identify the interface being dealt with.
if <location>[,<location>...]
  ... tests ...
[elif <location>[,<location>...]
  ... tests ...]
[else
  ... tests ...]
fi
If one of the listed locations has been previously found true, then the if... branch will be processed, otherwise the else... branch will be processed. The 'elif...' branch does what you would expect too.

Note that these cannot be nested, however.

at <location>[,<location>...] We are 'at' the listed locations.
notat <location>[,<location>...] We are 'not at' the listed locations.
always ... test ... Runs the test regardless of whether a previous test was successful. If we are within an inactive branch of an if ... elif ... else ... fi clause the test will not be processed, even when preceded by always.
<testscript> <parameter> <location>[,<location>...] Anything else is assumed to be a script, which will be run by the whereami process with the second parameter. If the script exits with a 0 status, whereami will consider that the location(s) listed in the third parameter are current.
Note: that tests will only be run until one is successful, unless the test is preceded by always.

Read the detect.conf(5) manual page for more information.

Standard tests

The whole command normally appears on the same line in detect.conf. The HTML formatting here may break commands onto multiple lines for readability.
testdhcptestdhcp [<interface>,](start|stop|restart|<IP address pattern>) <location>[,<location>...] Gets a DHCP address (on the first call, or on the 'start' call) and compares it to the IP address pattern.
testarptestarp [<interface>,]<MAC address>,<IP address> <location>[,<location>...] Look for that MAC address in association with that IP address on the specified interface.
testmiitestmii <interface> <location>[,<location>...] Check if there is a network present on the interface.
testmoduletestmodule <pattern for lsmod> <location>[,<location>...] Look for the pattern somewhere in the output of lsmod.
testpcitestpci <pattern for lspci -v> <location>[,<location>...] Look for the pattern somewhere in the output of lspci -v
testpingtestping [<interface>,]<IP to find>,<IP to use> <location>[,<location>...] Configure the interface as the specified IP address and try and ping the other one. Note that this uses fping for speed, and makes assumptions about how long it is reasonable to wait for a ping response on a LAN.
testpppoetestpppoe <interface> <location>[,<location>...] Attempts to establish a pppoe session.
testreceivedtestreceived <interface> <location>[,<location>...] Check to see if we have received packets on that interface.
testssidtestssid <SSID> <location>[,<location>...] Look for a WLAN that is using that SSID.


Examples

In my situation I have around 7 different locations I want to identify:

  • Catalyst office in Wellington
  • Client 1 office in Auckland
  • Client 2 office in Sydney
  • Client 3 office in Auckland
  • Client 1 office in Wellington (mail is less important here)
  • Client 2 office in Wellington (mail is less important here)
  • Out of office (Wellington, Auckland and Sydney)
  • At home (on the network)
  • . . . as well as other locations

In most of these situations DHCP is set up, which makes things quite a bit easier because I can assume that the network adapter is configured once whereami is run. At Catalyst I also use the lspci command to see if my computer is in its docking station.

For the home network I don't have DHCP set up yet, so I use testarp to look for a MAC address.

Since being docked doesn't entail that I'm at Catalyst, I check for the docking station first; then I check for all the DHCP addresses I might have been assigned. Fortunately these all assign addresses in different class C ranges, so I don't have to get complicated and look up IP addresses and so forth, but the tests could be refined further if required.

Someday I would like to give whereami some 'hysteresis': the last active location would influence detection such that if I was last in Auckland then whereami will reckon that, if I am now off-line, I am off-line in Auckland (so it could configure the defaults for ppp appropriately).


Creating tests

If the standard test programs (in /usr/share/whereami/...) are insufficient for your needs, you can create your own.

Each script to be used in detect.conf must:

  • accept a single parameter
  • exit with 0 on success and 1 otherwise

If you want to pass multiple parameters to your program then, for now, you will need to pass them a comma (or some other non-space character) separated list. You can use the standard tests (which are shell scripts) as examples to work from.


Having found out where you are, here are the actions that whereami can be configured to take.

 


whereami   |   Actions   © Andrew McMillan, 1999-2003 released under the GPL

whereami-0.3.34/README0000644000000000000000000000426010620241635011151 0ustar whereami README File Andrew McMillan This is the Debian GNU/Linux prepackaged version of the whereami package. 1. What is "whereami" "whereami" is a utility for laptop users or people who use their machines in different situations all the time. The general strategy is as follows: - whereami is run at boot time, when a PCMCIA card is inserted or removed, or at suspend/resume. - whereami builds a script of actions based on: o where you are now o where you were last - whereami executes that script. Along with 'whereami' are a number of useful programs and scripts to help with automating the sorts of things that many of us want to do when we arrive (or leave) each location. As ever, I wrote whereami for my own reasons. It meets my needs, and I'm only too happy to include changes to make it fit with a wider audience. 2. What do I need? Before using whereami, you will need to configure several items: - the whereami detection configuration in /etc/whereami/detect.conf - the whereami configuration file in /etc/whereami/whereami.conf A number of useful scripts are also provided in the /usr/share/whereami directory to assist with tasks that are regularly a part of configuration when your computer is set up in a different environment. When it is running, whereami will extend the $PATH to include this directory, so scripts that are in there may be used without explicit pathing. A basic knowledge of shell scripting will help, but you might want to look on this as an opportunity to learn, if you don't have experience with shell scripts - there are plenty of examples. 3. Configuration You should refer to the manual, specifically detect.conf(5) whereami.conf(5), and whereami(8) for more comprehensive information on configuration and setup. 4. Further Help or Contributions I have set up two mailing lists for whereami, one for announcements and the other for discssion. You can subscribe to these here: http://lists.catalyst.net.nz/cgi-bin/mailman/listinfo/whereami-announce http://lists.catalyst.net.nz/cgi-bin/mailman/listinfo/whereami-discuss whereami-0.3.34/detect.conf0000644000000000000000000000547010620241635012414 0ustar # The detection configuration file for 'whereami' # # This file describes unique features of various environments you connect # to and associates them with those locations. # When a test is successful, no further tests will be conducted # until a subsequent 'if' or 'fi' statement, or if the line is preceded # by the word 'always' # # You may also set environment variables for the scripts (test and action) # subsequently called by whereami using "set ". # # See "man 5 detect.conf" for lots more information, especially for the # details of the helper scripts used here. # # It is a good idea to default to somewhere... default undocked # Test for the presence of an ethernet connection plugged into eth0 testmii eth0 lan # Uncomment this for exhaustive debugging output # set DEBUGWHEREAMI 1 # 'down' might be a location that is forced from the command line # like "whereami down" if down always at undocked always notat eth0,eth1 elif stop # Or maybe we can't remember the exact command, so we do it twice! # like "whereami stop" this time always at undocked always notat eth0,eth1 elif lan # If the testmii at the top was successful set INTERFACE eth0 # testdhcp '*.*.*.*' dhcp # testarp eth0,00:24:5e:17:12:11,10.2.0.4 morrinsville # testping 192.168.138.1,192.168.138.55 queenstown # testping 202.49.41.18,202.49.41.1 rotorua else # If the testmii at the top failed # modprobe prism54 w_eth1 # always modprobe orinoco w_eth1 # always modprobe ath_pci atheros # always modprobe ipw2100 w_eth1 # ... and we unload this in whereami.conf, if we don't find one, # in an attempt to minimise power, and RFI fi if w_eth1 # Some wireless drivers use one interface name set INTERFACE eth1 testap scan wlan fi if atheros # And some use a different one set INTERFACE ath0 testap scan wlan fi # If we have found at least some WLAN APs in the vicinity, find out # if we can do anything with any of them if wlan # testap milford,1234-5FED-CB milford,wdhcp # testap wanaka,1234-2468-1357-dead-beef-feed-99 wanaka,wdhcp # testap ruapehu ruapehu,wdhcp # # If there's anything there at all, try and DHCP off it # testap .+ wdhcp # # And if there isn't, we will indicate that. # notat wlan,wdhcp fi # So it seems we should try and get DHCP off a WLAN AP if wdhcp # testdhcp '*.*.*.*' dhcp fi # And if we have DHCP (wired or wireless) we want to make # a decision as to which LAN that is, exactly. if dhcp # testdhcp 192.168.5.* waiheke # testdhcp 192.168.7.* tauranga # testdhcp 192.168.10.* wellington # testdhcp 192.168.55.3* picton # # Note that we only get here, if the one above is _unsuccessful_ # testdhcp 192.168.55.* rakaia fi whereami-0.3.34/samples/0000755000000000000000000000000010620241635011733 5ustar whereami-0.3.34/samples/detect.conf.example0000644000000000000000000000547010620241635015512 0ustar # The detection configuration file for 'whereami' # # This file describes unique features of various environments you connect # to and associates them with those locations. # When a test is successful, no further tests will be conducted # until a subsequent 'if' or 'fi' statement, or if the line is preceded # by the word 'always' # # You may also set environment variables for the scripts (test and action) # subsequently called by whereami using "set ". # # See "man 5 detect.conf" for lots more information, especially for the # details of the helper scripts used here. # # It is a good idea to default to somewhere... default undocked # Test for the presence of an ethernet connection plugged into eth0 testmii eth0 lan # Uncomment this for exhaustive debugging output # set DEBUGWHEREAMI 1 # 'down' might be a location that is forced from the command line # like "whereami down" if down always at undocked always notat eth0,eth1 elif stop # Or maybe we can't remember the exact command, so we do it twice! # like "whereami stop" this time always at undocked always notat eth0,eth1 elif lan # If the testmii at the top was successful set INTERFACE eth0 # testdhcp '*.*.*.*' dhcp # testarp eth0,00:24:5e:17:12:11,10.2.0.4 morrinsville # testping 192.168.138.1,192.168.138.55 queenstown # testping 202.49.41.18,202.49.41.1 rotorua else # If the testmii at the top failed # modprobe prism54 w_eth1 # always modprobe orinoco w_eth1 # always modprobe ath_pci atheros # always modprobe ipw2100 w_eth1 # ... and we unload this in whereami.conf, if we don't find one, # in an attempt to minimise power, and RFI fi if w_eth1 # Some wireless drivers use one interface name set INTERFACE eth1 testap scan wlan fi if atheros # And some use a different one set INTERFACE ath0 testap scan wlan fi # If we have found at least some WLAN APs in the vicinity, find out # if we can do anything with any of them if wlan # testap milford,1234-5FED-CB milford,wdhcp # testap wanaka,1234-2468-1357-dead-beef-feed-99 wanaka,wdhcp # testap ruapehu ruapehu,wdhcp # # If there's anything there at all, try and DHCP off it # testap .+ wdhcp # # And if there isn't, we will indicate that. # notat wlan,wdhcp fi # So it seems we should try and get DHCP off a WLAN AP if wdhcp # testdhcp '*.*.*.*' dhcp fi # And if we have DHCP (wired or wireless) we want to make # a decision as to which LAN that is, exactly. if dhcp # testdhcp 192.168.5.* waiheke # testdhcp 192.168.7.* tauranga # testdhcp 192.168.10.* wellington # testdhcp 192.168.55.3* picton # # Note that we only get here, if the one above is _unsuccessful_ # testdhcp 192.168.55.* rakaia fi whereami-0.3.34/samples/80at-home0000755000000000000000000000155310620241635013367 0ustar #!/bin/bash # # This script identifies that I am at home. I haven't got around to having dhcp at # home so I have to ifconfig and then ping to see if there's something at the other # end. # # For future development the code section below should really be separated as a # script in the ./scripts directory which will test a particular IP and return # a true/false answer. In that case we could do many of these sort of checks # easily. Also it would be nice to 'C' code this in some way to try and improve # the speed with which we can see if a particular IP is valid. # TESTIP=192.168.55.10 MYIP=20 if ( /usr/share/whereami/findnet $TESTIP $MYIP); then LOCATION=home # We only put the location out if we find that we are here, which is different # from the docked / undocked case where we always say one or the other. echo $LOCATION >>iwillbe LOCATED=1 fi whereami-0.3.34/apm.conf0000644000000000000000000000206610620241635011717 0ustar # Configuration for whereami during suspend and resume # # On suspend or resume, whereami will change to the location(s) specified # below in the SUSPEND_LOCATION and RESUME_LOCATION environment variables. # If the location is 'auto', whereami performs location detection. If the # variable is empty then whereami does nothing. # # Uncomment to enable whereami detection on resume. # Note: It is not necessary to enable detection here if "ifup" is # invoked at resume time, e.g., by an apmd proxy script or by cardmgr, # and if /etc/network/if-pre-up.d/whereami is set up to invoke whereami. # # Note: With kernel prior to 2.4.19 and with certain machines # (e.g. IBM ThinkPads), the apm subsystem sends more than one resume # event on wakeup. If that happens then whereami will run more # than once. #RESUME_LOCATION=auto # Use SUSPEND_LOCATION if you want to set a location on suspend. # Note: Your network card may already be suspended at this point, so # don't be too surprised if trying to unmount something does not work... #SUSPEND_LOCATION=undocked whereami-0.3.34/TODO0000644000000000000000000000035210620241635010757 0ustar * Better integration with ifupdown * Better integration with hotplug * Incorporate more useful scripts from users. * GUI for controlling detect.conf * Some sort of "autodiscover" mode, handholding through a basic setup process. whereami-0.3.34/debian/0000755000000000000000000000000011415355677011530 5ustar whereami-0.3.34/debian/copyright0000644000000000000000000000043510620241635013446 0ustar This is the Debian GNU/Linux prepackaged version of whereami. This version of whereami is copyright 1999, Andrew McMillan and is released under the GPL (on Debian systems look in `/usr/share/common-licenses/GPL'). Changes: * Initial version * 2001-02-17 Location of GPL has moved. whereami-0.3.34/debian/gplcopynote0000644000000000000000000000032310620241635013775 0ustar This program is licensed according to the GNU GENERAL PUBLIC LICENSE Version 2, June 1991, or later versions at your discretion. See the file /usr/share/common-licenses/GPL for the full details of the GNU GPL. whereami-0.3.34/debian/pcmcia-whereami.patch0000644000000000000000000000246210620241635015571 0ustar diff -ruN pcmcia-cs.orig/etc/network pcmcia-cs/etc/network --- pcmcia-cs.orig/etc/network Tue Nov 27 07:18:55 2001 +++ pcmcia-cs/etc/network Mon Dec 24 23:21:56 2001 @@ -60,6 +60,10 @@ [ -n "$IF_PORT" ] && /sbin/ifport $DEVICE $IF_PORT + if is_true $WHEREAMI ; then + /usr/sbin/whereami --run_from pcmcia --syslog --hint $DEVICE || exit 1 + fi + if is_true $PPPOE ; then log /sbin/ifconfig $DEVICE up log "/usr/sbin/pppd call dsl-provider" || exit 1 @@ -164,8 +168,8 @@ stop_fn $DEVICE - if is_true $PUMP || is_true $BOOTP || is_true $DHCP || \ - is_true $DHCLIENT || [ -n "$IPADDR" ] ; then + if is_true $WHEREAMI || is_true $PUMP || is_true $BOOTP \ + || is_true $DHCP || is_true $DHCLIENT || [ -n "$IPADDR" ] ; then # Shut down all NFS mounts on this interface nfsstop () diff -ruN pcmcia-cs.orig/etc/network.opts pcmcia-cs/etc/network.opts --- pcmcia-cs.orig/etc/network.opts Tue Nov 27 07:18:55 2001 +++ pcmcia-cs/etc/network.opts Mon Dec 24 22:51:34 2001 @@ -13,6 +13,8 @@ IF_PORT="" # Use BOOTP (via /sbin/bootpc, or /sbin/pump)? [y/n] BOOTP="n" + # Use WHEREAMI ? [y/n] + WHEREAMI="n" # Use DHCP (via /sbin/dhcpcd, /sbin/dhclient, or /sbin/pump)? [y/n] DHCP="n" # If you need to explicitly specify a hostname for DHCP requests whereami-0.3.34/debian/whereami.postinst0000644000000000000000000000076411253156512015130 0ustar #!/bin/sh # # $Id: whereami.postinst,v 1.6 2004/02/10 20:52:04 andrew Exp $ # set -e if [ "$1" = "configure" ]; then # CFG=/etc/whereami/whereami.conf if [ ! -d /var/lib/whereami ] ; then # Create new state files location then move and link files mkdir /var/lib/whereami cd /etc/whereami mv iam iwas* whereiam.sh /var/lib/whereami ln -s /var/lib/whereami/iam ln -s /var/lib/whereami/iwas ln -s /var/lib/whereami/whereiam.sh fi fi #DEBHELPER# whereami-0.3.34/debian/changelog0000644000000000000000000006716611415355661013413 0ustar whereami (0.3.34-0.3) unstable; urgency=low * Non-maintainer upload. * Compatibility with isc-dhcp-client (Closes: #585058). -- Mehdi Dogguy Thu, 08 Jul 2010 00:41:36 +0200 whereami (0.3.34-0.2) unstable; urgency=low * Non-maintainer upload to fix release goal. * Fix incorrect provides and dependencies in init.d script (Closes: #542442). * Make sure /var/run/whereami is created at boot time if /var/run/ is a tmpfs. * Make sure to depend on ${misc:Depends}, as debhelper is used. * Do not ignore errors in postinst. Thanks lintian for the tip. * Remove last traces of debconf use, left over from last NMU. -- Petter Reinholdtsen Sun, 13 Sep 2009 13:55:27 +0200 whereami (0.3.34-0.1) unstable; urgency=low * Non-maintainer upload to fix pending l10n issues. * Remove unused templates file and debconf translations. Closes: #449520, #440070, #449519, #452692, #463679 Closes: #449520, #471688, #473471 * Fix detect.conf(5) man page (line 51) -- Christian Perrier Sun, 16 Mar 2008 08:55:46 +0100 whereami (0.3.34) unstable; urgency=low * Fix no-longer-required link in postinst. (closes: #449059) * Updated german translation (closes:#449162) -- Andrew McMillan Mon, 05 Nov 2007 00:16:00 +1300 whereami (0.3.33) unstable; urgency=low * Apply lintian clean fixes, including re-revert DH_COMPAT. * Ensure man pages are built with package. * Correct logic inversion in testsupplicant (closes:#422647). * Add testwpa script from François Tourde. * Add Brazillian Portugese translation (closes:#44070). * Fix to ensure testsupplicant works when wpa_supplicant already running at start of process. (closes:#422650). -- Andrew McMillan Fri, 02 Nov 2007 07:10:50 +1300 whereami (0.3.32) unstable; urgency=low * Revert DH_COMPAT in debian/rules so this can go into Etch. -- Andrew McMillan Tue, 27 Feb 2007 17:22:18 +1300 whereami (0.3.31) unstable; urgency=low * Remove /usr/share/doc/whereami/examples which was empty (closes: #405306) * Spanish translation (closes: #403443) * Catalan translation (closes: #405307) * Fix typo in PATH setting (closes: #402186) * Correct use of /bin/sh to /bin/bash in a couple of test scripts -- Andrew McMillan Mon, 26 Feb 2007 07:52:34 +1300 whereami (0.3.30) unstable; urgency=low * Incorporated minor fixes from Ubuntu package. -- Andrew McMillan Fri, 1 Dec 2006 23:03:29 +1300 whereami (0.3.29) unstable; urgency=low * Correct old directory mentioned in README and add comment about $PATH (closes: #367477). * Add build, binary-indep and binary-arch targets (closes: #395813). * Apply patches from Stefano Sabatini extending allowable SSIDs. -- Andrew McMillan Sun, 12 Nov 2006 13:33:51 +1300 whereami (0.3.28) unstable; urgency=low * Make testmii retry with ethtool if mii-tool's operation is not supported. * Change some of the suggests to recommends (iputils-arping, resolvconf and wireless-tools). * Comment out some things in the whereami.conf that might result in some unsightly error messages when running unconfiugured (closes: #336904) -- Andrew McMillan Wed, 2 Nov 2005 10:26:48 +1300 whereami (0.3.27) unstable; urgency=low * Quit network hook for loopback. Provide hint for the interface (yep, two bugs in one bug report is bad form) (closes: #333926) -- Andrew McMillan Sat, 15 Oct 2005 09:17:29 +1300 whereami (0.3.26) unstable; urgency=low * Add portugese translation (closes: #331496). -- Andrew McMillan Tue, 4 Oct 2005 11:21:04 +1300 whereami (0.3.25) unstable; urgency=low * Add swedish translation (closes: #330617). -- Andrew McMillan Thu, 29 Sep 2005 14:03:15 +1200 whereami (0.3.24) unstable; urgency=low * Depend on debconf | debconf-2.0 -- Andrew McMillan Tue, 27 Sep 2005 12:44:51 +1200 whereami (0.3.23) unstable; urgency=low * Vietnamese translation (closes: #324124). * Added test for whereami installation into the dhclient hook script. Closes (Malone: #2044). -- Andrew McMillan Sun, 18 Sep 2005 22:34:52 +1200 whereami (0.3.22) unstable; urgency=low * Added initial "testsupplicant" support for using wpasupplicant * Changes to testap to more robustly get scan results as quickly as possible and then move on. -- Andrew McMillan Fri, 8 Jul 2005 12:46:20 +0300 whereami (0.3.21) unstable; urgency=low * Remove stuff from /var/lib/whereami in prerm. * Add pointer in README to mailing lists that are now setup. * Daniel Bonniot supplied a fix to make dhclient3 exit in a manner that is appropriate for whereami (closes: #308980). * The testmii script will now bring up the interface before checking to see if there really is a network connection (closes: #285703). * Patched html docs (man pages are still better) (closes: #177873). * Added /usr/local/share/whereami to path (closes: #288718) * Added $scriptbase/actions to path, moved actions in there and symlinked back to their old locations. (closes: #177906) * Added a '!location' flag in whereami.conf to indicate "not in this location" kinds of actions. (closes: #194060) * Added "iwconfig essid on" to testap/testssid (closes: #309279) * Man pages and examples updated (closes: #178235) * Applied patch from Peter Koellner to allow quoting of parameters to test scripts in detect.conf. * Added "setproxy" script to work with Squid proxies as well as Oops ones. -- Andrew McMillan Sun, 19 Jun 2005 22:11:55 +1200 whereami (0.3.20) unstable; urgency=low * Updated man page source to correct licensing screwups. * Added Czech translation by Miroslav Kure (closes: #298319) -- Andrew McMillan Mon, 4 Apr 2005 07:07:58 +1200 whereami (0.3.19) unstable; urgency=low * Added documentation for testappassive and testprocsys from Matthew Grant. * Added /usr/local/share/whereami to PATH for scripts and tests based on a suggestion by Simon Guest. * Applied patch to testap from Simon Guest to allow specifying 'restricted' mode, which seems to be needed by the ipw2200 driver. * Added documentation for the above change to detect.conf.sgml. * Added testusb script contributed by Brett Johnson. * Improved detect.conf manpage with examples. * Removed ancient 'samples' directory which applied to the now unsupported mode of operation. * Added scripts testappassive and testprocsys from Matthew Grant. * Tweaked testap to work more reliably with the madwifi driver. -- Andrew McMillan Sun, 13 Feb 2005 12:19:37 +1300 whereami (0.3.18) unstable; urgency=low * Added ludicrous dependencies (closes: #273399) * Made testssid check binary for driverloader/ndiswrapper (closes: #275368) * Made testping work ok-ishly with iputils-ping and friends. -- Andrew McMillan Tue, 19 Oct 2004 14:01:06 +1300 whereami (0.3.17) unstable; urgency=low * Apply patch from Patrice Neff for qmail handling (closes: #265863) * Correct shell variable escaping from Matthew Grant. * Apply patch for de l10n from Jens Nachtigall (closes: #273991) * Apply patch for nl l10n from Luk Claes (closes: #274898) -- Andrew McMillan Wed, 6 Oct 2004 09:36:44 +1300 whereami (0.3.16) unstable; urgency=low * Fix how testap handles moving from an encrypted WLAN to an unencrypted one. * Check if whereami is actually installed in network hook (closes: #235226) -- Andrew McMillan Tue, 3 Aug 2004 07:06:37 +1200 whereami (0.3.15) unstable; urgency=low * Apply japanes l10n from Hideki Yamane (closes: #259800) -- Andrew McMillan Sun, 18 Jul 2004 11:12:40 +1200 whereami (0.3.14) unstable; urgency=low * Add setoops script from Fedor Karpelevitch to set "oops" proxy. * Added section to whereami.conf manpage descibing the more useful scripts. * Fix typos in testap -- Andrew McMillan Sat, 3 Jul 2004 23:00:15 +1200 whereami (0.3.13) unstable; urgency=low * Add settimezone script from Itay Ben-Yaacov (closes: #252359) * Make testap assign first matching ESSID on a successful test. -- Andrew McMillan Thu, 17 Jun 2004 09:30:07 +1200 whereami (0.3.12) unstable; urgency=low * Added support for dhcpcd from Chris Halls. -- Andrew McMillan Thu, 27 May 2004 23:54:38 -0300 whereami (0.3.11) unstable; urgency=low * Add dependency on perl (closes: #250300) -- Andrew McMillan Sat, 22 May 2004 21:40:12 +1200 whereami (0.3.10) unstable; urgency=low * Preserve mail configuration perms/owner/grp in setmailrelay (closes: #249477) * "Fallback" isn't what that was doing! Duh! (closes: #249479) -- Andrew McMillan Wed, 19 May 2004 22:40:17 +1200 whereami (0.3.9) unstable; urgency=low * Apply patch to whereami.network-hook (closes: #235226) -- Andrew McMillan Thu, 22 Apr 2004 09:38:32 +1200 whereami (0.3.8) unstable; urgency=low * Fix missing quotes in testap. * Add support for Exim4 from Itay Ben-Yaacov (closes: #244930) -- Andrew McMillan Wed, 21 Apr 2004 12:51:43 +1200 whereami (0.3.7) unstable; urgency=low * Correct location of lspci in testpci script. * Fix variable handling in testap where INTERFACE is not previously set. * Lots of changes to testap, which now seems reasonably ready for use. * Added 'echo "a message"' function to detect.conf syntax. * Updated detect.conf example configuration to suggest more reasonable things. -- Andrew McMillan Tue, 23 Mar 2004 23:20:48 +1200 whereami (0.3.6) unstable; urgency=low * Apply new french translation (closes: #238017). * Beginnings of a new "testap" script where WLAN supports iwlist .. scan. -- Andrew McMillan Sun, 21 Mar 2004 14:55:20 +1200 whereami (0.3.5) unstable; urgency=low * Fix dhclient3 hook to use STATEDIR, really closes: #233963 * Add a reload to postfix handling in setmailrelay -- Andrew McMillan Mon, 15 Mar 2004 08:25:30 +1300 whereami (0.3.4) unstable; urgency=low * Change default STATEDIR in testdhcp (closes: #233963) * Add directories /var/run/whereami and /var/lib/whereami to reduce noise. -- Andrew McMillan Tue, 9 Mar 2004 06:55:11 +1300 whereami (0.3.3) unstable; urgency=medium * Remove "exit 0" from dhclient3 hook (closes: #228303) * Fix debugging cruft in setresolver (closes: #228308) * Move "state" file locations to /var/lib/whereami * Fix typo int html docs (closes: #229300) * Also overwrite /var/run/dnsmasq/resolv.conf in setdnsmasq (a hack!) -- Andrew McMillan Wed, 11 Feb 2004 08:56:23 +1300 whereami (0.3.2) unstable; urgency=low * Add support for ethtool to testmii. * Improve handling of wireless networks with encryption, including man page changes(!) * Adjust APM support to fit current scheme. * Apply patch from Chris Halls: bind-forwarders should not do anything if resolvconf is installed. setmailrelay should use postconf for PostFix. * Note that bugs 164213 & 167704 were fixed at 0.2.7 which was not released into Debian. Let's try again... (closes: #164213, #167704) * Remove references to old (bash) version in postinst. (closes: #228089) -- Andrew McMillan Sat, 17 Jan 2004 22:27:03 +1300 whereami (0.3.1) unstable; urgency=low * Add some basic support for resolvconf (needs work) * Add "Source" line to debian/control (closes: #223224) * Add QMail support (Patrice Neff) (closes: #217459) * Fix parsing of testarp options (Alexander Borkowski) -- Andrew McMillan Mon, 8 Dec 2003 00:15:27 +1300 whereami (0.3.0) unstable; urgency=low * Switch to gettext for templates (Michel Grentzinger) (closes: #199005) * Remove option of using old (ancient) whereami and fix templates to not use Yes / No (closes: #199040) (increment major version) * Added french translation (Michel Grentzinger) (closes: #199981) -- Andrew McMillan Sun, 6 Jul 2003 23:28:12 +1200 whereami (0.2.12) unstable; urgency=low * Added "Suggests" for wireless-tools. Updated to standards version 3.5.9.0 * Correct handling of overlapping sets of locations (closes: #188097) -- Andrew McMillan Tue, 8 Apr 2003 20:47:15 +1200 whereami (0.2.11) unstable; urgency=low * Applied a patch from Adrian Woizik to improve handling of multiple locations. * Correct handling of location change when sets of locations overlap. * Added information about 'testreceived' and 'testssid' checks to detect.conf manpage. * Corrected parameter handling in testreceived script. -- Andrew McMillan Thu, 20 Mar 2003 23:43:14 +1200 whereami (0.2.10) unstable; urgency=low * Added Chris Hall's --mapping patch for use in ifupdown mapping * Small option change for setmailrelay (exim) from Matej Cepl * Add optional IP address assignment during testarp. * Make lintian clean. -- Andrew McMillan Sun, 23 Feb 2003 22:20:08 +1300 whereami (0.2.9) unstable; urgency=low * More patches from Thomas Hood (closes: #177547, #177554, #177585) * Re-added ifconfig to testarp, but just as 'ifconfig ... up'. The removal at 0.2.6 did cause problems for some PowerPC users. * Fixed a typo in testssid script. * Updated HTML documentation somewhat (closes: #177545) -- Andrew McMillan Tue, 21 Jan 2003 23:28:53 +1300 whereami (0.2.8) unstable; urgency=low * Comment patch to apm.conf from Thomas Hood (closes: #176860) * Manpage patch to detect.conf.5 from Thomas Hood (closes: #178862) -- Andrew McMillan Thu, 16 Jan 2003 12:16:57 +1300 whereami (0.2.7) unstable; urgency=low * Patch from Chris Halls to fix postinst hanging (closes: #164213, #167704) -- Andrew McMillan Wed, 8 Jan 2003 07:57:00 +1300 whereami (0.2.6) unstable; urgency=low * Added testreceived to look for received packets (Mike Carr) (closes: #149988) * Removed ifconfig from testarp script (closes: #174286) - please advise me if this causes anyone any problems. * Some tweaks to rules / control files so latest lintian doesn't bitch at me so much. -- Andrew McMillan Mon, 6 Jan 2003 16:05:31 +1300 whereami (0.2.5) unstable; urgency=low * Updated to suggest ifplugd, which integrates nicely. * Added "testssid" test to look for particular wireless networks * Force named.conf to be owner readable in bind-forwarders. * Policy: fix conffiles creation to remove duplicates. -- Andrew McMillan Sat, 7 Dec 2002 21:09:26 +1300 whereami (0.2.4) unstable; urgency=low * Added exim support to setmailrelay (closes: #164623) * Allow for spaces around route filename (closes: #167346) * Updated documentation further. (closes: #164375) * Corrected some errors in handling if/elif/else/fi construct. * Added support for internal 'at' and 'notat' constructs. * detect.conf man page updated for 'at', 'notat' and 'elif' -- Andrew McMillan Mon, 4 Nov 2002 18:01:06 +1300 whereami (0.2.3) unstable; urgency=low * Add support for bind9 to bind-forwarders * Default to first resolv.conf nameserver if none supplied to bind-forwarders (thanks to Michael Lamertz). * Updated README and TODO to reflect current plans / status. * Removed CONFIGURING file, which was vastly out of date. -- Andrew McMillan Wed, 23 Oct 2002 19:00:21 +1300 whereami (0.2.2) unstable; urgency=low * Remove postinst code to do usr/doc link, per policy. * Correct typo in detect.conf manpage (closes: #164479) * Improved wording in debconf template. * Raphael Pierquin points out that bash functions should return, not exit! * Corrected normal exit behaviour (closes: #165014) -- Andrew McMillan Sun, 20 Oct 2002 21:41:07 +1300 whereami (0.2.1) unstable; urgency=low * Added masqmail integration with masqmail_route script. * Changes to setmailrelay to use init.d scripts (closes: 158364) * Added patch from Patrice Neff to support 'elif' (closes: #152174). * Change testarp to down interface on test failure (closes: #158363). * Fix network hooks to not --syslog (closes: #160187). * Added " export ..." of variables to whereiam.sh so they are usable! -- Andrew McMillan Sat, 28 Sep 2002 16:53:33 +1200 whereami (0.2.0) unstable; urgency=low * Added hooks into ifup / ifdown. * Comprehensive race-resistant, staleness detecting locking. * Restructure of whereami.pl. Or maybe that should be 'Structure...' :-) * Change to use Getopt::Long. * Fix some minor errors. * Added patch from Patrice Neff to support 'elif' (closes: #152174) -- Andrew McMillan Mon, 8 Jul 2002 08:57:25 +1200 whereami (0.1.16) unstable; urgency=low * Applied Chris Hall's more complete solution to #146882 -- Andrew McMillan Fri, 17 May 2002 08:25:34 +1200 whereami (0.1.15) unstable; urgency=low * Made test case insensitive in testarp (closes: #147094) * Improved testing for presence of dhclient3 and quietened it (closes: #146882) -- Andrew McMillan Thu, 16 May 2002 08:52:35 +1200 whereami (0.1.14) unstable; urgency=low * Added handling of '*.*.*.*' as 'restart' for backward compatibility in testdhcp. -- Andrew McMillan Mon, 6 May 2002 07:22:09 +1200 whereami (0.1.13) unstable; urgency=low * Applied new 'testdhcp' from Chris Halls which integrates with dhclient3. * Added /etc/dhcp3/dhclient-exit-hooks.d/whereami for dhclient3 integration. -- Andrew McMillan Sun, 5 May 2002 22:42:26 +1200 whereami (0.1.12) unstable; urgency=low * Add docbook-to-man into build dependencies (closes: #142092) -- Andrew McMillan Wed, 10 Apr 2002 20:55:38 +1200 whereami (0.1.11) unstable; urgency=low * Correct whereami.conf manpage to point to the right document location (closes: #139379) * Comment out most of detect.conf (closes: #139378) -- Andrew McMillan Fri, 22 Mar 2002 07:30:40 +1200 whereami (0.1.10) unstable; urgency=low * Correct [some] errors in man pages - no doubt there are more! (closes: #137799) -- Andrew McMillan Mon, 11 Mar 2002 22:44:09 +1300 whereami (0.1.9) unstable; urgency=low * Take interface down after testing it and it fails (closes: #136943) -- Andrew McMillan Wed, 6 Mar 2002 09:34:00 +1300 whereami (0.1.8) unstable; urgency=low * Really fix locking this time... (closes: #135977) -- Andrew McMillan Wed, 27 Feb 2002 19:34:00 +1300 whereami (0.1.7) unstable; urgency=high * Fix whereami.pl to not output stub script to screen (closes: #132317) * Correct bug in --hint option to whereami.pl ( closes: #132308) * Thanks to Tom Lees for these two fixes :-) * Construction of whereiam.sh script was fixed in 0.1.6 (closes: #132319) -- Andrew McMillan Tue, 5 Feb 2002 08:13:59 +1300 whereami (0.1.6) unstable; urgency=high * Fix construction of whereiam.sh script. * Increase timeouts on testping script to better accommodate WLAN * Fix bug with non-eth0 interfaces in testping script. * Add example debug setting to example detect.conf -- Andrew McMillan Mon, 4 Feb 2002 23:11:44 +1300 whereami (0.1.5) unstable; urgency=low * Change testping to use bash (closes: #131348) -- Andrew McMillan Mon, 4 Feb 2002 23:11:33 +1300 whereami (0.1.4) unstable; urgency=low * Move lock file into /var/run directory (closes: #130223) * Add existing whereami tests directory into path (closes: #130222) -- Andrew McMillan Mon, 28 Jan 2002 21:37:30 +1300 whereami (0.1.3) unstable; urgency=low * Apply Chris' patch to ensure foo1 differs from foo (closes: #129423) -- Andrew McMillan Wed, 16 Jan 2002 22:07:18 +1300 whereami (0.1.2) unstable; urgency=low * Remove xtrace from postinst script (closes: #128430). * Fix variable name in testarp script. * Check compatibility mode in whereami.apm, whereami.init (closes: #129116) * Started updating HTML docs (WIP - use man pages for now). * Remove debugging code from postinst. -- Andrew McMillan Mon, 14 Jan 2002 23:09:34 +1300 whereami (0.1.1) unstable; urgency=low * Clean wierd high-bit characters out of testdhcp. * Minor improvements to testdhcp for DH_CLIENT users. * Run with "no restart on upgrade". -- Andrew McMillan Tue, 8 Jan 2002 21:54:30 +1300 whereami (0.1.0) unstable; urgency=low * Completely new version written in perl. New 'detect.conf' file specifying detection characteristics. * Rewritten manpages for whereami and detect.conf. * New script for testing PPPoE setup. * Correct spelling in program description (closes: #125480) * set -o xtrace in all of the test scripts so we can better debug problems out in the field (will turn off in a release or two) * Added locking against multiple execution. * Addded --help option. * Changes to use debconf (closes: #121158) * Added --scriptdebug and --hint options. -- Andrew McMillan Tue, 25 Dec 2001 00:55:42 +1300 whereami (0.0.18) unstable; urgency=low * Switch to debconf to avoid the postinst message for installed users. -- Andrew McMillan Sat, 24 Nov 2001 17:32:22 +1300 whereami (0.0.17) unstable; urgency=low * Suggest 'iputils-arping' rather than 'arping', which is an older version. * Add sample script for aprfind, courtesy of Chris Halls (thanks :-) * Update 'detect.conf' sample to show current thinking. Also include the start of a perl script parsing it. Moving towards v0.1.0... -- Andrew McMillan Sat, 24 Nov 2001 09:47:23 +1300 whereami (0.0.16) unstable; urgency=low * Applied Chris Halls' apm patch for whereami on suspend/resume * Renamed INSTALL "Not The Debian Way (tm)" to CONFIGURE and re-included (closes: #119676) -- Andrew McMillan Fri, 16 Nov 2001 09:01:49 +1300 whereami (0.0.15) unstable; urgency=low * Correct arpfind format to be without carriage returns -- Andrew McMillan Fri, 16 Nov 2001 09:01:38 +1300 whereami (0.0.14) unstable; urgency=low * Corrected e-mail addresses. * Minor changes to description. -- Andrew McMillan Tue, 2 Oct 2001 14:34:16 +1200 whereami (0.0.13) unstable; urgency=low * Removed irrelevant file from source tree. Some docs changes. -- Andrew McMillan Sat, 15 Sep 2001 11:07:29 +1200 whereami (0.0.12) unstable; urgency=low * Added 'arpfind' utility script by Alexander Clouter * Changes to documentation to better describe utility programs -- Andrew McMillan Tue, 11 Sep 2001 08:40:26 +1200 whereami (0.0.11) unstable; urgency=low * Added example test for MII by Chris Halls (closes: #110800) * Modifications to setmailrelay to support postfix, also by Chris Halls (closes: #110806) * Minor documentation changes * Added example test for wireless lan * Renamed example test for static IP -- Andrew McMillan Sat, 1 Sep 2001 16:22:00 +1200 whereami (0.0.10) unstable; urgency=low * Allow new location to be specified on command line. If we do a 'whereami undocked' before actually disconnecting from the network, the network drives get disconnected cleanly. -- Andrew McMillan Thu, 31 May 2001 07:16:40 +1200 whereami (0.0.9) unstable; urgency=low * Commented the example confirguration files. Closes: Bug#96617. * Changed maintainer e-mail address. -- Andrew McMillan Tue, 8 May 2001 14:24:09 +1200 whereami (0.0.8) unstable; urgency=low * Removed -x from version number to identify as debian native package. * Removed gplcopynote and notes files, which are no longer relevant -- Andrew McMillan Sun, 4 Mar 2001 15:33:34 +1300 whereami (0.0.7-1) unstable; urgency=low * Removed non-Debian INSTALL docs from Debian package (policy). * There is only one changelog, since this is a native Debian package (policy). * Updated policy version number to current policy. -- Andrew McMillan Sat, 3 Mar 2001 22:17:17 +1300 whereami (0.0.7) unstable; urgency=low * Added patches to apply against PCMCIA network setup * Changed default mail-relay.conf to point somewhere generic -- Andrew McMillan Sat, 17 Feb 2001 13:26:39 +1300 whereami (0.0.6-2) unstable; urgency=low * Correct some lintian errors / warnings -- Andrew McMillan Sat, 17 Feb 2001 12:40:26 +1300 whereami (0.0.6-1) unstable; urgency=low * Brought current with my own system. * Added 'findnet' script which uses fping to find the current network for assigning a static IP address * Added TODO file indicating future directions. -- Andrew McMillan Tue, 25 Jan 2000 12:13:40 +1300 whereami (0.0.5-1) unstable; urgency=low * Added a setresolver script to set resolvers from within whereami * Documented setresolver in the html -- Andrew McMillan Thu, 11 Nov 1999 19:50:11 +1300 whereami (0.0.4-2) unstable; urgency=low * Changed the setmailrelay script to accommodate alternative sendmail.cf locations * Modified build scripts to handle CVS checkin * Checked into CVS * Adjusted stuff to ensure lintian doesn't generate any messages -- Andrew McMillan Sun, 04 Nov 1999 14:57:12 +1300 whereami (0.0.4-1) unstable; urgency=low * Moved the helper scripts to /usr/share/whereami following a suggestion from Brian Mays. * Appended /usr/share/whereami to the tail of the PATH for the execution of the script for the new location. * Changed whereami to build the location script in the current directory (/etc/whereami) rather than in the scripts directory. * Added the web pages into the /usr/share/doc/whereami/html directory. * Updated the web pages to ensure they don't tell any porkies :-) * Changed the 'prerm' script to clean up the /etc/whereami directory of the various files created during operation. -- Andrew McMillan Sat, 09 Oct 1999 22:15:31 +1200 whereami (0.0.3-1) unstable; urgency=low * gzipped the man page * Put stuff into postinst and prerm to add/remove a link in /usr/doc * Changes to setmailrelay script to work correctly with Debian sendmail -- Andrew McMillan Fri, 08 Oct 1999 07:53:55 +1200 whereami (0.0.2-1) unstable; urgency=low * Removed various debugging messages and cleaned up the scripts * Got the debian package working properly for me -- Andrew McMillan Tue, 28 Sep 1999 21:45:00 +1200 whereami (0.0.1-1) unstable; urgency=low * Initial release version -- Andrew McMillan Tue, 28 Sep 1999 19:01:26 +1200 Local variables: mode: debian-changelog End: whereami-0.3.34/debian/rules0000755000000000000000000001026611415355661012606 0ustar #!/usr/bin/make -f # -*- makefile -*- # debian/rules file - for whereami # Copyright 1999-2006 by Andrew McMillan # Based on the pcmcia package by Brian Mays # Patterned after the hello package by Ian Jackson. # The package we are dealing with package=whereami # Uncomment this to turn on verbose mode. export DH_VERBOSE=1 build-stamp: dh_testdir umask 022; $(MAKE) all touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp -$(MAKE) clean dh_clean build: build-stamp binary-arch binary-indep: binary binary: build dh_testdir dh_testroot dh_clean -k $(RM) -r debian/$(package) # Install directories dh_installdirs DEBIAN etc etc/init.d etc/$(package) \ etc/$(package) etc/apm etc/apm/scripts.d \ etc/apm/suspend.d etc/apm/resume.d \ etc/dhcp etc/dhcp/dhclient-exit-hooks.d \ etc/dhcp3 etc/dhcp3/dhclient-exit-hooks.d \ etc/network etc/network/if-up.d \ etc/network/if-pre-up.d \ etc/network/if-down.d \ etc/network/if-post-down.d \ usr usr/sbin usr/share usr/share/doc \ usr/share/$(package) \ usr/share/$(package)/actions \ usr/share/$(package)/tests \ usr/share/doc/$(package) \ usr/share/doc/$(package)/html/ \ usr/share/doc/$(package)/html/images \ usr/share/doc/$(package)/patches/ \ usr/share/man usr/share/man/man8 \ var/lib/whereami # Install files install bin/$(package) debian/$(package)/usr/sbin/. dh_installinit --no-restart-on-upgrade --update-rcd-params="defaults 35 65" install bin/whereami.apm debian/$(package)/etc/apm/scripts.d/$(package) cd debian/$(package)/etc/apm/suspend.d; ln -s ../scripts.d/$(package) 01$(package) cd debian/$(package)/etc/apm/resume.d; ln -s ../scripts.d/$(package) 99$(package) install -m644 whereami.conf mail-relay.conf apm.conf detect.conf debian/$(package)/etc/$(package)/. install -m755 debian/whereami.dhclient3-exit-hook debian/$(package)/etc/dhcp/dhclient-exit-hooks.d/whereami install -m755 debian/whereami.dhclient3-exit-hook debian/$(package)/etc/dhcp3/dhclient-exit-hooks.d/whereami install -m755 debian/whereami.network-hook debian/$(package)/etc/network/if-pre-up.d/whereami # If we want to run other than in "pre-up" then we should include something like this. At this stage just "pre-up" seems right-ish... # (cd debian/$(package)/etc/network; ln -s ../if-pre-up.d/whereami if-up.d/whereami; ln -s ../if-pre-up.d/whereami if-post-down.d/whereami; ln -s ../if-pre-up.d/whereami if-down.d/whereami) install -m644 debian/*.patch debian/$(package)/usr/share/doc/$(package)/patches/. install -m644 html/*.html debian/$(package)/usr/share/doc/$(package)/html/. install -m644 `find html/images -maxdepth 1 -type f` debian/$(package)/usr/share/doc/$(package)/html/images/. install -m755 `find scripts -maxdepth 1 -type f ` debian/$(package)/usr/share/$(package)/actions/. cd debian/$(package)/usr/share/$(package); sh -c 'for FILE in actions/* ; do ln -s $$FILE; done' install -m755 `find scripts/tests -maxdepth 1 -type f ` debian/$(package)/usr/share/$(package)/tests/. # Find configuration files # find debian/$(package)/etc/$(package) -name "*.conf" -not -type d | \ # sed 's%debian/$(package)%%' >debian/conffiles # echo "/etc/init.d/$(package)" >>debian/conffiles # echo "/etc/apm/event.d/10$(package)" >>debian/conffiles # sort debian/$(package)/DEBIAN/conffiles # Install documentation install -m644 AUTHORS README VERSION TODO \ debian/$(package)/usr/share/doc/$(package)/. dh_installman man/whereami.8 man/detect.conf.5 man/whereami.conf.5 dh_installchangelogs dh_compress install -m644 debian/copyright \ debian/$(package)/usr/share/doc/$(package)/copyright dh_fixperms # Set permissions on our helper scripts chmod 755 debian/$(package)/usr/share/$(package)/* dh_installdeb dh_perl dh_gencontrol sed '/:/s/, *$$//' debian/$(package)/DEBIAN/control \ >debian/$(package)/DEBIAN/control.new mv debian/$(package)/DEBIAN/control.new debian/$(package)/DEBIAN/control dh_md5sums dh_builddeb # Below here is fairly generic really binary: binary-indep binary-arch source diff: @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false .PHONY: binary-arch binary-indep clean whereami-0.3.34/debian/control0000644000000000000000000000266611415355661013136 0ustar Source: whereami Section: net Priority: extra Maintainer: Andrew McMillan Standards-Version: 3.6.1.0 Build-Depends: debhelper (>= 4.1.16) Build-Depends-Indep: docbook-to-man Package: whereami Architecture: all Suggests: pcmcia-cs, fping, net-tools, ifplugd, ethtool, squid | oops Recommends: wireless-tools, resolvconf, iputils-arping Depends: ${misc:Depends}, perl, fping | iputils-ping | netbase | dhcp-client | isc-dhcp-client Description: Automatically reconfigure your (laptop) system for a new location whereami is a set of useful scripts and a coordinating system for automatically re-locating your computer within the current (network) environment. . Typically, you would use whereami to automatically detect and re-configure your laptop when you move between a variety of diverse networks and/or docking environments. . Although whereami will work best if all of your networks assign addresses through dhcp, this is not a pre-requisite and the system allows any technique to be used to ascertain the new location with as little ongoing user intervention as possible. . Having ascertained the correct location, whereami will run appropriate (user-configured) scripts to adjust the laptop operation to suit the current environment. . See the man pages for more information. You may also get useful assistance from the debian-laptop mailing list, which is frequented by several of the users and contributors. whereami-0.3.34/debian/network.opts.patch0000644000000000000000000000062310620241635015210 0ustar --- etc/network.opts~ Mon Jun 19 02:30:05 2000 +++ etc/network.opts Sun Jul 16 18:42:52 2000 @@ -13,6 +13,8 @@ IF_PORT="" # Use BOOTP (via /sbin/bootpc, or /sbin/pump)? [y/n] BOOTP="n" + # Use WHEREAMI ? [y/n] + WHEREAMI="n" # Use DHCP (via /sbin/dhcpcd, /sbin/dhclient, or /sbin/pump)? [y/n] DHCP="n" # If you need to explicitly specify a hostname for DHCP requests whereami-0.3.34/debian/whereami.init0000755000000000000000000000314611253156043014207 0ustar #!/bin/sh # # Start or stop 'whereami' # ### BEGIN INIT INFO # Provides: whereami # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Autoconfigure computer according to defined rules # Description: Using a variety of techniques this will ascertain # the computer's location on the network, in the # docking station and so forth and configure things # appropriately. ### END INIT INFO # # Andrew McMillan # test -x /usr/sbin/whereami || exit 0 case "$1" in start|restart|force-reload|reload) if [ ! -d /var/run/whereami ] ; then mkdir /var/run/whereami fi echo -n "Where Am I: " # Find actual whereami ACTUAL_WHEREAMI=`readlink /usr/sbin/whereami` if [ "$ACTUAL_WHEREAMI" = "/usr/sbin/whereami.sh" ]; then # The old shell script took no parameters start-stop-daemon --start --quiet --exec /usr/sbin/whereami else # Use new format start-stop-daemon --start --quiet --exec /usr/sbin/whereami -- --run_from init --syslog --hint netstart fi ;; stop) if [ "$ACTUAL_WHEREAMI" != "/usr/sbin/whereami.sh" ]; then # Use new format start-stop-daemon --start --quiet --exec /usr/sbin/whereami -- --run_from init --syslog shutdown fi ;; status) cat /var/lib/whereami/iam ;; *) echo "Usage: /etc/init.d/whereami {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0 whereami-0.3.34/debian/compat0000644000000000000000000000000210620241635012707 0ustar 4 whereami-0.3.34/debian/whereami.dhclient3-exit-hook0000644000000000000000000000150511415355661017027 0ustar #!/bin/sh # dhcpv3 client script for whereami # Chris Halls # # Information about the lease is saved in # /var/lib/whereami/dhclient3., so # subsequent invocations of whereami can use # this information and whereami is started to # determine whether the computer should be # reconfigured # Just exit if whereami is no longer installed test ! -e /usr/sbin/whereami && exit 1 statefile=${STATEDIR:-"/var/lib/whereami"}/dhclient.$interface # save state to file ( echo "# Generated by $0 - do not edit!" for I in reason new_ip_address alias_ip_address interface medium new_subnet_mask do eval echo "$I=\$$I" done ) > $statefile # echo Reason:$reason # cat $statefile case "$reason" in REBOOT|BOUND) /usr/sbin/whereami --run_from dhclient --syslog --hint dhclient ;; esac whereami-0.3.34/debian/notes0000644000000000000000000000105610620241635012566 0ustar DEBIAN SPECIFIC NOTES: * whereami is expressly written for the Debian system. * If it has not yet been incorporated into the /etc/pcmcia/network script, you may wish to add a call to /usr/sbin/whereami to be called automatically after card insertion or removal. A line like: [ -f /usr/sbin/whereami ] && /usr/sbin/whereami as the last line of the appropriate options will mean that 'whereami' executes automatically after insertion and after removal, and will not break your pcmcia if you should remove whereami at a future date. whereami-0.3.34/debian/whereami.prerm0000644000000000000000000000107110620241635014360 0ustar #!/bin/sh # Pre-removal script for whereami. # $Id: whereami.prerm,v 1.4 2005/05/15 09:18:01 andrew Exp $ set -e case "$1" in remove|deconfigure) set +e [ -L /usr/doc/whereami ] && rm -f /usr/doc/whereami [ -L /usr/sbin/whereami ] && rm -f /usr/sbin/whereami if [ -d /etc/whereami ] ; then PRESERVE=`pwd` for DDD in /etc/whereami /var/lib/whereami ; do cd ${DDD} for F in whereiam.sh iam iwas* whereami.started dhclient3.* iwlist.*; do [ -f ${F} ] && rm -f ${F} done done cd ${PRESERVE} fi ;; esac #DEBHELPER# whereami-0.3.34/debian/whereami.network-hook0000644000000000000000000000174710620241635015674 0ustar #!/bin/sh # # $Id: whereami.network-hook,v 1.5 2006/11/12 00:39:14 andrew Exp $ # # Hook for whereami to run when network is being brought up # Andrew McMillan # # Not a lot to do, AFAICS - just call whereami... # # Unless it is going to get really complicated we will use the same # script in all situations, so we need the name we were called by. # We only run in pre-up phase because that is where network detection # generally needs to happen. Possibly we could run something post-up # but whereami ain't architected that way. # # Quit if we're called for the loopback [ "$IFACE" = lo ] && exit 0 # Just exit if whereami is no longer installed test ! -e /usr/sbin/whereami && exit 1 EXTRA_HINT="" SITUATION=`basename \`dirname $0\` .d` if [ "$SITUATION" = "pre-up" ] ; then EXTRA_HINT=',netstart' fi # Can't use --syslog because syslog starts after the network (bug #160187) /usr/sbin/whereami --run_from ${SITUATION} --hint "${SITUATION},${IFACE}${EXTRA_HINT}" exit 0 whereami-0.3.34/debian/network.patch0000644000000000000000000000112410620241635014221 0ustar --- etc/network~ Fri Jul 7 05:35:48 2000 +++ etc/network Sun Jul 16 17:58:04 2000 @@ -68,6 +68,8 @@ if [ "$GATEWAYS" ] ; then set - $GATEWAYS ; GATEWAY=$1 fi + elif is_true $WHEREAMI ; then + /usr/sbin/whereami $DEVICE || exit 1 elif [ -x /sbin/pump ] ; then /sbin/pump -i $DEVICE else @@ -154,7 +156,7 @@ stop_fn $DEVICE - if is_true $PUMP || is_true $BOOTP || is_true $DHCP \ + if is_true $WHEREAMI || is_true $PUMP || is_true $BOOTP || is_true $DHCP \ || is_true $DHCLIENT || [ "$IPADDR" ] ; then # Shut down all NFS mounts on this interface whereami-0.3.34/scripts/0000755000000000000000000000000010620241635011756 5ustar whereami-0.3.34/scripts/bind-forwarders0000755000000000000000000000472410620241635015003 0ustar #!/bin/sh # $Id: bind-forwarders,v 1.8 2004/01/09 12:05:50 andrew Exp $ # # by Andrew McMillan, Catalyst IT Ltd, (c) 2002 licensed # for use under the GPL version 2 # # 2003-12-09 Chris Halls Does not run if resolvconf is installed # # usage: # bind-forwarders # if [ -x /sbin/resolvconf ] ;then logger -p user.info -t whereami -i "bind-forwarders ignored, resolvconf is installed" exit 0 fi # Support bind or bind9 as init script BINDINIT=/etc/init.d/bind if [ -x "${BINDINIT}9" ]; then BINDINIT=${BINDINIT}9 BINDPID="`cat /var/run/bind/run/named.pid`" else BINDPID="`cat /var/run/named.pid`" fi # Possibly this is different for bind9 too? FILENAME=/etc/bind/named.conf if [ ! -e $FILENAME ] ; then logger -p user.warning -t whereami -i "Bind configuration named.conf missing!" cp $FILENAME.last $FILENAME if [ ! -e $FILENAME ] ; then logger -p user.error -t whereami -i "Really stuffed - can't copy from backup named.conf!" exit 1 fi fi # Use the first nameserver in /etc/resolv.conf if we didn't # get told one on the command line. if [ -z "$1" ]; then PRIMARY=`tr -s ' ' $FILENAME.tmp # if [ -e $FILENAME.tmp ] ; then mv $FILENAME $FILENAME.last cp $FILENAME.tmp $FILENAME chmod --reference=$FILENAME $FILENAME.tmp chown --reference=$FILENAME $FILENAME.tmp # Enforce readability by owner as minimum chmod u+r $FILENAME else logger -p user.error -t whereami -i "Error handling named.conf changes!" exit 1 fi # Look for the named.conf file again. if [ ! -e $FILENAME ] ; then logger -p user.error -t whereami -i "Wha..? named.conf gone missing!" exit 1 fi # Test to see if bind is already running (just reload it) or needs to be started BIND_RUNNING="`find /proc -type d -maxdepth 1 -name ${BINDPID}`" if [ "$BIND_RUNNING" = "" ] ; then logger -p user.warning -t whereami -i "Nameserver not running - starting it." ${BINDINIT} start else logger -p user.notice -t whereami -i "Reloading nameserver." ${BINDINIT} reload fi if [ ! -e $FILENAME ] ; then logger -p user.error -t whereami -i "Wha..? named.conf gone missing after restarting bind!" exit 1 fi whereami-0.3.34/scripts/kill-netscape0000755000000000000000000000123010620241635014433 0ustar #!/bin/bash #echo "SIGHUP" kill -SIGHUP `ps ax | grep "netscape.*a[t]or" | sed -e ": x;s/ / /;t x" | cut --field=2 --delimiter=' '` sleep 1 #echo "SIGQUIT" kill -SIGQUIT `ps ax | grep "netscape.*a[t]or" | sed -e ": x;s/ / /;t x" | cut --field=2 --delimiter=' '` #sleep 1 #echo "SIGTERM" #kill -SIGTERM `ps ax | grep "netscape.*a[t]or" | sed -e ": x;s/ / /;t x" | cut --field=2 --delimiter=' '` #sleep 1 #echo "SIGABRT" #kill -SIGABRT `ps ax | grep "netscape.*a[t]or" | sed -e ": x;s/ / /;t x" | cut --field=2 --delimiter=' '` #sleep 1 #echo "SIGKILL" #kill -SIGKILL `ps ax | grep "netscape.*a[t]or" | sed -e ": x;s/ / /;t x" | cut --field=2 --delimiter=' '` whereami-0.3.34/scripts/masqmail_route0000755000000000000000000000204610620241635014730 0ustar #!/bin/sh # # $Id: masqmail_route,v 1.3 2002/11/01 22:05:29 andrew Exp $ # # Integration (well sort of :-) of whereami with masqmail. # # This script looks at the masqmail configuration of the online # file (usually "/tmp/connect_route") and removes it. If one of # our current locations matches a location for which masqmail # is configured then we create a new file with that location. # # whereami sets the list of locations to be comma-separated - possibly a mistake! LOCATIONS="`echo ${LOCATION} | tr ',' ' '`" # Work out what masqmail has specified for the notification file ONLINE_FILE="`grep "^online_file *=" /etc/masqmail/masqmail.conf | cut -f2 -d= | tr -d \\"\\ `" # Remove any existing indications of which location we should use rm -f ${ONLINE_FILE} for LOCN in ${LOCATIONS} ; do if grep "^connect_route.${LOCN} *=" /etc/masqmail/masqmail.conf >/dev/null ; then logger -t whereami -i "Setting masqmail route in ${ONLINE_FILE} to \"${LOCN}\"" echo "${LOCN}" > ${ONLINE_FILE} # We exit on the first success exit 0; fi done whereami-0.3.34/scripts/netscape-option0000755000000000000000000000040710620241635015015 0ustar #!/bin/bash # usage: # netscape-option # FILENAME=$1 echo "Setting $2 to $3 in $FILENAME" sed -e "s/\($2\",\) .*\();$\)/\1 $3\2/" $FILENAME >$FILENAME.tmp chmod --reference=$1 $1.tmp chown --reference=$1 $1.tmp mv $1.tmp $1 whereami-0.3.34/scripts/setproxy0000755000000000000000000000363510620241635013610 0ustar #!/bin/bash # This script is based on one written Fedor Karpelevitch for "oops" # to reconfigure the proxy to set the upstream proxy. I have now # modified it to also handle "Squid", since I decided to switch # my local proxy to that instead. UPSTREAM="$@" # # If several proxies are installed we try and deal to all of them # because it's just too damn much work to figure which one has control! # # The proxies we know how to deal with... PROXIES="oops squid" RELOADACTION="force-reload" modify_conffile() { CONFIGURATION="$1" shift NEWPROXY="$@" PROXYCOMMAND="$1" if [ "${UPSTREAM}" != "none" ]; then echo "${NEWPROXY}" > ${CONFIGURATION}.N fi grep -v "^${PROXYCOMMAND} " ${CONFIGURATION} >> ${CONFIGURATION}.N mv ${CONFIGURATION}.N ${CONFIGURATION} } stopit() { echo "Stopping ${PROXY}" /etc/init.d/${PROXY} stop } startit() { echo "Starting ${PROXY}" /etc/init.d/${PROXY} start } reloadit() { echo "Reloading ${PROXY}" /etc/init.d/${PROXY} ${RELOADACTION} } redirect_oops() { echo "Setting OOPS upstream proxy host ($UPSTREAM)" modify_conffile /etc/oops/oops.cfg parent ${UPSTREAM} } redirect_squid() { PARENT=$1 TYPE=$2 # This bit of mucking around lets us handle things in an # appropriate way if we just have "setproxy # as we would if we switched from OOPS -> Squid... if [ "${TYPE}" = "parent" -o "${TYPE}" = "sibling" ] ; then shift else TYPE=parent fi PORT=${2:-"3128"} ICP_PORT=${3:-"3130"} OPTIONS=${4:-"default"} echo "Setting Squid upstream proxy host (${PARENT}:${PORT})" modify_conffile /etc/squid/squid.conf cache_peer ${PARENT} ${TYPE} ${PORT} ${ICP_PORT} ${OPTIONS} } for PROXY in ${PROXIES} ; do if [ -x /usr/sbin/${PROXY} ] ; then if [ "$UPSTREAM" = "start" ]; then startit elif [ "$UPSTREAM" = "stop" ]; then stopit else redirect_${PROXY} ${UPSTREAM} reloadit fi fi done whereami-0.3.34/scripts/setresolver0000755000000000000000000000164410620241635014266 0ustar #! /bin/bash # # Written by Andrew McMillan, 10th November 1999 # - styled on the pcmcia 'network' script by David Hinds (thanks) # DEVICE=whereami RESOLV=/etc/resolv.conf function buildresolv() { for PART in $@ ; do case "$PART" in domain|search|nameserver) echo -en "\n$PART" ;; *) echo -en " $PART" ;; esac done echo "" } if [ -x '/sbin/resolvconf' ] ; then # Just use resolvconf buildresolv $@ | resolvconf -a $DEVICE 2>&1 | logger -t whereami-setresolver else # Insert a section into the file in a manner similar to # the entries inserted by the pcmcia package if [ "$1" != "" ] ; then echo -n "# $DEVICE begin" > $RESOLV.N buildresolv $@ >> $RESOLV.N echo -e "\n# $DEVICE end" >> $RESOLV.N # Now replace that section into the existing file sed -e "/# $DEVICE begin/,/# $DEVICE end/d" $RESOLV >> $RESOLV.N mv $RESOLV.N $RESOLV fi fi whereami-0.3.34/scripts/tests/0000755000000000000000000000000010712412302013111 5ustar whereami-0.3.34/scripts/tests/testping0000755000000000000000000000346310620241635014711 0ustar #!/bin/bash # $Id: testping,v 1.6 2004/10/19 01:04:06 andrew Exp $ # # Script to assist in locating us on a particular network by confirming # that we manage to hit a specified host with a quick 'ping'. We actually # use 'fping' because it's waaay quicker. # # Written by Andrew McMillan , 10th December 1999 # # [$INTERFACE,]$IPTOFIND,$IPTOUSE # # Turn on execution tracing, for debugging... [ "$DEBUGWHEREAMI" = "1" ] && set -o xtrace IFACE=${1/,*} IPTOUSE=${1/*,} IPTOFIND=${1/,$IPTOUSE} if [ "$IFACE" = "$IPTOFIND" ] ; then # We can also set $INTERFACE externally and that will be used as the default. INTERFACE=${INTERFACE:-"eth0"} else INTERFACE=${IFACE} IPTOFIND=${IPTOFIND/$INTERFACE,} fi ifconfig $INTERFACE $IPTOUSE >/dev/null 2>&1 # Note that the timeout on fping is set very low (30 mS - -t30) so that # the host will need to be close for this to work. Most LANs will # get a response in well under 30mS, but if we fail we will double # the interval (-B2 ) five times before giving up. # RESULT=1 if [ -x /usr/bin/fping ] ; then if [ "`fping -a -B2 -i5 -r5 -t30 $IPTOFIND`" = "$IPTOFIND" ] ; then # Leave the interface running in this case RESULT=0 fi else # Fall back to something that will work without installing fping # We only try a single ping, since we want to be as quick as possible # and we expect to be detecting a LAN ip address. if ! /bin/ping -c 1 -n -q $IPTOFIND | grep "100% packet loss" >/dev/null ; then RESULT=0 fi fi if [ "$RESULT" = "1" ] ; then RESULT=1 # Downing the interface might seem a good idea, but it makes our next # attempt much slower. Better to down it after all attempts have failed. # (i.e. if you want to do that, do it in whereami.conf) ifconfig $INTERFACE 0.0.0.0 >/dev/null 2>&1 fi exit $RESULT whereami-0.3.34/scripts/tests/testsupplicant0000755000000000000000000000342710622542772016146 0ustar #!/bin/sh # # Author: Andrew McMillan # Written: 8th July 2005 (Debconf5, Helsinki) # # This script is designed to help whereami work with the wpasupplicant # package. We make the assumption that wpasupplicant is running and # that you have at least got it working manually, and now you want to # use it with whereami... # # We seem to need to do several things: # - Configure for null encryption and "open" mode # - Bring the interface up. # - Kick the wpa_supplicant daemon # - Either: # - Watch the wpa_cli status output for COMPLETED # - Watch the iwconfig output until we see a real encryption key # # Turn on execution tracing, for debugging... [ -n "$DEBUGWHEREAMI" ] && set -o xtrace MAXATTEMPTS=15 # # Perhaps this is needs to be optional - if so, tell me please! iwconfig ${INTERFACE} enc "ffff-ffff-ff" enc open ifconfig ${INTERFACE} up ACTION=start if pgrep wpa_supplicant >/dev/null ; then ACTION=reload fi if [ -x /etc/init.d/wpasupplicant ] ; then /etc/init.d/wpasupplicant "${ACTION}" else # Kill any existing supplicant, sleeping briefly if we did so pkill wpa_supplicant && sleep 1 # Start a new supplicant /sbin/wpa_supplicant -B -Dwext -i${INTERFACE} -c/etc/wpa_supplicant.conf echo "$!" >/var/run/whereami/supplicant.pid fi while [ "$MAXATTEMPTS" -gt "0" ] ; do if /sbin/wpa_cli -i ${INTERFACE} status | grep 'wpa_state=COMPLETED' >/dev/null ; then # Success exit 0 fi if [ "`iwconfig ${INTERFACE} | grep Encryption | cut -f3 -d: `" = "restricted" ] ; then # Success exit 0 fi # Otherwise we loop again until we have exceeded the timeout... sleep 1 MAXATTEMPTS=$(( $MAXATTEMPTS - 1 )) done # Failed to work within timeout if [ -x /etc/init.d/wpasupplicant ] ; then /etc/init.d/wpasupplicant stop else pkill wpa_supplicant fi exit 1 whereami-0.3.34/scripts/tests/testreceived0000644000000000000000000000070210620241635015530 0ustar #!/bin/bash # $Id: testreceived,v 1.2 2003/03/20 11:41:53 andrew Exp $ # # testreceived - look for received packes on an interface # # Contributed by: Mike Carr # # May supply IFACE as first (and only) argument (or previously set INTERFACE) # Turn on execution tracing, for debugging... [ "$DEBUGWHEREAMI" = "1" ] && set -o xtrace IFACE=${1:-$INTERFACE} /sbin/ifconfig -s $IFACE |tail -1 |awk '$4==0 { exit 1; }' exit $? whereami-0.3.34/scripts/tests/testmodule0000755000000000000000000000046210620241635015235 0ustar #!/bin/sh # $Id: testmodule,v 1.2 2001/12/24 11:53:22 andrew Exp $ # # by Andrew McMillan, Catalyst IT Ltd, (c) 2001 licensed # for use under the GPL version 2 # # Turn on execution tracing, for debugging... [ "$DEBUGWHEREAMI" = "1" ] && set -o xtrace /sbin/lsmod | grep "$1" >/dev/null && exit 0 exit 1 whereami-0.3.34/scripts/tests/testdhcp0000755000000000000000000001651610620241635014675 0ustar #!/bin/bash # # $Id: testdhcp,v 1.16 2005/09/18 10:37:24 andrew Exp $ # # by Andrew McMillan, Catalyst IT Ltd, (c) 2001 licensed # for use under the GPL version 2 # # This script tests whether we are at a specific DHCP-assigned IP address. # DHCP IP address assignment should be done if it hasn't already. # ############################################### # NOTE: This script is something of a work in progress. I can't have experience # with all possible DHCP clients, so if you need help getting it working with what # you happen to use, feel free to call upon me. ############################################### # # Parameters: [,](start|stop|restart|) # # Interface to test. If omitted, use INTERFACE variable (from detect.conf) # # start Start dhcp client (use before testing IP address). # stop Stop dhcp client (use when you do not want to leave the client running) # restart Restart dhcp client # IP address to test for. You may use bash pattern matching # characters for subnet testing. # # Environment variables: # # INTERFACE Default interface name to use if not specified # DEBUGWHEREAMI Turn on debugging output (0 for debug msgs, 1 for execution tracing) # PUMPPATH Path to pump # DHCLIENTPATH Path to dhclient # DHCPCDPATH Path to dhcpcd # DHCPMETHOD Which dhcpclient method to use (pump, dhclient, dhclient3 or dhcpcd). # If unspecified, it will [try to] be automatically selected # # Examples: # testdhcp eth1,192.168.3.7 # testdhcp 192.168.3.* # testdhcp 10.* # testdhcp 192.168.1.[01][0-9] # [ -n "$DEBUGWHEREAMI" ] && set -o xtrace STATEDIR=${STATEDIR:-"/var/lib/whereami"} WHEREAMILOCK=$LOCKDIR/whereami.started PUMPPATH=${PUMPPATH:-/sbin/pump} DHCLIENTPATH=${DHCLIENTPATH:-/sbin/dhclient} DHCLIENT=`basename $DHCLIENTPATH` DHCPCDPATH=${DHCPCDPATH:-/sbin/dhcpcd} debug() { [ -n "$DEBUGWHEREAMI" ] && echo $@ } # Run DHCP action - pump # pump pump() { # We prefer this one at the moment, and it is the Debian (and RH) default # Also consider: It might be advisable to set a timeout in your /etc/pump.conf STATEFILE=$STATEDIR/dhclient.$INTERFACE case $1 in start) # Prod the DHCP server for a new address $PUMPPATH --interface $INTERFACE # Get the status into a file. if ! $PUMPPATH --interface $INTERFACE --status >$STATEFILE; then # OK, looks like it's got it's knickers knotted and we need to nuke it and try again.. killall $PUMPPATH sleep 1 $PUMPPATH --interface $INTERFACE $PUMPPATH --interface $INTERFACE --status >$STATEFILE fi ;; stop) killall $PUMPPATH ;; test) if [ ! -s $STATEFILE -o ! -f $WHEREAMILOCK -o $STATEFILE -ot $WHEREAMILOCK ]; then echo testdhcp: pump was not started return 1 fi DHCP_ADDRESS=`grep "IP: " $STATEFILE | tr -d " " | cut -f2 -d:` ;; esac } dhclient() { # ISC dhcp version 2. # Use the -e flag to make sure that dhclient only runs in the background if it # has a lease. Thus we know if we see dhclient in the background, that the # interface has got an IP address from a DHCP server. # Also consider: It might be advisable to set a timeout in your /etc/dhclient.conf STATEFILE=$STATEDIR/dhclient.$INTERFACE [ -z "$DEBUGWHEREAMI" ] && QUIETFLAG=-q case $1 in start) if $DHCLIENTPATH $QUIETFLAG -e $INTERFACE; then # dhclient started and got a lease return 0 else # no address - disable interface ifconfig $INTERFACE down return 1 fi ;; stop) dhcli_pid="`ps ax | grep $DHCLIENT | grep $INTERFACE | cut -c-5`" [ -n "$dhcli_pid" ] && kill $dhcli_pid ifconfig $INTERFACE down rm -f $STATEFILE ;; test) # if dhclient is running, we have an IP address if ps ax | grep $DHCLIENT | grep -q $INTERFACE ; then DHCP_ADDRESS="`/sbin/ifconfig $INTERFACE | head -2 | tail -1 | cut -d: -f2 | cut -d\ -f1`" [ -n "$DHCP_ADDRESS" ] && return 0 || return 1 else return 1 fi ;; esac } dhclient3() { # ISC dhcp version 3. # We drop a file in /etc/dhcp3/dhclient-exit-hooks.d/whereami, that # saves the DHCP state in /var/run/whereami/dhclient3.. # We also call whereami with --hint dhclient3 on state changes, so # we only need to look at the dhclient state # we know if we see dhclient in the background, that the # interface has got an IP address from a DHCP server. # Also consider: It might be advisable to set a timeout in your /etc/dhclient.conf STATEFILE=$STATEDIR/dhclient3.$INTERFACE [ -z "$DEBUGWHEREAMI" ] && QUIETFLAG=-q case $1 in start) $DHCLIENTPATH -1 $QUIETFLAG $INTERFACE ;; stop) dhcli_pid="`ps ax | grep $DHCLIENT | grep $INTERFACE | cut -c-5`" [ -n "$dhcli_pid" ] && kill $dhcli_pid ifconfig $INTERFACE down rm -f $STATEFILE ;; test) DHCP_ADDRESS="`grep new_ip_address= $STATEFILE | cut -f2 -d=`" [ -n "$DHCP_ADDRESS" ] ;; esac } dhcpcd() { INFOFILE="/var/lib/dhcpc/dhcpcd-$INTERFACE.info" PIDFILE="/var/run/dhcpcd-$INTERFACE.pid" case $1 in start) # Prod the DHCP server for a new address if $DHCPCDPATH -n "$INTERFACE"; then # dhcpcd started and got a lease return 0 else # no address - clear interface ifconfig "$INTERFACE" 0.0.0.0 return 1 fi ;; stop) if [ -s "$PIDFILE" ] && kill -0 "`cat "$PIDFILE"`" ;then $DHCPCDPATH -k "$INTERFACE" > /dev/null fi ;; test) if [ ! -s "$INFOFILE" -o ! -s "$PIDFILE" ]; then debug testdhcp: dhcpcd was not started return 1 fi DHCP_ADDRESS="`grep '^IPADDR=' $INFOFILE| cut -f2 -d=`" ;; esac } # Turn on execution tracing, for debugging... [ "$DEBUGWHEREAMI" = "1" ] && set -o xtrace case $1 in *,*) INTERFACE=${1/,*} IP_ADDRESS=${1/*,} ;; *) # Use INTERFACE variable; default to eth0 if not set INTERFACE=${INTERFACE:-eth0} IP_ADDRESS="$1" ;; esac mkdir -p $STATEDIR if [ -z "$DHCPMETHOD" ]; then if [ -x "$PUMPPATH" ]; then DHCPMETHOD=pump elif [ -x "$DHCLIENTPATH" ]; then $DHCLIENTPATH --version 2>&1 | grep -i -q "DHCP Client V3\|dhclient-V3" && DHCPMETHOD=dhclient3 || DHCPMETHOD=dhclient elif [ -x "$DHCPCDPATH" ]; then DHCPMETHOD=dhcpcd else logger -p user.error -t whereami -i "testdhcp: No suitable DHCP client found!" debug "testdhcp: No suitable DHCP client found!" exit 1 fi fi case $IP_ADDRESS in '*.*.*.*') ACTION=restart ;; start|stop|restart) ACTION=$IP_ADDRESS ;; *) ACTION=test ;; esac debug testdhcp method:$DHCPMETHOD interface:$INTERFACE action:$ACTION IP:$IP_ADDRESS if [ $ACTION = restart ];then $DHCPMETHOD stop $DHCPMETHOD start else $DHCPMETHOD $ACTION fi STATUS=$? if [ $ACTION = test -a $STATUS = 0 ] ;then # echo "DHCP=$DHCP_ADDRESS" [ "${DHCP_ADDRESS/#$IP_ADDRESS/FOUND}" = "FOUND" ] && exit 0 # echo "Sorry $IP_ADDRESS not found" exit 2 fi exit $STATUS whereami-0.3.34/scripts/tests/testarp0000755000000000000000000000401310620241635014526 0ustar #!/bin/bash # # $Id: testarp,v 1.11 2004/10/05 20:47:22 andrew Exp $ # # by Andrew McMillan, Catalyst IT Ltd, (c) 2001 licensed # for use under the GPL version 2 # # Thanks to Alexander Clouter for some of the basis of this script :-) # # [$INTERFACE,]$MAC_ADDRESS,$IP_ADDRESS[,$IP_TO_USE] # # Turn on execution tracing, for debugging... [ "$DEBUGWHEREAMI" = "1" ] && set -o xtrace # Split out our parameters. This is getting silly! case "$1" in *,*,*,*) # All four! Easy :-) IFACE=${1/,*,*,*} IP_TO_USE=${1/*,*,*,} MIDDLE=${1/$IFACE,} MAC_ADDRESS=${MIDDLE/,*} MIDDLE=${MIDDLE/$MAC_ADDRESS,} IP_ADDRESS=${MIDDLE/,*} ;; *,*:*,*) # Must be IF,MAC,TARGET IFACE=${1/,*} IP_ADDRESS=${1//*,} MAC_ADDRESS=${1/$IFACE,} MAC_ADDRESS=${MAC_ADDRESS/,$IP_ADDRESS} ;; *,*,*) # Must be MAC,TARGET,OUR_IP MAC_ADDRESS=${1/,*} IP_TO_USE=${1//*,} IP_ADDRESS=${1/$MAC_ADDRESS,} IP_ADDRESS=${IP_ADDRESS/,$IP_TO_USE} ;; *:*,*) # Must be MAC,TARGET MAC_ADDRESS=${1/,*} IP_ADDRESS=${1/*,} ;; *) # Invalid logger -p user.error -t whereami -i "testarp: bogus parameter '$1'" exit 2 ;; esac if [ "$IFACE" = "" ] ; then # We can also set $INTERFACE externally and that will be used as the default. INTERFACE=${INTERFACE:-"eth0"} else INTERFACE=${IFACE} MAC_ADDRESS=${MAC_ADDRESS/$INTERFACE,} fi IFSTATE="`ifconfig | egrep \"^${INTERFACE}[\t ]\"`" if [ "$IFSTATE" = "" ] ; then # Some systems need the interface "up", some don't ifconfig $INTERFACE up > /dev/null 2>&1 fi if (arping -f -w1 -D -I $INTERFACE $IP_ADDRESS | grep -i -e $MAC_ADDRESS > /dev/null 2>&1) ; then if [ "$IP_TO_USE" != "" ] ; then # Configure the interface if successful, and we have an IP to use ifconfig $INTERFACE $IP_TO_USE >/dev/null 2>&1 fi RESULT=0 else # Be a tidy kiwi, and put the interface back how we found it... if [ "$IFSTATE" = "" ] ; then ifconfig $INTERFACE down > /dev/null 2>&1 fi # echo "Not found" RESULT=1 fi exit $RESULT whereami-0.3.34/scripts/tests/testssid0000755000000000000000000000406110620241635014711 0ustar #!/bin/bash # # Script to assist in locating us on a particular wireless network # # Written by Andrew McMillan , 15th November 2002 # Changed by Adrian Woizik , 06th March 2003 # # $1 is the parameters we are finding, comma-separated # - Expected SSID # # [ "$DEBUGWHEREAMI" != "" ] && set -o xtrace WLANTIMEOUT=${TIMEOUT:-"2"} case $1 in *,*) TESTSSID="${1/,*}" WEPKEY="${1/*,}" ;; *) # WEP off WEPKEY="" TESTSSID="$1" ;; esac if [ "${WEPKEY}" != "" ] ; then iwconfig $INTERFACE key "${WEPKEY}" fi LINKPWR="`cat /proc/net/wireless | grep $INTERFACE | tr -s ' ' | cut -f4 -d' ' | cut -f1 -d.`" if [ "`grep -E '(driverloader|ndiswrapper)' /proc/modules`" != "" ] ; then # ndiswrapper and the linuxant driverloader only return a binary value MINPWR=0 else MINPWR=5 fi if [ "$LINKPWR" -gt "$MINPWR" ] ; then FOUNDSSID="`iwgetid $INTERFACE | cut -f2 -d: | cut -f2 -d'\"'`" if [ "$FOUNDSSID" = "$TESTSSID" ] ; then # we are already configured, exit and do not touch iwconfig. RESULT=0 exit $RESULT else # we are configured but not for this SSID. RESULT=1 fi fi iwconfig $INTERFACE essid on iwconfig $INTERFACE essid "${TESTSSID}" # be sure that $INTERFACE is up, for linkstat ifconfig $INTERFACE up # How long to wait? 1 second is _usually_ enough, but not always sleep ${WLANTIMEOUT} LINKPWR="`cat /proc/net/wireless | grep $INTERFACE | tr -s ' ' | cut -f4 -d' ' | cut -f1 -d.`" if [ "$LINKPWR" -gt 5 ] ; then iwconfig $INTERFACE key restricted [ "$DEBUGWHEREAMI" != "" ] && echo "Found power of ${LINKPWR} for $TESTSSID on interface $INTERFACE (WEP)" RESULT=0 else # Turn the Key off again to look for a non-WEP AP iwconfig $INTERFACE key off LINKPWR="`cat /proc/net/wireless | grep $INTERFACE | tr -s ' ' | cut -f4 -d' ' | cut -f1 -d.`" if [ "$LINKPWR" -gt 4 ] ; then [ "$DEBUGWHEREAMI" != "" ] && echo "found $TESTSSID on interface $INTERFACE" RESULT=0 else [ "$DEBUGWHEREAMI" != "" ] && echo "$TESTSSID not found" RESULT=1 fi fi exit $RESULT whereami-0.3.34/scripts/tests/testusb0000755000000000000000000000030210620241635014532 0ustar #!/bin/sh # # Contributed by Brett Johnson # # Turn on execution tracing, for debugging... [ "$DEBUGWHEREAMI" = "1" ] && set -o xtrace /usr/sbin/lsusb | grep "$1" >/dev/null && exit 0 exit 1 whereami-0.3.34/scripts/tests/testwpa0000644000000000000000000001234610712412302014531 0ustar #!/bin/bash # # $Id: $ # $ManualTag: V0.2 $ ;) # # By François TOURDE , based on work of # Andrew McMillan, Catalyst IT Ltd, # (c) 2007 licensed for use under the GPL version 2 # # Parameters: # - first form: [,](start|stop) # - second form: [,](),() # # Interface to test. If omitted, use INTERFACE variable (from detect.conf) # # start|stop If wpa_supplicant is not started, used to start or stop it. Further wpa configs # will be done using wpa_cli. # # A pattern that should match the ESSID we are looking for. # # WPA-PSK key A WPA-PSK key, using the format accepted by "iwconfig". This is only applied # if the pattern match is successful. # # Environment variables: # # INTERFACE Default interface name to use if not specified # DEBUGWHEREAMI Turn on debugging output (0 for debug msgs, 1 for execution tracing) # # Examples: # testwpa eth1,start dummy # set INTERFACE eth1 # testwpa mylan,my_secret_code my_location # testwpa stop dummy # # Turn on execution tracing, for debugging... [ -n "$DEBUGWHEREAMI" ] && set -o xtrace [ -n "$DEBUGWHEREAMI" ] && echo "0:$0, 1:$1, 2:$2" PARAMETERS=${1:-"start"} WHEREAMILOCK=$LOCKDIR/whereami.started WPAKEY="" PATTERN="" ACTION="test" INTERFACE=${INTERFACE:-eth0} [ -n "$DEBUGWHEREAMI" ] && echo "\$1>$1<" case ${PARAMETERS} in *,start) [ -n "$DEBUGWHEREAMI" ] && echo "interface,start" # First form INTERFACE="${1/,start}" ACTION="start" ;; *,stop) [ -n "$DEBUGWHEREAMI" ] && echo "interface,stop" # First form INTERFACE="${1/,stop}" ACTION="stop" ;; start) [ -n "$DEBUGWHEREAMI" ] && echo "start" # First form INTERFACE="${INTERFACE:-eth0}" ACTION="start" ;; stop) [ -n "$DEBUGWHEREAMI" ] && echo "stop" # First form INTERFACE="${INTERFACE:-eth0}" ACTION="stop" ;; *,*,*) [ -n "$DEBUGWHEREAMI" ] && echo "interface,essid,wpakey" # Third form INTERFACE="${1/,*}" WPAKEY="${1/*,}" PATTERN="${1/$INTERFACE,}" PATTERN="${PATTERN/,$WPAKEY}" ;; *,*) [ -n "$DEBUGWHEREAMI" ] && echo "essid,wpakey" # Second form PATTERN="${1/,*}" WPAKEY="${1/*,}" ;; *) [ -n "$DEBUGWHEREAMI" ] && echo "essid only!" # Second form PATTERN="$1" ;; esac # Setup some wpa parms WPA_IFACE=$INTERFACE IF_WPA_VERBOSITY=$DEBUGWHEREAMI # source functions if [ -f /etc/wpa_supplicant/functions.sh ]; then . /etc/wpa_supplicant/functions.sh else [ -n "$DEBUGWHEREAMI" ] && echo "No /etc/wpa_supplicant/functions.sh usable. Check your WPA installation" exit 1 fi # Other wpa parms WPA_SUP_CONF="-C $WPA_CTRL_DIR" ###################################################### # Utility to do some supplicant operations ###################################################### launch_supplicant() { # Run the wpa_supplicant daemon kill_supplicant init_wpa_supplicant || exit 1 } ###################################################### # Utility to do some supplicant operations ###################################################### conf_supplicant() { # We can call supplicant client to setup link conf_wpa_supplicant || { kill_supplicant; exit 1;} } ###################################################### # Utility to do some supplicant operations ###################################################### kill_supplicant() { # stop the wpa_supplicant daemon kill_wpa_supplicant } ###################################################### # The main task # Start and stop must return errors, because they're # not now tips to find network. # # wpa_state possible values: WPA_DISCONNECTED,WPA_INACTIVE,WPA_SCANNING,WPA_ASSOCIATING,WPA_ASSOCIATED, # WPA_4WAY_HANDSHAKE,WPA_GROUP_HANDSHAKE,WPA_COMPLETED ###################################################### case ${ACTION} in start) # Launch wpa_supplicant, with standard parms launch_supplicant $INTERFACE STATUS=1 ;; stop) # Stop supplicant kill_supplicant $INTERFACE STATUS=1 ;; test) # Now, we must test link wpa_cli scan if wpa_cli scan_results|grep --quiet "$PATTERN"; then [ -n "$DEBUGWHEREAMI" ] && echo "Found SSID!" # Starting the link... The following commands must be checked # for a {OK, FAIL} return message... later :) NETID=$(wpa_cli add_network) wpa_cli select_network $NETID wpa_cli set_network $NETID ssid '"'$PATTERN'"' wpa_cli set_network $NETID key_mgmt WPA-PSK wpa_cli set_network $NETID psk '"'$WPAKEY'"' # Now, we must check network link... following handshaking mechanism STATUS=-1 while [ $STATUS == -1 ] ; do STATUS_TEXT=$(wpa_cli status|grep "wpa_state="|sed -e 's/.*=//') [ -n "$DEBUGWHEREAMI" ] && echo "Connection state: "${STATUS_TEXT} case ${STATUS_TEXT} in SCANNING|ASSOCIAT*|*_HANDSHAKE) sleep 1; ;; COMPLETED) [ -n "$DEBUGWHEREAMI" ] && echo "Connection complete" STATUS=0 ;; *) [ -n "$DEBUGWHEREAMI" ] && echo "Connection not completed" STATUS=1 ;; esac done else [ -n "$DEBUGWHEREAMI" ] && echo "SSID not found" STATUS=1 fi ;; *) ;; esac exit $STATUS whereami-0.3.34/scripts/tests/testmii0000755000000000000000000000151710620241635014530 0ustar #!/bin/sh # # by Andrew McMillan, Catalyst IT Ltd, (c) 2001 licensed # for use under the GPL version 2 # # Turn on execution tracing, for debugging... [ "$DEBUGWHEREAMI" = "1" ] && set -o xtrace ifconfig $1 up # # Use apparently more reliable mii-tool... if [ -x /sbin/mii-tool ] ; then /sbin/mii-tool $1 2>&1 | grep "link ok" >/dev/null && exit 0 # Don't exit on failure unless we confirm that mii-tool was supported # since it won't work on many modern Gb cards... /sbin/mii-tool $1 2>&1 | grep "Operation not supported" >/dev/null || exit 1 fi if [ -x /usr/sbin/ethtool ] ; then # Fall back to ethtool, which can give false positives on this /usr/sbin/ethtool $1 2>&1 | grep "Link detected: yes" >/dev/null && exit 0 fi # Interface is not connected - bring it down to remove it from # routing table ifconfig $1 down exit 1 whereami-0.3.34/scripts/tests/testappassive0000755000000000000000000000632710620241635015751 0ustar #!/bin/bash # # $Id: testappassive,v 1.1 2005/02/12 23:28:24 andrew Exp $ # # by Andrew McMillan, Catalyst IT Ltd, (c) 2004 licensed # for use under the GPL version 2 # Altered by Matthew Grant , (c) 2004 # # This script uses "iwlist ${INTERFACE} scan" to see if we can connect to # a useful local WLAN. # ############################################### # NOTE: This script is something of a work in progress. I can't have experience # with all possible WLAN hardware, so if you need help getting it working with what # you happen to use, feel free to call upon me. ############################################### # # Parameters: # - first form: [,]scan # - second form: # - third form: [,] # # Interface to test. If omitted, use INTERFACE variable # (from detect.conf) # # scan Normally we just use the last scan details (if they're less # than 10 secs old), but sometimes we may want to force a scan. # # A pattern that should match the ESSID we are looking for. # # Environment variables: # # INTERFACE Default interface name to use if not specified # DEBUGWHEREAMI Turn on debugging output (0 for debug msgs, 1 for execution tracing) # # Examples: # testapscan eth1,scan # set INTERFACE eth1 # testapscan scan # testapscan eth1,othercap # testapscan friendap # set INTERFACE ath0 # testapscan mywlan # STATEDIR=${STATEDIR:-"/var/lib/whereami"} WHEREAMILOCK=$LOCKDIR/whereami.started ###################################################### # Perform the actual scan, which gets all nearby AP # details into a file we will use for subsequent calls ###################################################### scan_for_ap() { IFSTATE="`ifconfig | egrep \"^${INTERFACE}[\t ]\"`" if [ "$IFSTATE" = "" ] ; then ifconfig ${INTERFACE} up # We seem to need a sleep here to accumulate the # scan data - for madwifi, at least. sleep 5 fi /sbin/iwlist ${INTERFACE} scan >${STATEFILE} # Be a tidy kiwi, and put the interface back how we found it... if [ "$IFSTATE" = "" ] ; then ifconfig ${INTERFACE} down fi } ###################################################### # Utility to do pattern match, with awkward quoting ###################################################### ap_pattern_match() { egrep "ESSID:\"$1\"" "${STATEFILE}" } ###################################################### # Test if there is an AP in our scan that matches ###################################################### test_which_ap() { ap_pattern_match "$1" >/dev/null } # Turn on execution tracing, for debugging... [ -n "$DEBUGWHEREAMI" ] && set -o xtrace PATTERN="" ACTION="test" INTERFACE=${INTERFACE:-eth0} case $1 in *,scan) # First form INTERFACE=${1/,scan} ACTION="scan" ;; scan) # First form INTERFACE=${INTERFACE:-eth0} ACTION="scan" ;; *,*) # Third form INTERFACE=${1/,*} PATTERN=${1/*,} ;; *) # Second form PATTERN="$1" ;; esac STATEFILE=$STATEDIR/iwlist.$INTERFACE mkdir -p $STATEDIR STATUS=1 if [ "$ACTION" = "scan" ] ; then scan_for_ap STATUS=$? fi if [ "$PATTERN" != "" ];then test_which_ap "$PATTERN" STATUS=$? fi exit $STATUS whereami-0.3.34/scripts/tests/testap0000755000000000000000000001216510620241635014353 0ustar #!/bin/bash # # $Id: testap,v 1.9 2006/11/12 00:39:14 andrew Exp $ # # by Andrew McMillan, Catalyst IT Ltd, (c) 2004 licensed # for use under the GPL version 2 # # This script uses "iwlist ${INTERFACE} scan" to see if we can connect to # a useful local WLAN. # ############################################### # NOTE: This script is something of a work in progress. I can't have experience # with all possible WLAN hardware, so if you need help getting it working with what # you happen to use, feel free to call upon me. ############################################### # # Parameters: # - first form: [,]scan # - second form: ()[,WEP key] # - third form: [,](),WEP key # # Interface to test. If omitted, use INTERFACE variable (from detect.conf) # # scan Normally we just use the last scan details (if they're less than 10 secs # old), but sometimes we may want to force a scan. # # A pattern that should match the ESSID we are looking for. # # WEP key A WEP key like 12345bcdef (40-bit), 123456789abcdef0123456789a (128 bit), # or any other format accepted by "iwconfig". This is only applied # if the pattern match is successful. # # If only two parameters are supplied, the are assumed to be the pattern and # the WEP key to be assigned if the pattern match is successful. # # Environment variables: # # INTERFACE Default interface name to use if not specified # DEBUGWHEREAMI Turn on debugging output (0 for debug msgs, 1 for execution tracing) # # Examples: # testap eth1,scan # set INTERFACE eth1 # testap scan # testap eth1,othercap # testap eth1,apother,12345bcdef # testap friendap,12345bcdef # set INTERFACE ath0 # testap mywlan # # Turn on execution tracing, for debugging... [ -n "$DEBUGWHEREAMI" ] && set -o xtrace [ -n "$DEBUGWHEREAMI" ] && echo "0:$0, 1:$1, 2:$2" PARAMETERS=${1:-"scan"} STATEDIR=${STATEDIR:-"/var/lib/whereami"} WHEREAMILOCK=$LOCKDIR/whereami.started ISMADWIFI="`grep ath_pci /proc/modules 2>/dev/null`" ###################################################### # Utility to do pattern match, with awkward quoting ###################################################### ap_pattern_match() { egrep "ESSID:\"$1\"" "${STATEFILE}" } ###################################################### # Test if there is an AP in our scan that matches ###################################################### test_which_ap() { ap_pattern_match "$1" >/dev/null } ###################################################### # Perform the actual scan, which gets all nearby AP # details into a file we will use for subsequent calls ###################################################### scan_for_ap() { MAXATTEMPTS=4 IFSTATE="`ifconfig | egrep \"^${INTERFACE}[\t ]\"`" if [ "$IFSTATE" = "" ] ; then ifconfig ${INTERFACE} up fi while [ "$MAXATTEMPTS" -gt "0" ] ; do # Do the actual scan for APs /sbin/iwlist ${INTERFACE} scan >"${STATEFILE}" if test_which_ap '.*' ; then return $? fi # Otherwise we loop again until we have exceeded the attempt limit... sleep 1 MAXATTEMPTS=$(( $MAXATTEMPTS - 1 )) done if [ "$IFSTATE" = "" ] ; then ifconfig ${INTERFACE} down fi } ###################################################### # Assign the first ESSID that matched the pattern ###################################################### assign_matching_essid() { FIRST_SSID="`ap_pattern_match \"$1\" | head -n1 | cut -f2 -d'\"'`" if [ "" != "${FIRST_SSID}" ] ; then # On is required for some cards (Debian bug #309279) iwconfig ${INTERFACE} essid on iwconfig ${INTERFACE} essid "${FIRST_SSID}" fi } WEPKEY="" PATTERN="" ACTION="test" INTERFACE=${INTERFACE:-eth0} [ -n "$DEBUGWHEREAMI" ] && echo "\$1==$1==" case ${PARAMETERS} in *,scan) [ -n "$DEBUGWHEREAMI" ] && echo "interface,scan" # First form INTERFACE="${1/,scan}" ACTION="scan" ;; scan) [ -n "$DEBUGWHEREAMI" ] && echo "scan only" # First form INTERFACE="${INTERFACE:-eth0}" ACTION="scan" ;; *,*,*) [ -n "$DEBUGWHEREAMI" ] && echo "interface,essid,wepkey" # Third form INTERFACE="${1/,*}" WEPKEY="${1/*,}" PATTERN="${1/$INTERFACE,}" PATTERN="${PATTERN/,$WEPKEY}" ;; *,*) [ -n "$DEBUGWHEREAMI" ] && echo "essid,wepkey" # Second form PATTERN="${1/,*}" WEPKEY="${1/*,}" ;; *) [ -n "$DEBUGWHEREAMI" ] && echo "essid only!" # Second form PATTERN="$1" ;; esac STATEFILE=$STATEDIR/iwlist.$INTERFACE mkdir -p $STATEDIR STATUS=1 if [ "$ACTION" = "scan" ] ; then scan_for_ap STATUS=$? fi if [ "$PATTERN" != "" ];then test_which_ap "$PATTERN" STATUS=$? if [ "${STATUS}" -eq 0 ] ; then # We found a match, so assign that ESSID assign_matching_essid "${PATTERN}" # And apply the appropriate WEP key, or turn it off if [ "${WEPKEY}" = "" ] ; then iwconfig $INTERFACE enc off else # underscore is used as an argument separator in WEP key, in # order to pass multiple parameters to iwconfig iwconfig $INTERFACE key ${WEPKEY//_/ } fi fi fi exit $STATUS whereami-0.3.34/scripts/tests/testpci0000755000000000000000000000046610620241635014527 0ustar #!/bin/sh # $Id: testpci,v 1.3 2004/03/21 11:29:50 andrew Exp $ # # by Andrew McMillan, Catalyst IT Ltd, (c) 2001 licensed # for use under the GPL version 2 # # Turn on execution tracing, for debugging... [ "$DEBUGWHEREAMI" = "1" ] && set -o xtrace /usr/bin/lspci -v | grep "$1" >/dev/null && exit 0 exit 1 whereami-0.3.34/scripts/tests/testprocsys0000755000000000000000000000073210620241635015452 0ustar #!/bin/bash # # by Matthew Grant , (c) 2004 # licensed for use under GPL version 2 # # Tests whether hotplug is set up and running or not. # Turn on debugging [ "$DEBUGWHEREAMI" = "1" ] && set -o xtrace case $1 in *,*) FILE=${1/,*} STRING=${1/*,} ;; *) [ "$DEBUGWHEREAMI" != "" ] \ && echo "$0: failing miserably - args not understood" exit 255 ;; esac [ -f "$FILE" ] \ && cat "$FILE" | grep -E -q "$STRING" \ && exit 0 exit 1 whereami-0.3.34/scripts/setdnsmasq0000755000000000000000000000023310620241635014064 0ustar #!/bin/sh echo "nameserver $1" >/etc/resolv.dnsmasq if [ -f /var/run/dnsmasq/resolv.conf ] ; then echo "nameserver $1" >/var/run/dnsmasq/resolv.conf fi whereami-0.3.34/scripts/findnet0000755000000000000000000000214010620241635013330 0ustar #!/bin/sh # # Script to assist in locating us on a particular network by confirming # that we manage to hit a specified host with a quick 'ping'. We actually # use 'fping' because it's waaay quicker. # # Written by Andrew McMillan , 10th December 1999 # # $1 is the IP we are trying to find # $2 is the IP number we should use on that subnet # mynet=`echo $1 | cut -d'.' -f1-3` myip=$mynet.$2 ifconfig eth0 $myip >/dev/null 2>&1 # Note that the timeout on fping is set very low (30 mS - -t30) so that # the host will need to be close for this to work. Most LANs will # get a response in well under 30mS, but we kind of insist because # we're only gonna retry once... (-r1). # if (fping -a -b12 -B1.2 -i5 -r1 -t30 $1) ; then # echo "found $1" # Leave the interface running in this case RESULT=0 else # echo "Not found" RESULT=1 # Downing the interface might seem a good idea, but it makes our next # attempt much slower. Better to down it after all attempts have failed. # ifconfig eth0 down ifconfig eth0 0.0.0.0 >/dev/null 2>&1 fi exit $RESULT whereami-0.3.34/scripts/setmailrelay0000755000000000000000000001604110620241635014401 0ustar #!/bin/bash # $Id: setmailrelay,v 1.12 2004/10/05 20:47:22 andrew Exp $ # # This script was written originally by Jos Visser http://www.josv.com/~josv/ # and I have modified it a little to make it slightly more generic # - Andrew McMillan 10 August 1999 # Postfix support by Chris Halls, August 2001 # Exim support by Auke Jilderda, October 2002 # qmail support by Patrice Neff, October 2003 # exim4 support by Itay Ben-Yaacov, April 2004 # # 2003-12-09 Chris Halls Use postconf for postfix configuration # # Usage: # setmailrelay none # - You have a permanent internet connection, do not use a mail relay # setmailrelay # - Relay to specified host # setmailrelay queue [] # - Do not send, place on the queue. When the queue is flushed, mail # will be relayed to , or $DEFAULT_RELAY if not specified # Where are the config files for your mailer? Can override in mail-relay.conf SENDMAIL_CONFFILE=/etc/mail/sendmail.cf POSTFIX_CONFFILE=/etc/postfix/main.cf EXIM_CONFFILE=/etc/exim/exim.conf EXIM4_CONFFILE=/etc/exim4/update-exim4.conf.conf QMAIL_CONFDIR=/etc/qmail/ # Where we get MAIL_SERVER and DEFAULT_RELAY from . /etc/whereami/mail-relay.conf RELAY="${1:-none}" QUEUE_RELAY="${2:-${DEFAULT_RELAY}}" # check for a "parameter=" line in a file, add it if it does not exist # check_for_line(file, parameter) check_for_parameter() { FILE="$1" PARAM="$2" if egrep -q "^$PARAM *=" "$FILE" ; then : else echo "$PARAM=" >> "$FILE" fi } if [ "$MAIL_SERVER" = "" ]; then # Go for some reasonable choices if [ -f $SENDMAIL_CONFFILE ] ; then MAIL_SERVER=sendmail elif [ -f $POSTFIX_CONFFILE ] ; then MAIL_SERVER=postfix elif [ -f $EXIM_CONFFILE ] ; then MAIL_SERVER=exim elif [ -f $EXIM4_CONFFILE ] ; then MAIL_SERVER=exim4 # Only supports split configuration elif [ -d $QMAIL_CONFDIR ] ; then MAIL_SERVER=qmail else echo "Unsupported mail server configuration check /etc/whereami/mail-relay.conf" echo "or advise awm@debian.org, hopefully including a patch!" exit 1 fi fi echo "Setting mail relay host ($RELAY)" case "$MAIL_SERVER" in sendmail) /etc/init.d/sendmail stop if [ "$RELAY" = "none" ]; then MODE=background QUEUE_RUN="-q5m" RELAY="" elif [ "$RELAY" = "queue" ]; then MODE=deferred QUEUE_RUN="" RELAY="smtp:${DEFAULT_RELAY}" else MODE=background QUEUE_RUN="-q5m" RELAY="smtp:$RELAY" fi sed -e "s/^DS.*\$/DS$RELAY/" \ -e "s/^O DeliveryMode=.*\$/O DeliveryMode=$MODE/" \ <$SENDMAIL_CONFFILE >$SENDMAIL_CONFFILE.N # Preserve the ownership and permissions chmod --reference=$SENDMAIL_CONFFILE $SENDMAIL_CONFFILE.N chown --reference=$SENDMAIL_CONFFILE $SENDMAIL_CONFFILE.N # Make a backup copy mv -f $SENDMAIL_CONFFILE $SENDMAIL_CONFFILE.whereami mv $SENDMAIL_CONFFILE.N $SENDMAIL_CONFFILE /etc/init.d/sendmail start if [ "$QUEUE_RUN" = "-q5m"]; then /etc/init.d/sendmail runq fi ;; postfix) if [ "$RELAY" = "none" ]; then DEFER="" DISABLE_LOOKUPS="no" RELAY="" elif [ "$RELAY" = "queue" ]; then DEFER="smtp" DISABLE_LOOKUPS="yes" RELAY="$DEFAULT_RELAY" else DEFER="" DISABLE_LOOKUPS="yes" MODE=background RELAY="$RELAY" fi postconf -ev defer_transports=$DEFER disable_dns_lookups=$DISABLE_LOOKUPS \ "relayhost=$RELAY" # Need to reload after changing things /etc/init.d/postfix reload if [ "$RELAY" != "queue" ]; then # Run mail queue /etc/init.d/postfix flush fi ;; exim) if [ "$RELAY" = "none" ]; then DEFER="# queue_remote_domains = *" RELAY="$DEFAULT_RELAY" elif [ "$RELAY" = "queue" ]; then DEFER="queue_remote_domains = ! *" RELAY="$DEFAULT_RELAY" else DEFER="# queue_remote_domains = *" RELAY="$RELAY" fi # add parameters to configuration file if they do not exist #check_for_parameter $EXIM_CONFFILE "queue_remote_domains" #check_for_parameter $EXIM_CONFFILE "route_list" sed -e "s/^.*queue_remote_domains *=.*\$/$DEFER/" \ -e "s/route_list *=.*\$/route_list = \"* $RELAY bydns_a\"/" \ < $EXIM_CONFFILE > $EXIM_CONFFILE.N # Preserve the ownership and permissions chmod --reference=$EXIM_CONFFILE $EXIM_CONFFILE.N chown --reference=$EXIM_CONFFILE $EXIM_CONFFILE.N # make a backup copy of configuration file mv -f $EXIM_CONFFILE $EXIM_CONFFILE.whereami mv $EXIM_CONFFILE.N $EXIM_CONFFILE # reload configuration /etc/init.d/exim reload if [ "$RELAY" != "queue" ]; then # flush queued mails exim -qff fi ;; exim4) if [ "$RELAY" = "none" ]; then DEFER="no" RELAY="$DEFAULT_RELAY" elif [ "$RELAY" = "queue" ]; then DEFER="yes" RELAY="" else DEFER="no" fi sed -e "s/dc_smarthost=.*/dc_smarthost=\'$RELAY\'/" \ < $EXIM4_CONFFILE > $EXIM4_CONFFILE.N # Preserve the ownership and permissions chmod --reference=$EXIM4_CONFFILE $EXIM4_CONFFILE.N chown --reference=$EXIM4_CONFFILE $EXIM4_CONFFILE.N # make a backup copy of configuration file # mv -f $EXIM4_CONFFILE $EXIM4_CONFFILE.whereami mv $EXIM4_CONFFILE.N $EXIM4_CONFFILE # reload configuration /etc/init.d/exim4 reload if [ "$DEFER" = "no" ]; then # flush queued mails exim4 -qff fi ;; qmail) QMAIL_CONFFILE="${QMAIL_CONFDIR}smtproutes" QMAIL_CONFFILE_NEW="${QMAIL_CONFFILE}.setmailrelay" if [ "$RELAY" = "none" ]; then DELIVERIES="20" RELAY="$DEFAULT_RELAY" elif [ "$RELAY" = "queue" ]; then DELIVERIES="0" RELAY="$DEFAULT_RELAY" else DELIVERIES="20" RELAY="$RELAY" fi if [ -e $QMAIL_CONFFILE ]; then grep ':[^:]*' $QMAIL_CONFFILE >$QMAIL_CONFFILE_NEW else >$QMAIL_CONFFILE_NEW fi [ -n "$RELAY" ] && echo "$RELAY" >>$QMAIL_CONFFILE_NEW # Preserve the ownership and permissions chmod --reference=$QMAIL_CONFFILE $QMAIL_CONFFILE_NEW chown --reference=$QMAIL_CONFFILE $QMAIL_CONFFILE_NEW mv $QMAIL_CONFFILE_NEW $QMAIL_CONFFILE echo $DELIVERIES >"${QMAIL_CONFDIR}concurrencyremote" /etc/init.d/qmail restart ;; *) echo "Unrecognised mail server type" ;; esac whereami-0.3.34/scripts/settimezone0000755000000000000000000000035510620241635014255 0ustar #!/bin/sh # # Set timezone - contributed by Itay Ben-Yaacov # timezone=$1 if [ -f /usr/share/zoneinfo/$timezone ]; then echo $timezone > /etc/timezone rm -f /etc/localtime && ln -sf /usr/share/zoneinfo/$timezone /etc/localtime fi whereami-0.3.34/scripts/setoops0000755000000000000000000000131210620241635013375 0ustar #!/bin/bash # This script was written Fedor Karpelevitch to reconfigure # the lightweight "oops" proxy server to use a different # upstream proxy, or to use no proxy at all. UPSTREAM="$@" CONFFILE=/etc/oops/oops.cfg if [ "$UPSTREAM" != "stop" ]; then echo "Setting upstream proxy host ($UPSTREAM)" if [ "$UPSTREAM" != "none" ]; then echo parent $UPSTREAM > $CONFFILE.N fi grep -v "^parent " $CONFFILE >> $CONFFILE.N mv $CONFFILE.N $CONFFILE # echo Reconfiguring oops... # /usr/sbin/oopsctl reconfigure # echo Oops reconfigured. echo Restarting oops /etc/init.d/oops restart echo Restarted oops else echo Stopping oops /etc/init.d/oops stop fi whereami-0.3.34/mail-relay.conf0000644000000000000000000000057510620241635013201 0ustar # Configuration file for setmailrelay of whereami # # # The DEFAULT_RELAY sets the fallback for the mailserver to relay through # #DEFAULT_RELAY=mail.myplace.org # # # The MAIL_SERVER chooses between sendmail, postfix and exim. If you omit # this the system will choose the one it first finds a configuration file # for, which is normally a safe approach. # #MAIL_SERVER=sendmail whereami-0.3.34/COPYING0000644000000000000000000004321710620241635011331 0ustar GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. $Id: COPYING,v 1.1.1.1 2001/02/19 18:29:31 andrew Exp $ whereami-0.3.34/VERSION0000644000000000000000000000001710620241635011335 0ustar whereami-0.0.2