From: Florent Bruneau Date: Tue, 12 Oct 2010 14:47:38 +0000 (+0200) Subject: New script to perform the upgrade of the site. X-Git-Tag: xorg/1.0.1~53 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=da501b1f1c06207daf29e70142eee8409869c9f7;p=platal.git 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 --- 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