chiark / gitweb /
etc/post-mirror.d/worldofspectrum: Maintain an unzipped tree in parallel.
[mirror-admin] / etc / post-mirror.d / worldofspectrum
1 #! /bin/sh -e
2
3 ## Unpack all of the zip files.
4 wos=$MIRRORS/worldofspectrum
5 from=$wos/games to=$wos/games.unpack
6 (cd "$from" && find . -name \*.zip -print) |
7 while read i; do
8   case $i in ../* | */../*) continue ;; esac
9   path=${i%.zip}; dir=${path%/*} base=${path##*/}
10   if [ -e "$to/$path/.stamp" ] &&
11      [ !  "$from/$i" -nt "$to/$path/.stamp" ]; then
12     continue
13   fi
14   rm -rf "$to/%tmp" "$to/$path"
15   mkdir -p "$to/%tmp/$base"
16   (cd "$to/%tmp/$base" && unzip "$from/$i")
17   touch -r"$from/$i" "$to/%tmp/$base/.stamp"
18   mv "$to/%tmp/$base" "$to/$dir/"
19   rmdir "$to/%tmp"
20 done