From da501b1f1c06207daf29e70142eee8409869c9f7 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Tue, 12 Oct 2010 16:47:38 +0200 Subject: [PATCH] New script to perform the upgrade of the site. Instead of calling: % cd upgrade/{version}/ % ./update.sh The migration of the db can be done through: % upgrade/update.sh The script will automatically discover the version of the upgrade scripts to be run. Note: my goal is to build a script that can be used to perform most of the steps of the migration, not only the upgrade of the db and, if possible, that can detect the needed upgrades (let say "what must I do to upgrade this site that ran platal 0.10.1 to platal 1.0.1"). Feel free to improve this script. Signed-off-by: Florent Bruneau --- upgrade/update.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 upgrade/update.sh diff --git a/upgrade/update.sh b/upgrade/update.sh new file mode 100755 index 0000000..4036c76 --- /dev/null +++ b/upgrade/update.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +spoolroot="$(readlink -f $(dirname $0)/..)" +dbversionfile="$spoolroot/spool/tmp/db_version" + +currentversion="$(grep 'VERSION' $spoolroot/ChangeLog | cut -d ' ' -f 2 | head -n 1)" +previousversion="$(cat $dbversionfile 2> /dev/null)" + +function die() { + echo "$1" 1>&2 + exit 1 +} + +if [ "$currentversion" != "$previousversion" ]; then + cd $spoolroot/upgrade/$currentversion/ + ./update.sh "$@" || die "Upgrade to $currentversion failed" + echo "$currentversion" > $dbversionfile +else + echo "Already at version $currentversion" +fi -- 2.1.4