#!/bin/bash set -e topdir="$1" [ -n "$topdir" -a -d "$topdir" ] || exit 1 mirror="$topdir/mirror" mkdir -p "$mirror" STAMP=$(date "+%Y%m%d%H%M") new="$mirror/$STAMP" mkdir $new if lockfile -! -l 3600 -r2 -300 "$mirror/mirror.lock" then echo "couldn't aquire mirror.lock in due time" exit 1; fi mkdir -p "$new/cache" chmod 777 "$new/cache" cd "$new" ln -f "$topdir/config.sh" ln -f "$topdir/README.Mirror" mkdir -p "$new/bin" cd "$new/bin" ln -f "$topdir/bin/mod_perl-startup" mkdir -p "$new/conf" cd "$new/conf" ln -f "$topdir/conf/apache.conf" mkdir -p "$new/cgi-bin" cd "$new/cgi-bin" ln -f "$topdir/cgi-bin/dispatcher.pl" for d in lib files templates po www do mkdir -p "$new/$d" rsync -avH --link-dest "$topdir/$d" \ --exclude '*.new' --exclude '*.sed.in' \ --exclude '*.slices' --exclude '*~' \ --exclude '*.lock' --exclude '*.ttc' --exclude 'logs/' \ --exclude 'packages/*/' --exclude 'changelogs.*.dump' \ --exclude 'changelogs.cache' --exclude 'changelogs/**/log' \ --exclude "/auto" --exclude "/Search" --exclude "/perl" \ --delete-excluded --delete-after \ "$topdir/$d/" "$new/$d/" done LC_ALL=POSIX LANG=POSIX date -u > "$new/www/Pics/.trace" ln -sfT $new $mirror/current find $mirror -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 \ | xargs --no-run-if-empty -0 rm -rf rm -f "$mirror/mirror.lock"