From 0a53346ecd92e1281587c724631fdf76dc756fc7 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Tue, 6 Feb 2018 17:07:30 +0100 Subject: Auto update SDK DB on startup. Auto update db is enable by default (setting sdkDbUpdate = "startup") but it can be disable by setting sdkDbUpdate to "disable" in server config file. Signed-off-by: Sebastien Douheret --- scripts/sdks/agl/db-update | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'scripts/sdks') diff --git a/scripts/sdks/agl/db-update b/scripts/sdks/agl/db-update index 68bd26a..7ebd928 100755 --- a/scripts/sdks/agl/db-update +++ b/scripts/sdks/agl/db-update @@ -23,6 +23,17 @@ sdksDBFile=${1} [ "${sdksDBFile}" = "" ] && sdksDBFile=${SDK_ROOT_DIR}/sdks_latest.json +# Restore previous file on error +exitCode=0 +trap "OnExit" 0 1 2 15 +OnExit () +{ + if [ "${exitCode}" != "0" ] && [ -f "${sdksDBFile}.old" ]; then + echo "Error detected, restore previous database version" + mv "${sdksDBFile}.old" "${sdksDBFile}" + fi +} + # Backup previous file [ -f "${sdksDBFile}" ] && mv "${sdksDBFile}" "${sdksDBFile}.old" @@ -31,4 +42,10 @@ instDir=$(dirname "${sdksDBFile}") [ ! -d "${instDir}" ] && mkdir -p "${instDir}" # Get database -wget -q --connect-timeout=30 "${SDK_DATABASE}" -O "${sdksDBFile}" +echo "Updating AGL SDK database..." +wget --no-verbose --connect-timeout=30 "${SDK_DATABASE}" -O "${sdksDBFile}" +exitCode=$? + +[ "${exitCode}" = "0" ] && echo "Done: AGL SDK database is up-to-date" + +exit $exitCode -- cgit 1.2.3-korg