Last active
July 30, 2018 16:47
-
-
Save aursu/ab30a33e34b1318e8404cc0d28c71b3a to your computer and use it in GitHub Desktop.
AnswerHub On-Premise upgrade script
This file contains hidden or 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
#!/bin/bash | |
set -e | |
APPROOT=/var/www/answerhub | |
BKPSUF=$(date +%Y-%m-%d:%H:%M) | |
PERM="tomcat:tomcat" | |
STOPCMD="systemctl stop tomcat" | |
STARTCMD="systemctl restart tomcat" | |
NEXTREL="$1" | |
[ -d "$NEXTREL" -a -d "$NEXTREL/teamhub.war" -a -d "$NEXTREL/teamhub.home" ] || { | |
echo "Usage: $0 <new release folder>" >&2 | |
exit 0 | |
} | |
# In most cases, upgrading your AnswerHub installation is relatively easy. | |
# Simply follow the steps below and after restarting your application server, | |
# AnswerHub will run any additional upgrade tasks that are required and then | |
# your new version will be ready to run. | |
# 1. Stop your running application server | |
echo $STOPCMD | |
$STOPCMD | |
# 2. Make a backup of your existing teamhub.war and teamhub.home folders | |
THUBWAR=$APPROOT/teamhub.war | |
[ -d "$THUBWAR" ] && { | |
echo mv $THUBWAR{,-$BKPSUF} | |
mv $THUBWAR{,-$BKPSUF} | |
} | |
THUBHOME=$APPROOT/teamhub.home | |
[ -d "$THUBHOME" ] && { | |
echo mv $THUBHOME{,-$BKPSUF} | |
mv $THUBHOME{,-$BKPSUF} | |
} | |
# Replace your existing teamhub.war folder with the teamhub.war from the new release | |
echo cp -a $NEXTREL/teamhub.war $APPROOT/ | |
cp -a $NEXTREL/teamhub.war $APPROOT/ | |
# Migrate your teamhub.war/WEB-INF/classes/META-INF/config.properties to the new | |
# directory | |
echo cat $THUBWAR-$BKPSUF/WEB-INF/classes/META-INF/config.properties > $THUBWAR/WEB-INF/classes/META-INF/config.properties | |
cat $THUBWAR-$BKPSUF/WEB-INF/classes/META-INF/config.properties > $THUBWAR/WEB-INF/classes/META-INF/config.properties | |
# Replace your existing teamhub.home folder with the teamhub.home from the new | |
# release | |
echo cp -a $NEXTREL/teamhub.home $APPROOT/ | |
cp -a $NEXTREL/teamhub.home $APPROOT/ | |
# Copy any custom themes and plugins to the teamhub.home/themes folder and the | |
# teamhub.home/plugins/installed folder. | |
[ -d themes ] && { | |
echo mkdir -p $THUBHOME/themes/ | |
mkdir -p $THUBHOME/themes/ | |
echo rsync -rcav themes/ $THUBHOME/themes/ | |
rsync -rcav themes/ $THUBHOME/themes/ | |
} | |
[ -d plugins/installed ] && { | |
echo mkdir -p $THUBHOME/plugins/installed | |
mkdir -p $THUBHOME/plugins/installed | |
echo rsync -rcav plugins/ $THUBHOME/plugins/ | |
rsync -rcav plugins/ $THUBHOME/plugins/ | |
} | |
# Copy any files from your old teamhub.home/sites folder to the new | |
# teamhub.home/sites folder. | |
[ -d $THUBHOME/sites ] && { | |
echo rm -rf $THUBHOME/sites | |
rm -rf $THUBHOME/sites | |
echo mkdir -p $THUBHOME/sites | |
mkdir -p $THUBHOME/sites | |
} | |
echo rsync -rcav $THUBHOME-$BKPSUF/sites/ $THUBHOME/sites/ | |
rsync -rcav $THUBHOME-$BKPSUF/sites/ $THUBHOME/sites/ | |
# Finally, verify that the folders in the new teamhub.home are owned by the user | |
# running your application server. | |
echo chown -R $PERM $APPROOT/ | |
chown -R $PERM $APPROOT/ | |
# After these steps, restart your application server and the new AnswerHub should | |
# load. If your new version does not start, please double-check that you followed | |
# all the steps outlined above and then contact your support representative for | |
# help with the upgrade. | |
echo $STARTCMD | |
$STARTCMD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment