]> git.deb.at Git - deb/packages.git/blob - bin/create_mirror
Merge branch 'archive-master' of git+ssh://git.debian.org/git/webwml/packages into...
[deb/packages.git] / bin / create_mirror
1 #!/bin/bash
2
3 set -e
4
5 topdir="$1"
6 [ -n "$topdir" -a -d "$topdir" ] || exit 1
7 mirror="$topdir/mirror"
8
9 mkdir -p "$mirror"
10
11 STAMP=$(date "+%Y%m%d%H%M")
12 new="$mirror/$STAMP"
13 mkdir $new
14
15 if lockfile -! -l 3600 -r2 -300 "$mirror/mirror.lock"
16 then
17     echo "couldn't aquire mirror.lock in due time"
18     exit 1;
19 fi
20
21 mkdir -p "$new/cache"
22 chmod 777 "$new/cache"
23
24 cd "$new"
25 ln -f "$topdir/config.sh"
26 ln -f "$topdir/README.Mirror"
27
28 mkdir -p "$new/bin"
29 cd "$new/bin"
30 ln -f "$topdir/bin/mod_perl-startup"
31
32 mkdir -p "$new/conf"
33 cd "$new/conf"
34 ln -f "$topdir/conf/apache.conf"
35
36 mkdir -p "$new/cgi-bin"
37 cd "$new/cgi-bin"
38 ln -f "$topdir/cgi-bin/dispatcher.pl"
39
40 for d in lib files templates po www
41 do
42   mkdir -p "$new/$d"
43   rsync -avH --link-dest "$topdir/$d" \
44       --exclude '*.new' --exclude '*.sed.in' \
45       --exclude '*.slices' --exclude '*~' \
46       --exclude '*.lock' --exclude '*.ttc' --exclude 'logs/' \
47       --exclude 'packages/*/' --exclude 'changelogs.*.dump' \
48       --exclude 'changelogs.cache' --exclude 'changelogs/**/log' \
49       --exclude "/auto" --exclude "/Search" --exclude "/perl" \
50       --delete-excluded --delete-after \
51       "$topdir/$d/" "$new/$d/"
52 done
53 LC_ALL=POSIX LANG=POSIX date -u > "$new/www/Pics/.trace"
54
55 ln -sfT $new $mirror/current
56 find $mirror -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 \
57         | xargs --no-run-if-empty -0 rm -rf
58
59 rm -f "$mirror/mirror.lock"