Albers, Lucas said on Mon, May 03, 2004 at 11:26:20AM -0600:
> I just use a ssh script to connect to all the machines and force the update
> as necessary.

That's fine too.  You may want to check out infrastructure.org; they have a
good whitepaper about this kind of setup.

> What exactly does cvsup do?

I keep per-host configs in a CVS repository.  cvsup does the checkout and
network xfer portion, and can run commands after a file has been checked out.
So, if I make a change to httpd.conf, I check it in, and then cvsup worries
about restarting apache.

> Could you perhaps post your script?

Attached.  Warning: it's not documented at all, but it might give you some
ideas.

M
#! /bin/bash
#
# This script updates a client to be match the master image.
# It should be run out of cron every 20 minutes.

# set -x

me=$(basename $0)
naptime=0
do_config=yes
do_rsync=yes

export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export HOME=/root

pushd / > /dev/null

die()
{
        echo $@ 1>&2
        exit 1
}

usage()
{
  cat <<EOF
Usage: ${me} [OPTIONS]
Options:
  [--config-only]
  [--random-sleep]
EOF
} 

while test $# -gt 0; do
  case "$1" in
    -*=*) optarg=$(echo "$1" | sed 's/[-_a-zA-Z0-9]*=//') ;;
    *) optarg= ;;
  esac

  case "$1" in
    --config-only) do_rsync=no ;;
    --random-sleep) naptime=$(expr $RANDOM % 3600) ;;
    --help) usage && exit ;;
  esac
  shift
done

# We sleep up to 1 hour here so as to not overwhelm the systemimager
# and cvsup servers with requests, since our clocks are synced.
sleep $naptime

if test "$do_rsync" = yes; then
  pushd /etc/systemimager > /dev/null
  cat updateclient.master.exclude updateclient.exclude > \
    updateclient.local.exclude.tmp || die "Unable to write exclude file!"
        mv updateclient.local.exclude.tmp updateclient.local.exclude \
                || die "Unable to move generated exclude file!"
  popd > /dev/null
  updateclient --server=systemimager --image=sys \
    > /var/log/systemupdater.log 2>&1 || die "updateclient failed!"
fi

if test "$do_config" = yes; then
  supfile=$(mktemp) || exit 1
  cat /etc/cvsup/supfile >> $supfile
  dnsdomainname --fqdn >> $supfile
  cvsup -e -g -l /var/lock/cvsup.lock -L 1 $supfile >> \
                /var/log/systemupdater.log || die "cvsup failed!"
  rm $supfile
fi
popd > /dev/null

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to