From ea69f9087fe4501159e11f0801fca964a2abd55f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 16 Mar 2022 13:32:37 -0700 Subject: [PATCH] Adds missing update script --- update.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 update.sh diff --git a/update.sh b/update.sh new file mode 100755 index 000000000..a394eed81 --- /dev/null +++ b/update.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e + +# determine inital and target versions +initial_version="`./bw-dev runweb python manage.py instance_version --current`" +target_version="`./bw-dev runweb python manage.py instance_version --target`" + +initial_version="`echo $initial_version | tail -n 1 | xargs`" +target_version="`echo $target_version | tail -n 1 | xargs`" +if [[ "$initial_version" = "$target_version" ]]; then + echo "Already up to date; version $initial_version" + exit +fi + +echo "---------------------------------------" +echo "Updating from version: $initial_version" +echo ".......... to version: $target_version" +echo "---------------------------------------" + +function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; } + +# execute scripts between initial and target +for version in `ls -A updates/ | sort -V `; do + if version_gt $initial_version $version; then + # too early + continue + fi + if version_gt $version $target_version; then + # too late + continue + fi + echo "Running tasks for version $version" + ./updates/$version +done + +./bw-dev runweb python manage.py instance_version --update +echo "✨ ----------- Done! --------------- ✨"