From: Mark Wooding Date: Thu, 28 Aug 2014 14:56:15 +0000 (+0100) Subject: etc/post-mirror.d/worldofspectrum: Maintain an unzipped tree in parallel. X-Git-Url: https://git.distorted.org.uk/~mdw/mirror-admin/commitdiff_plain/bd667e3896e93612bc50b2241403e2fe50869fa3 etc/post-mirror.d/worldofspectrum: Maintain an unzipped tree in parallel. --- diff --git a/etc/post-mirror.d/worldofspectrum b/etc/post-mirror.d/worldofspectrum new file mode 100755 index 0000000..3531f98 --- /dev/null +++ b/etc/post-mirror.d/worldofspectrum @@ -0,0 +1,20 @@ +#! /bin/sh -e + +## Unpack all of the zip files. +wos=$MIRRORS/worldofspectrum +from=$wos/games to=$wos/games.unpack +(cd "$from" && find . -name \*.zip -print) | +while read i; do + case $i in ../* | */../*) continue ;; esac + path=${i%.zip}; dir=${path%/*} base=${path##*/} + if [ -e "$to/$path/.stamp" ] && + [ ! "$from/$i" -nt "$to/$path/.stamp" ]; then + continue + fi + rm -rf "$to/%tmp" "$to/$path" + mkdir -p "$to/%tmp/$base" + (cd "$to/%tmp/$base" && unzip "$from/$i") + touch -r"$from/$i" "$to/%tmp/$base/.stamp" + mv "$to/%tmp/$base" "$to/$dir/" + rmdir "$to/%tmp" +done