diff options
author | Jochen Topf <jochen@topf.org> | 2014-09-18 11:40:49 +0200 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2014-09-18 11:40:49 +0200 |
commit | 5475214823e7a9deaa7925bb0054c22b233658d1 (patch) | |
tree | 38bd727d80b42509c3b5c6aed9828931b47c8dff | |
parent | 29cf83f2a8a3a137867b5ed523b75be192aa92ad (diff) | |
download | taginfo-5475214823e7a9deaa7925bb0054c22b233658d1.tar taginfo-5475214823e7a9deaa7925bb0054c22b233658d1.tar.gz |
Make update more robust.
-rwxr-xr-x | sources/languages/update.sh | 25 | ||||
-rwxr-xr-x | sources/update_all.sh | 2 |
2 files changed, 22 insertions, 5 deletions
diff --git a/sources/languages/update.sh b/sources/languages/update.sh index adcd965..33f8cab 100755 --- a/sources/languages/update.sh +++ b/sources/languages/update.sh @@ -20,6 +20,23 @@ PROPERTY_ALIASES_FILE="$DIR/PropertyValueAliases.txt" DATECMD='date +%Y-%m-%dT%H:%M:%S' +update_file() { + file=$1 + url=$2 + + if curl --silent --fail --location --time-cond $file --output $file $url; then + return 0 + else + error=$? + if [ "$error" = "22" ]; then + echo "WARNING: Getting ${url} failed. Using old version." + else + echo "ERROR: Could not get ${url}: curl error: $error" + exit 1 + fi + fi +} + if [ "x" = "x$DIR" ]; then echo "Usage: update.sh DIR" exit 1 @@ -44,13 +61,13 @@ echo "`$DATECMD` Running pre.sql..." sqlite3 $DATABASE <pre.sql echo "`$DATECMD` Getting subtag registry..." -curl --silent --time-cond $REGISTRY_FILE --output $REGISTRY_FILE $REGISTRY_URL +update_file $REGISTRY_FILE $REGISTRY_URL echo "`$DATECMD` Running subtag import..." $EXEC_RUBY ./import_subtag_registry.rb $DIR echo "`$DATECMD` Getting CLDR..." -curl --silent --location --time-cond $CLDR_FILE --output $CLDR_FILE $CLDR_URL +update_file $CLDR_FILE $CLDR_URL echo "`$DATECMD` Unpacking CLDR..." rm -fr $CLDR_DIR @@ -58,8 +75,8 @@ mkdir $CLDR_DIR unzip -q -d $CLDR_DIR $CLDR_FILE echo "`$DATECMD` Getting unicode scripts..." -curl --silent --location --time-cond $UNICODE_SCRIPTS_FILE --output $UNICODE_SCRIPTS_FILE $UNICODE_SCRIPTS_URL -curl --silent --location --time-cond $PROPERTY_ALIASES_FILE --output $PROPERTY_ALIASES_FILE $PROPERTY_ALIASES_URL +update_file $UNICODE_SCRIPTS_FILE $UNICODE_SCRIPTS_URL +update_file $PROPERTY_ALIASES_FILE $PROPERTY_ALIASES_URL echo "`$DATECMD` Running unicode scripts import..." $EXEC_RUBY ./import_unicode_scripts.rb $DIR diff --git a/sources/update_all.sh b/sources/update_all.sh index 2b01dcc..dfe31c6 100755 --- a/sources/update_all.sh +++ b/sources/update_all.sh @@ -50,7 +50,7 @@ for source in $SOURCES_DOWNLOAD; do echo "=====================================" echo "Downloading $source..." mkdir -p $DIR/$source - curl --silent --output $DIR/download/taginfo-$source.db.bz2 http://taginfo.openstreetmap.org/download/taginfo-$source.db.bz2 + curl --silent --fail --output $DIR/download/taginfo-$source.db.bz2 http://taginfo.openstreetmap.org/download/taginfo-$source.db.bz2 bzcat $DIR/download/taginfo-$source.db.bz2 >$DIR/$source/taginfo-$source.db echo "Done." done |