From 62b07845181b548e3bef6ef8f1cb15a4d73bbef9 Mon Sep 17 00:00:00 2001 From: Christian Stocker Date: Thu, 5 May 2011 14:11:41 +0200 Subject: [PATCH] get JOURNAL_ID from repository.xml check if current_revision_id.dat exists mv current_revision_id.dat away when done --- cloneRepo.sh | 16 ++++++++++++++++ config.sh-dist | 1 - getClusterId.xsl | 21 +++++++++++++++++++++ startNewRepo.sh | 26 ++++++++++++++++++++------ 4 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 getClusterId.xsl diff --git a/cloneRepo.sh b/cloneRepo.sh index bc1c266..2206b33 100644 --- a/cloneRepo.sh +++ b/cloneRepo.sh @@ -16,8 +16,24 @@ echo "."; echo "Jackrabbit is down" echo "Copy the whole repository location with rsync"; rsync -avr $REPOLOCATION/ $REPOLOCATION.bkup + +echo "Get JOURNAL_ID" + +JRCLUSTERID=`xsltproc $SCRIPTPATH/getClusterId.xsl $REPOLOCATION.bkup/repository.xml` + +echo "Found JOURNAL_ID: $JRCLUSTERID" + echo "Get LOCAL_REVISION ID from mysql" ID=`$MYSQLBIN -u $MYSQLUSER -h $MYSQLHOST -p$MYSQLPASS $MYSQLDB --silent -N -e "select REVISION_ID from JOURNAL_LOCAL_REVISIONS where JOURNAL_ID = '$JRCLUSTERID'"` +if [[ -z $ID ]] +then + echo "****" + echo "No revision id for '$JRCLUSTERID' found. Please make sure this is in the database" + echo "We stop here and start Jackrabbit again"; + echo "****" + $JRSTART & + exit 1; +fi echo "It's $ID, write this to $REPOLOCATION.bkup/current_revision_id.dat" echo $ID > $REPOLOCATION.bkup/current_revision_id.dat echo "Adjust clusterconfig of $REPOLOCATION.bkup/repository.xml" diff --git a/config.sh-dist b/config.sh-dist index e2ae72e..abe7d59 100644 --- a/config.sh-dist +++ b/config.sh-dist @@ -5,6 +5,5 @@ MYSQLUSER="USER" MYSQLPASS="PASS" MYSQLHOST="localhost" MYSQLDB="jackrabbit" -JRCLUSTERID="node_old" JRCLUSTERID_NEW="node_new"; MYSQLBIN="mysql" diff --git a/getClusterId.xsl b/getClusterId.xsl new file mode 100644 index 0000000..733625f --- /dev/null +++ b/getClusterId.xsl @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + diff --git a/startNewRepo.sh b/startNewRepo.sh index f3abdc1..14cace7 100644 --- a/startNewRepo.sh +++ b/startNewRepo.sh @@ -4,23 +4,37 @@ SCRIPTPATH=`dirname $0`; . $SCRIPTPATH/config.sh + +if [[ ! -f $REPOLOCATION/current_revision_id.dat ]] +then +echo "!!!!!!" +echo "$REPOLOCATION/current_revision_id.dat does not exist, can't proceed" +echo "!!!!!!" +exit 2 +fi + + ID=`cat $REPOLOCATION/current_revision_id.dat` -echo "Check if cluster ID $JRCLUSTERID already exists" -CLUSTERIDCHECK=`$MYSQLBIN -u $MYSQLUSER -h $MYSQLHOST -p$MYSQLPASS $MYSQLDB --silent -N -e "select REVISION_ID from JOURNAL_LOCAL_REVISIONS where JOURNAL_ID = '$JRCLUSTERID'"` +echo "Check if JOURNAL_ID $JRCLUSTERID_NEW already exists" +CLUSTERIDCHECK=`$MYSQLBIN -u $MYSQLUSER -h $MYSQLHOST -p$MYSQLPASS $MYSQLDB --silent -N -e "select REVISION_ID from JOURNAL_LOCAL_REVISIONS where JOURNAL_ID = '$JRCLUSTERID_NEW'"` if [[ -z $CLUSTERIDCHECK ]] then -echo "It exists, update REVISION_ID to $ID" -$MYSQLBIN -u $MYSQLUSER -h $MYSQLHOST -p$MYSQLPASS $MYSQLDB --silent -N -e "UPDATE JOURNAL_LOCAL_REVISIONS SET REVISION_ID = $ID where JOURNAL_ID = '$JRCLUSTERID_NEW';" -else -echo "It does not exist, insert it and put REVISION to $ID" +echo "It does not exist, insert it and put REVISION_ID to $ID" $MYSQLBIN -u $MYSQLUSER -h $MYSQLHOST -p$MYSQLPASS $MYSQLDB --silent -N -e "INSERT INTO JOURNAL_LOCAL_REVISIONS (REVISION_ID, JOURNAL_ID) VALUES($ID, '$JRCLUSTERID_NEW');" +else +echo "It exists, update REVISION_ID to $ID" +$MYSQLBIN -u $MYSQLUSER -h $MYSQLHOST -p$MYSQLPASS $MYSQLDB --silent -N -e "UPDATE JOURNAL_LOCAL_REVISIONS SET REVISION_ID = $ID where JOURNAL_ID = '$JRCLUSTERID_NEW';" fi echo "Adjust clusterconfig of $REPOLOCATION/repository.xml (again, just to be sure)" xsltproc --nonet --param cluster_id "'$JRCLUSTERID_NEW'" $SCRIPTPATH/changeClusterId.xsl $REPOLOCATION/repository.xml > $REPOLOCATION/repository.xml.new 2> /dev/null mv $REPOLOCATION/repository.xml.new $REPOLOCATION/repository.xml + +echo "Move $REPOLOCATION/current_revision_id.dat away" +mv $REPOLOCATION/current_revision_id.dat $REPOLOCATION/current_revision_id.dat.old echo "Start Jackrabbit" + $JRSTART