So I've checked around the 'net and wan't able to find anything
        that great for mirroring packages between a master/slave
        machine, so I wrote my own small script below.  Comments?

        - Paul


#! /bin/bash ## # mirror-dpkg: mirror Debian packages from a master computer to a slave # 0.9 # # Paul J. Lucas ##

RCP="scp -q"
RSH="ssh -q"

########## You shouldn't have to change anything below this line. #############

alert() {
    echo "$ME: $1" >&2
    exit 1
}

usage() {
    echo "usage: $ME [slave_hostname]" >&2
    exit 1
}

########## Main ###############################################################

ME=$(basename $0)

(( $# > 1 )) && usage

PID_FILE=/var/run/$ME.pid
[ -f $PID_FILE ] && alert "Already runnning."
echo $$ > $PID_FILE

DPKG_SEL_FILE=/tmp/$ME.dpkg_sel
SLAVE_PID=/tmp/$ME.slave_pid

trap 'x=$?; rm -f $PID_FILE /tmp/$ME.*; exit $x' EXIT HUP INT TERM

case $# in

1)  SLAVE=$1
    # See if the slave is running by trying to copy its PID file here.
    $RCP $SLAVE:$PID_FILE $SLAVE_PID 2>/dev/null &&
        alert "Slave is apparently already running."

    # Copy master package list to slave.
    dpkg --get-selections \* > $DPKG_SEL_FILE
    $RCP $DPKG_SEL_FILE $SLAVE:$DPKG_SEL_FILE

    # Tell the slave to update.
    $RSH $SLAVE $ME
    ;;

0)  dpkg --set-selections < $DPKG_SEL_FILE >/dev/null 2>&1
    apt-get -q=2 dselect-upgrade
    ;;

esac

# vim:set et sw=4 ts=4:


-- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Reply via email to