4 echo "Please configure me!"
6 # This script originates from http://www.debian.org/mirror/anonftpsync
7 # modified by Martin Zobel-Helas <zobel@debian.org>, 2005-01-16
8 # these modifications are published under the terms of the GNU GPL
10 # + some more documentation about variables
11 # + added ARCH_EXCLUDE
12 # + mirror in a safe way, first /pool, then /dists and the rest
14 # Version: $Id: anonftpsync,v 1.19 2005/11/30 14:14:03 jfs Exp $
17 # Note: You MUST have rsync 2.0.16-1 or newer, which is available in slink
18 # and all newer Debian releases, or at http://rsync.samba.org/
20 # Set the variables below to fit your site. You can then use cron to have
21 # this script run daily to automatically update your copy of the archive.
24 # chmod 744 anonftpsync
26 # TO is the destination for the base of the Debian mirror directory
27 # (the dir that holds dists/ and ls-lR).
32 # RSYNC_HOST is the site you have chosen from the mirrors file.
33 # (http://www.debian.org/mirror/list-full)
36 RSYNC_HOST=deb.grml.org
38 # RSYNC_DIR is the directory given in the "Packages over rsync:" line of
39 # the mirrors file for the site you have chosen to mirror.
44 # LOGDIR is the directory where the logs will be written to
49 # ARCH_EXCLUDE can be used to exclude a complete architecture from
50 # mirrorring. Please use as space seperated list.
51 # Possible values are:
52 # alpha, amd64, arm, hppa, hurd-i386, i386, ia64, m68k, mipsel, mips, powerpc, s390, sh and sparc
54 # There is one special value: source
55 # This is not an architecture but will exclude all source code in /pool
58 # ARCH_EXCLUDE="alpha arm hppa hurd-i386 ia64 m68k mipsel mips s390 sparc"
60 # With a blank ARCH_EXCLUDE you will mirror all available architectures
65 # EXCLUDE is a list of parameters listing patterns that rsync will exclude.
66 # The following example would exclude mostly everything:
68 # --exclude binary-alpha/ --exclude binary-arm/ --exclude binary-i386/ \
69 # --exclude binary-m68k/ --exclude binary-powerpc/ --exclude binary-sparc/ \
70 # --exclude binary-ia64/ --exclude binary-mips*/ --exclude binary-hppa/ \
71 # --exclude binary-sh/ --exclude binary-s390/ \
72 # --exclude binary-hurd-i386/ \
73 # --exclude *_alpha.deb --exclude *_arm.deb --exclude *_i386.deb \
74 # --exclude *_m68k.deb --exclude *_powerpc.deb --exclude *_sparc.deb \
75 # --exclude *_ia64.deb --exclude *_hppa.deb --exclude *_sh.deb \
76 # --exclude *_mips.deb --exclude *_mipsel.deb --exclude *_s390.deb \
77 # --exclude *_hurd-i386.deb \
78 # --exclude disks-alpha/ --exclude disks-arm/ --exclude disks-i386/ \
79 # --exclude disks-ia64/ --exclude disks-m68k/ --exclude disks-mips*/ \
80 # --exclude disks-powerpc/ --exclude disks-s390/ --exclude disks-sparc/ \
81 # --exclude stable/ --exclude testing/ --exclude unstable/ \
83 # --exclude *.orig.tar.gz --exclude *.diff.gz --exclude *.dsc \
84 # --exclude /contrib/ --exclude /non-free/ \
87 # With a blank EXCLUDE you will mirror the entire archive.
92 # MAILTO is the address to send logfiles to;
93 # if it is not defined, no mail will be sent
98 # There should be no need to edit anything below this point, unless there
101 #-----------------------------------------------------------------------------#
103 # Check for some environment variables
104 if [ -z $TO ] || [ -z $RSYNC_HOST ] || [ -z $RSYNC_DIR ] || [ -z $LOGDIR ]; then
105 echo "One of the following variables seems to be empty:"
106 echo "TO, RSYNC_HOST, RSYNC_DIR or LOGDIR"
110 # Note: on some non-Debian systems, hostname doesn't accept -f option.
111 # If that's the case on your system, make sure hostname prints the full
112 # hostname, and remove the -f option. If there's no hostname command,
113 # explicitly replace `hostname -f` with the hostname.
114 HOSTNAME=`hostname -f`
116 LOCK="${TO}/Archive-Update-in-Progress-${HOSTNAME}"
118 # Exclude architectures defined in $ARCH_EXCLUDE
119 for ARCH in $ARCH_EXCLUDE; do
121 --exclude binary-$ARCH/ \
122 --exclude disks-$ARCH/ \
123 --exclude installer-$ARCH/ \
124 --exclude Contents-$ARCH.gz \
125 --exclude *_$ARCH.deb \
126 --exclude *_$ARCH.udeb "
127 if [ "$ARCH" == "source" ]; then
130 --exclude *.diff.gz \
136 LOGFILE=$LOGDIR/deb.grml.org.log
138 # Get in the right directory and set the umask to be group writable
143 # Check to see if another sync is in progress
144 if lockfile -! -l 43200 -r 0 "$LOCK"; then
145 echo ${HOSTNAME} is unable to start rsync, lock file exists
148 # Note: on some non-Debian systems, trap doesn't accept "exit" as signal
149 # specification. If that's the case on your system, try using "0".
150 trap "rm -f $LOCK > /dev/null 2>&1" exit
155 rsync --recursive --links --hard-links --times --verbose --delete --timeout=600\
156 $EXCLUDE $SOURCE_EXCLUDE \
157 $RSYNC_HOST::$RSYNC_DIR/pool/ $TO/pool/ >> $LOGFILE 2>&1
160 if [ 0 = $result ]; then
161 # Now sync the remaining stuff
162 rsync --recursive --links --hard-links --times --verbose --delete-after --delay-updates \
163 --exclude "Archive-Update-in-Progress-${HOSTNAME}" \
164 --exclude "sync-${HOSTNAME}" \
167 $RSYNC_HOST::$RSYNC_DIR $TO >> $LOGFILE 2>&1
169 date -u > "${TO}/sync-${HOSTNAME}"
171 echo "ERROR: Help, something weird happened" | tee -a $LOGFILE
172 echo "mirroring /pool exited with exitcode" $result | tee -a $LOGFILE
176 if ! [ -z $MAILTO ]; then
177 mail -s "grml archive synced" $MAILTO < $LOGFILE