#!/bin/bash # Change to the scripts directory so paths are correct cd "$(dirname "$0")"/.. # Do not download, only check validity of URL if [ "$1" == "--check-only" ]; then shift; SPIDER="--spider"; else SPIDER=""; fi # Default to ENU if nothing passed in as first arg if [ ".$1" == "." ]; then WINLANG="ENU"; else WINLANG="$1"; fi for cmdfile in `egrep -lri "URL\|($WINLANG|ALL)" scripts/$2`; do echo Processing $cmdfile # Look for URL|LANG in scripts/ + second arg for needed in `egrep -hri "URL\|($WINLANG|ALL)" $cmdfile | tr ' ' '~'`; do url=`echo -ne "$needed" | cut -d\| -f3 | tr '~' ' ' | perl -pe 's/[\r\n]//g;s/^ *//;s/ *$//'` file=`echo -ne "$needed" | cut -d\| -f4 | tr '~' ' ' | perl -pe 's/[\r\n]//g;s/^ *//;s/ *$//;s/([^\/]*\/*)$/lc($1)/eg'` path=`echo -ne "$file" | perl -pe 's#(.*/).*#$1#'` if [ ! "$SPIDER" == "" ]; then wget $SPIDER --passive-ftp "$url" ; continue fi # Make sure path is available mkdir -p "$path" # Download file if it doesn't exist if [ ! -f "$file" ] ; then if wget $SPIDER $WGET_OPS --passive-ftp -O "$file.$$.tmp" "$url" ; then mv "$file.$$.tmp" "$file" else rm -f "$file.$$.tmp" fi else touch "$file" fi done done