forked from kitodo/kitodo-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
based on description kitodo/kitodo-production#3396
- Loading branch information
Stefan von der Heide
committed
Jun 26, 2020
1 parent
1581153
commit db8d847
Showing
12 changed files
with
699 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
ccs/scripts-for-minor-3.x-update/howToUseTheUpdateScripts.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
The update scripts provided here help to perform minor updates on Kitodo 3.* | ||
according to https://github.com/kitodo/kitodo-production/issues/3396. | ||
The scripts support (nearly) each step described there, plus some additional (optional) parts. | ||
|
||
Preconditions: | ||
- Have available new version of modules jars in form of "modules.zip" | ||
- Have available new WAR file | ||
- Have available SQL-Script with updates to be performed in the database | ||
|
||
Steps to follow: | ||
1) saveConfigBeforeMinorUpdate | ||
2) optional: saveMessagesBeforeMinorUpdate | ||
3) saveModulesBeforeMinorUpdate | ||
4) saveWARBeforeMinorUpdate | ||
5) optional: saveDatabaseBeforeMinorUpdate | ||
6) performDatabaseUpdateAsPartOfMinorUpdate | ||
7) Optional: Delete Elastic Search Index according to description on GitHub | ||
I never have done this at this point of time, but made it via the Kitodo User-Interface (step 13), after everything was installed | ||
8) installModulesAsPartOfMinorUpdate | ||
9) installMessagesAsPartOfMinorUpdate | ||
10) installWARAsPartOfMinorUpdate | ||
11) restoreConfigAfterMinorUpdate | ||
12) start tomcat8 | ||
13) login to Kitodo and delete&re-create Index | ||
|
||
Hint: If the WAR-files is named like "kitodo-something.war", the website has the same name: myserver.com:8080/kitodo-something | ||
|
57 changes: 57 additions & 0 deletions
57
ccs/scripts-for-minor-3.x-update/installMessagesAsPartOfMinorUpdate.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
# Expected command line parameters | ||
# $1: path to WAR-File for the new version | ||
# | ||
# Installing new messages from WAR-File as part of minor 3.x update ... | ||
# as part of the minor update process ... | ||
# defined here https://github.com/kitodo/kitodo-production/issues/3396 ... | ||
# even, if it is not mentioned there. | ||
# Files will be put to /usr/local/kitodo/messages | ||
# Hint: tomcat service will be stopped(!) also | ||
|
||
#fixed parameter | ||
kitodoPath=/usr/local/kitodo | ||
|
||
|
||
if [ "$EUID" -ne 0 ] | ||
then echo "Please run as root(sudo)" | ||
exit -1 | ||
fi | ||
|
||
if [ $# -ne 1 ] | ||
then | ||
echo "Parameter number not correct, expecting:" | ||
echo "\$1 (WAR-file)" | ||
exit -1 | ||
fi | ||
if [ ! -f $1 ] | ||
then | ||
echo "File $1 given as first parameter not found" | ||
exit -2 | ||
fi | ||
|
||
destDir=$kitodoPath/messages | ||
|
||
echo "Installing new messages from WAR-File as part of minor 3.x update ..." | ||
echo "as part of the minor update process ..." | ||
echo "defined here https://github.com/kitodo/kitodo-production/issues/3396 ..." | ||
echo "even, if it is not mentioned there." | ||
echo "Files will be put to $destDir" | ||
echo "" | ||
|
||
echo "stopping Tomcat ..." | ||
service tomcat8 stop | ||
echo "" | ||
|
||
echo "installing messages ..." | ||
if [ ! -d "$destDir" ] | ||
then | ||
echo "creating directory: " $destDir | ||
mkdir $destDir | ||
fi | ||
unzip -j $1 WEB-INF/classes/messages/* -d $destDir | ||
echo "" | ||
|
||
echo "... work done!" | ||
echo "" | ||
|
53 changes: 53 additions & 0 deletions
53
ccs/scripts-for-minor-3.x-update/installModulesAsPartOfMinorUpdate.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
# Expected command line parameters | ||
# $1: path to file with update modules.zip for the new version | ||
# | ||
# Installing new modules-jars as part of minor 3.x update ... | ||
# as described here https://github.com/kitodo/kitodo-production/issues/3396 ... | ||
# Files will be put to /usr/local/kitodo/modules | ||
# Hint: tomcat service will be stopped(!) also | ||
|
||
#fixed parameter | ||
kitodoPath=/usr/local/kitodo | ||
|
||
|
||
if [ "$EUID" -ne 0 ] | ||
then echo "Please run as root(sudo)" | ||
exit -1 | ||
fi | ||
|
||
if [ $# -ne 1 ] | ||
then | ||
echo "Parameter number not correct, expecting:" | ||
echo "\$1 (zipfile with new module-jars)" | ||
exit -1 | ||
fi | ||
if [ ! -f $1 ] | ||
then | ||
echo "File $1 given as first parameter not found" | ||
exit -2 | ||
fi | ||
|
||
destDir=$kitodoPath/modules | ||
|
||
echo "Installing new modules-jars as part of minor 3.x update ..." | ||
echo "as described here https://github.com/kitodo/kitodo-production/issues/3396 ..." | ||
echo "Files will be put to $kitodoPath/modules" | ||
echo "" | ||
|
||
echo "stopping Tomcat ..." | ||
service tomcat8 stop | ||
echo "" | ||
|
||
echo "installing module-jars ..." | ||
if [ ! -d "$destDir" ] | ||
then | ||
echo "creating directory: " $destDir | ||
mkdir $destDir | ||
fi | ||
unzip $1 -d $destDir | ||
echo "" | ||
|
||
echo "... work done!" | ||
echo "" | ||
|
78 changes: 78 additions & 0 deletions
78
ccs/scripts-for-minor-3.x-update/installWARAsPartOfMinorUpdate.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
# Expected command line parameters | ||
# $1: path to WAR-file for the new version | ||
# | ||
# Installing new WAR-file as part of minor 3.x update ... | ||
# as described here https://github.com/kitodo/kitodo-production/issues/3396 ... | ||
# Files will be put to /var/lib/tomcat8/webapps | ||
# Hint: tomcat service will be stopped(!) also | ||
|
||
#fixed parameter | ||
tomcatWebApps=/var/lib/tomcat8/webapps/ | ||
tomcatLogFile=/var/log/tomcat8/catalina.out | ||
|
||
if [ "$EUID" -ne 0 ] | ||
then echo "Please run as root(sudo)" | ||
exit -1 | ||
fi | ||
|
||
if [ $# -ne 1 ] | ||
then | ||
echo "Parameter number not correct, expecting:" | ||
echo "\$1 (WAR-file for new version)" | ||
exit -1 | ||
fi | ||
if [ ! -f $1 ] | ||
then | ||
echo "File $1 given as first parameter not found" | ||
exit -2 | ||
fi | ||
if [ ! -d $tomcatWebApps ] | ||
then | ||
echo "Could not find $tomcatWebApps" | ||
exit -3 | ||
fi | ||
|
||
#destDir=$kitodoPath/modules | ||
|
||
echo "Installing new WAR-jars as part of minor 3.x update ..." | ||
echo "as described here https://github.com/kitodo/kitodo-production/issues/3396 ..." | ||
echo "Files will be put to $tomcatWebApps" | ||
echo "" | ||
|
||
echo "stopping Tomcat ..." | ||
service tomcat8 stop | ||
echo "" | ||
|
||
kitodoWarFile=$1 | ||
echo "copying $kitodoWarFile to $tomcatWebApps ..." | ||
cp $kitodoWarFile $tomcatWebApps | ||
echo "" | ||
|
||
echo "starting tomcat ..." | ||
service tomcat8 start | ||
echo "" | ||
|
||
echo "waiting for deployment done ..." | ||
deploymentDone=0 | ||
while [ $deploymentDone != 1 ] | ||
do | ||
searchForDeployment="$(tail $tomcatLogFile | grep Deployment | wc -l)" | ||
if [ "$searchForDeployment" != 0 ] | ||
then | ||
echo "done" | ||
deploymentDone=1 | ||
else | ||
echo "wait" | ||
sleep 2 | ||
fi | ||
done | ||
echo "" | ||
|
||
echo "stopping Tomcat again ..." | ||
service tomcat8 stop | ||
echo "" | ||
|
||
echo "... work done!" | ||
echo "" | ||
|
55 changes: 55 additions & 0 deletions
55
ccs/scripts-for-minor-3.x-update/performDatabaseUpdateAsPartOfMinorUpdate.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
# Expected command line parameters | ||
# $1: path to file with update sql script for the new version | ||
# | ||
# As part of preparation for minor 3.x update ... | ||
# as described here https://github.com/kitodo/kitodo-production/issues/3396 ... | ||
# this script updates the kitodo database | ||
# Hint: tomcat service will be stopped(!) also | ||
|
||
#fixed parameter | ||
mysqluser="root" | ||
mysqlpwd="" | ||
mysqldb="kitodo" | ||
tempexportfile=~/.temp.sqlexport | ||
|
||
if [ "$EUID" -ne 0 ] | ||
then echo "Please run as root(sudo)" | ||
exit -1 | ||
fi | ||
|
||
if [ $# -ne 1 ] | ||
then | ||
echo "Parameter number not correct, expecting:" | ||
echo "\$1 (path to file with update sql script for the new version)" | ||
exit -1 | ||
fi | ||
if [ ! -f $1 ] | ||
then | ||
echo "File $1 given as first parameter not found" | ||
exit -2 | ||
fi | ||
|
||
echo "As part of preparation for minor 3.x update ..." | ||
echo "as described here https://github.com/kitodo/kitodo-production/issues/3396 ..." | ||
echo "this script updates the kitodo database" | ||
echo "Hint: tomcat service will be stopped(!) also." | ||
echo "" | ||
|
||
|
||
echo "stopping Tomcat ..." | ||
service tomcat8 stop | ||
echo "" | ||
|
||
echo "performing database update ..." | ||
mysql -u $mysqluser --password=$mysqlpwd $mysqldb < $1 | ||
if [ $? -ne 0 ] | ||
then | ||
echo "Error executing SQL-Script: $1" | ||
exit -3 | ||
fi | ||
echo "" | ||
|
||
echo "... work done!" | ||
echo "" | ||
|
49 changes: 49 additions & 0 deletions
49
ccs/scripts-for-minor-3.x-update/restoreConfigAfterMinorUpdate.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# Expected command line parameters | ||
# $1: tarfile with saved configuration data | ||
# Restoring current configuration as part of post actions after minor 3.x update ... | ||
# as described here https://github.com/kitodo/kitodo-production/issues/3396 ... | ||
# Files will be put to .../tomcat8/webapps/kitodo*/WEB-INF/classes | ||
|
||
#fixed parameter | ||
configDirSearchPath=/var/lib/tomcat8/webapps/ | ||
kitodoBaseWarName="kitodo*" | ||
|
||
|
||
if [ "$EUID" -ne 0 ] | ||
then echo "Please run as root(sudo)" | ||
exit -1 | ||
fi | ||
|
||
if [ $# -ne 1 ] | ||
then | ||
echo "Parameter number not correct, expecting:" | ||
echo "\$1 (tarfile with saved configuration data)" | ||
exit -1 | ||
fi | ||
if [ ! -f $1 ] | ||
then | ||
echo "File $1 given as first parameter not found" | ||
exit -2 | ||
fi | ||
|
||
echo "Restoring current configuration as part of post actions after minor 3.x update ..." | ||
echo "as described here https://github.com/kitodo/kitodo-production/issues/3396 ..." | ||
echo "Files will be put to .../tomcat8/webapps/kitodo*/WEB-INF/classes" | ||
echo "" | ||
possibleConfigDirs="$(find "$configDirSearchPath" -maxdepth 1 -type d -iname "$kitodoBaseWarName")" | ||
numberPossibleConfigDirs="$(echo "$possibleConfigDirs" | wc -l)" | ||
if [ "$numberPossibleConfigDirs" != 1 ] | ||
then | ||
echo "Not clear (expecting one - no less, no more) candidate for config here: " $configDirSearchPath | ||
exit -3 | ||
fi | ||
|
||
dirToTar=$possibleConfigDirs/WEB-INF/classes | ||
echo "Extracting" $1 ":" | ||
tar -C $dirToTar -xvf "$1" | ||
echo "" | ||
|
||
echo "... work done!" | ||
echo "" | ||
|
69 changes: 69 additions & 0 deletions
69
ccs/scripts-for-minor-3.x-update/saveConfigBeforeMinorUpdate.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
# Expected command line parameters | ||
# $1: directory for stored data, typical "~" | ||
# a sub-directory "savedOldVersionData" will be created below | ||
# Saving current configuration as part of preparation for minor 3.x update ... | ||
# as described here https://github.com/kitodo/kitodo-production/issues/3396 ... | ||
# Files taken from .../tomcat8/webapps/kitodo*/WEB-INF/classes, excluding mapping.json | ||
|
||
#fixed parameter | ||
configDirSearchPath=/var/lib/tomcat8/webapps/ | ||
kitodoBaseWarName="kitodo*" | ||
|
||
|
||
if [ "$EUID" -ne 0 ] | ||
then echo "Please run as root(sudo)" | ||
exit -1 | ||
fi | ||
|
||
if [ $# -ne 1 ] | ||
then | ||
echo "Parameter number not correct, expecting:" | ||
echo "\$1 (directory for data to be saved in)" | ||
exit -1 | ||
fi | ||
if [ ! -d $1 ] | ||
then | ||
echo "Directory $1 given as first parameter not found" | ||
exit -2 | ||
fi | ||
|
||
echo "Saving current configuration as part of preparation for minor 3.x update ..." | ||
echo "as described here https://github.com/kitodo/kitodo-production/issues/3396 ..." | ||
echo "Files taken from .../tomcat8/webapps/kitodo*/WEB-INF/classes, excluding mapping.json" | ||
echo "" | ||
possibleConfigDirs="$(find "$configDirSearchPath" -maxdepth 1 -type d -iname "$kitodoBaseWarName")" | ||
numberPossibleConfigDirs="$(echo "$possibleConfigDirs" | wc -l)" | ||
if [ "$numberPossibleConfigDirs" != 1 ] | ||
then | ||
echo "Not clear (expecting one - no less, no more) candidate for config here: " $configDirSearchPath | ||
exit -3 | ||
fi | ||
|
||
destDir=$1/savedOldVersionData | ||
filename="$(date | awk '{print $6$2$3$4}' | sed -e 's/:/_/g')" | ||
if [ ! -d "$destDir" ] | ||
then | ||
echo "creating directory: " $destDir | ||
mkdir $destDir | ||
fi | ||
|
||
# create the tar of the config | ||
desttarfile=$destDir/$filename-config.tar | ||
dirToTar=$possibleConfigDirs/WEB-INF/classes | ||
find "$dirToTar" -maxdepth 1 -type f -printf "%f\n"| grep -v mapping > .temp.tar | ||
numberOfFilesFound="$(cat .temp.tar | wc -l)" | ||
if [ ! $numberOfFilesFound > 0 ] | ||
then | ||
echo "Could not find any config files here: $dirToTar" | ||
exit -4 | ||
fi | ||
echo "Creating" $desttarfile "including these files:" | ||
tar -C $dirToTar -czf "$desttarfile" -T .temp.tar | ||
tar tf $desttarfile | ||
rm .temp.tar | ||
echo "" | ||
|
||
echo "... work done!" | ||
echo "" | ||
|
Oops, something went wrong.