Secondary Installation Scripts

Previous: rsyncpasswd.html Next: ummmm

We need to copy our secondary install script to each host(slave) in turn, and then run it on them.

Copying Script to Each Node

Granted we could have scripts to do all this for us, and we do indeed have a nice collection of existing scripts, but sometimes for the flexibility advantage it is just easier to use the command line and go with it.

	for node in `cut -d' ' -f 2 /root/hostsup`; do scp pvm2.config $node:; echo $node; echo;  done

That will copy the file "pvm2.config" (provided it exists in the current working directory) to the $HOME directory of the user executing the command. That user should be root, since we want to run the installation script as root as well. It also assumes it will find the hostsup file in /root. If that is not true then you need to adjust appropriately.

Pretty printed it would look like:

#!/bin/sh

for node in `cut -d' ' -f 2 /root/hostsup`
do
  scp pvm2.config $node:
  echo $node
  echo
done

If that makes it any easier to understand... Feel free to snip it out of this document and add some variables in place of "pvm2.config" and "" (the empty space after the ":", to make a general script out of it. I can't be bothered too myself. It is just as easy to recall it from bash's history mechanism when I need it with "ctrl-r".

Even better would be to replace the "scp pvm2.config $node:" with something like "$@":

Such as:

#!/bin/sh
# Peter Jordan 2001-11-01 pjordan@blackwire.com
# use as "scp blat.sh \$node:" for example

if [ -z $HOSTNAMES ]; then
  HOSTNAMES=`cut -d' ' -f2 /root/hostsup`
fi

for foo in $HOSTNAMES
do
  eval "$@"
done

Which makes for a very generic "distributed shell" script, but it is fraught with nasty little bug-a-boos and I recommend you still use the command line. The last script above is found as "test.sh" in the script collection.

Running the Script on each Node:

Here we will use the script "aptall.sh" from the script collection to run the secondary script.

	bin/aptall.sh sh /root/pvm2.config

is the command line to use. aptall.sh is similar to the scripts given above but it uses ssh explicitly, and it also sets up the path which would otherwise be unset causing many things in our pvm2.config script to fail. Note that we also need to give the PATH explicitly for the location of pvm2.config, and run it using "sh".

Upon executing that command you will get tons of debugging output on the screen all mixed in together due to the "-f" option that aptall.sh passes to ssh. It would be better to modify this script to capture the output from each machine into a seperate file for later error handling. Perhaps giving a "passed" or "failed" status line of output for each machine on stdout.