aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/sdks
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-02-06 17:07:30 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-02-06 17:11:30 +0100
commit0a53346ecd92e1281587c724631fdf76dc756fc7 (patch)
treedd9996613a7f4237fd996be9a54949369cd064f4 /scripts/sdks
parent60a59bcfdb3c2404a468cc314b7afde85ee35e1b (diff)
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 <sebastien.douheret@iot.bzh>
Diffstat (limited to 'scripts/sdks')
-rwxr-xr-xscripts/sdks/agl/db-update19
1 files changed, 18 insertions, 1 deletions
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