#!/bin/bash # $HeadURL$ $LastChangedRevision$ echo "configuring environment ..." export RDW2_ETC_PREFIX=$(pwd)/etc MAX_SCHEMA=6 echo "initialising server ..." mkdir -p etc var echo 'rdw2_server_flag = True' > etc/rdw2.py echo "feeding rdw2 an too old database ..." export RDW2_DB_FILE=/tmp/old.sqlite sqlite3 $RDW2_DB_FILE 'PRAGMA user_version=0;' 2> /dev/null rdw2 --list-sets || true echo "feeding rdw2 an too new database ..." export RDW2_DB_FILE=/tmp/new.sqlite sqlite3 $RDW2_DB_FILE 'PRAGMA user_version=999;' 2> /dev/null rdw2 --list-sets || true export RDW2_DB_FILE=$(pwd)/var/rdw2.sqlite for OLD_VERSION in $(seq 0 $MAX_SCHEMA); do echo "telling rdw2 to upgrade from version $OLD_VERSION ..." if [ $OLD_VERSION = 0 ]; then # There never was a version 0 (the very first version of rdw2 # already used user_version). So we need to fake it. sqlite3 $RDW2_DB_FILE 'PRAGMA user_version=0;' 2> /dev/null else sqlite3 $RDW2_DB_FILE < $(rdw2-config rdw2_share_prefix)/sql/rdw2-$OLD_VERSION.sql fi # Variant text stripped. rdw2 -v --upgrade 2>&1 | grep -v "backing up database to" # Ensure loop reentrant. rm -f $RDW2_DB_FILE done echo "all done"