Skip to content

Commit

Permalink
get JOURNAL_ID from repository.xml
Browse files Browse the repository at this point in the history
check if current_revision_id.dat exists
mv current_revision_id.dat away when done
  • Loading branch information
chregu committed May 5, 2011
1 parent 16632c1 commit 62b0784
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
16 changes: 16 additions & 0 deletions cloneRepo.sh
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion config.sh-dist
Expand Up @@ -5,6 +5,5 @@ MYSQLUSER="USER"
MYSQLPASS="PASS"
MYSQLHOST="localhost"
MYSQLDB="jackrabbit"
JRCLUSTERID="node_old"
JRCLUSTERID_NEW="node_new";
MYSQLBIN="mysql"
21 changes: 21 additions & 0 deletions getClusterId.xsl
@@ -0,0 +1,21 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output doctype-public="-//The Apache Software Foundation//DTD Jackrabbit 2.0//EN"
doctype-system="http://jackrabbit.apache.org/dtd/repository-2.0.dtd"
method="text"
/>


<xsl:param name="cluster_id" select="'foo'"/>
<xsl:template match="*">
<xsl:apply-templates />
</xsl:template>

<xsl:template match="text()">
</xsl:template>

<xsl:template match="/Repository/Cluster[1]"><xsl:value-of select="@id"/></xsl:template>



</xsl:stylesheet>
26 changes: 20 additions & 6 deletions startNewRepo.sh
Expand Up @@ -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

0 comments on commit 62b0784

Please sign in to comment.