Alive -- A simple set of scripts for determining whether or not a host
is alive, and then intelligently mounting NFS shares.

Copyright (c) 1997 by Ryan Kirkpatrick (rkirkpat@nag.cs.colorado.edu). 
  All rights reserved.

* 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; see the file COPYING.  If not, write to the
  Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

There are three pieces to this program. 

* The alive program itself, a small C program that merely uses the
  echo service on the remote machine to determine if that remote
  machine is alive and reachable via TCP/IP. The echo service is used
  since it is a bit higher level than a simple ping, and if the echo
  service is running, that usually means that the remainder of the
  services are running.

* A bash shell script that uses the alive program and a given hostname
  to mount all of the shares for that hostname as pulled from
  /etc/fstab. If the host is unreachable, than it sets an 'at' job to
  rerun itself again at a ever growing time interval.

* A small blurb of bash shell script code to be placed in the rc.local
  startup file. It executes the above mentioned shell script for each
  host listed in /etc/fstab.

To compile the program.

* Edit Makefile and ClientLib/Makefile to suit your needs. One option
  you will probably want to set is the WAIT_TIME variable in the
  toplevel Makefile. This sets how long the alive program waits for a
  remote host to respond before giving up. The default of one second
  is fine for a medium to small LAN. If you are working with Internet
  hosts you may want to set it as high as a minute or two, or more.

* Type 'make' in the toplevel directory. The program alive will be
  built.

* Test alive if you wish by using it to see if different hosts are
  alive. One good test is 'alive localhost'. :)

To install the program.

* Since different people keep things in different places, you get to
  install the program and scripts by hand.

* The hardcoded paths are that alive and AliveMount.sh are located in
  /usr/sbin/, and the rc.local.addin script blurb is added to
  /etc/rc.d/rc.local, or whatever is equivalent for your system.

* To change the paths, just replace /usr/sbin/ with what ever you need
  in AliveMount.sh and rc.local.addin and you are set to go.

* Lastly you may want to put 'noauto' as an option for your nfs mounts
  in /etc/fstab. That way the system will not automatically mount them
  for you on boot up, and let AliveMount.sh do it instead.

To use the program

* Set up the NFS shares you want mounted with the desired options and
  mount points in /etc/fstab.

* Then when the system boots, the machine the nfs mount is being made
  off of is checked to see if it is alive before the nfs mount is
  mounted.

* If it is not, then AliveMount.sh sets it self to run again in two
  minutes, and if that fails, it waits four minutes to run, and so
  forth.

Why I wrote this

I have four Linux boxes that go up and down now and then in no
particular order for maintenance or upgrades. I have nfs mounts between
many of them, making mounting those nfs mounts on boot up difficult to
sequence correctly. It is even worse when I bring up all of the boxes
at once, say after the power has failed. This set of scripts keeps the
systems from locking up on boot because the other machines are taking
longer to boot and are not yet ready to serve nfs mount requests.

Also I suggest the following options for any nfs mounts. 
  * 'bg', so if the mount goes away for any reason, the system will
    not bug you about it. 
  * 'soft', so if the mount goes away for any reason, the system will
    not go crazy, and become obsessed with not being able to reach the
    remote system.
  * 'rsize=8192,wsize=8192', sets the read and write block sizes to
    something much more reasonable, increasing throughput off what the
    defaults give you by two to three times!

It is also possible to use the alive program for other purposes as
well. It is a very basic little program. It takes a single command
line parameter, a host name. It then sends an echo packet to that
remote host, waits a time defined at compile time, and if there has
been no response it prints 'Dead' on the STDOUT. Otherwise it prints
'Alive' on the STDOUT.

One last thing, the ClientLib source code come from a book called
"Internetworking with TCP/IP" by Douglas E. Comer and David
L. Stevens, ISBN 0-13-474222-2. It it quite simple and I didn't see
much point in rewriting it for this simple program. As well, there
were no obvious copyrights on the code saying I couldn't use it. Also,
I suggest this book for any one interested in writing TCP/IP
applications for Linux. It is perfect for anyone who doesn't want to
dive too deeply into the fundamentals of TCP/IP and the TCP/IP
stack. Instead it tells you enough to get you started writing TCP/IP
applications in a relatively short measure. I highly recommend it.

If you have any questions or comments about this program or scripts,
feel free to email me at rkirkpat@nag.cs.colorado.edu.

----------------------------------------------------------------------------
|   "For to me to live is Christ, and to die is gain."                     |
|                                            --- Philippians 1:21 (KJV)    |
----------------------------------------------------------------------------
|  Ryan Kirkpatrick  |  Boulder, Colorado  | rkirkpat@nag.cs.colorado.edu  |
----------------------------------------------------------------------------
|               http://www-ugrad.cs.colorado.edu/~rkirkpat/                |
----------------------------------------------------------------------------

