mirror of
https://git.qoto.org/m33/misskey-admin-scripts-n-tips.git
synced 2024-10-22 15:09:06 +00:00
add prechecks
This commit is contained in:
parent
ca5f35d2ba
commit
3b2dd05b5c
1 changed files with 54 additions and 7 deletions
|
@ -16,7 +16,8 @@ COMPOSE=docker-compose.yml
|
|||
# Backup destination directory
|
||||
DST=/usr/local/backup
|
||||
# Automatically stop, update and start the running instance
|
||||
AUTOUPDATE=0
|
||||
AUTOUPDATE=1
|
||||
TMP=/tmp/.update_misskey.$$
|
||||
###
|
||||
|
||||
if [ ! -d $CODE ] || [ ! -d $DATA ]; then
|
||||
|
@ -24,8 +25,9 @@ if [ ! -d $CODE ] || [ ! -d $DATA ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Take some care
|
||||
# Take some care before upgrading
|
||||
echo "Backing up current code... (you really should have done yourself a data backup before upgrading, something like backup_postgres.sh)"
|
||||
echo "$CODE will be archived in $DST/backup-code.tgz"
|
||||
tar -czf $DST/backup-code.tgz $CODE
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: something went wrong during backup..."
|
||||
|
@ -33,11 +35,52 @@ if [ $? -ne 0 ]; then
|
|||
fi
|
||||
|
||||
echo "Updating codebase with git..."
|
||||
#git stash
|
||||
#git checkout master
|
||||
#git pull
|
||||
#git submodule update --init
|
||||
#git stash pop
|
||||
cd $CODE
|
||||
|
||||
git stash
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error, bailing out"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git checkout master
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error, bailing out"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Compare version before/after pulling files
|
||||
currentVersion=`grep version package.json | awk '{ print $2 }' | sed 's/\"//g' | sed 's/,//'`
|
||||
|
||||
git pull | tee -a $TMP
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error, bailing out"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
grep -q "Already up to date." $TMP
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Your Misskey code is already up to date, version:$currentVersion."
|
||||
rm -f $TMP
|
||||
exit 0
|
||||
fi
|
||||
rm -f $TMP
|
||||
|
||||
latestVersion=`grep version package.json | awk '{ print $2 }' | sed 's/\"//g' | sed 's/,//'`
|
||||
echo "Upgrade needed, current:$currentVersion latest:$latestVersion."
|
||||
|
||||
git submodule update --init
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error, bailing out"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git stash pop
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error, bailing out"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Building new images... (it will take some time)"
|
||||
docker-compose --project-directory=$DATA --file $DATA/$COMPOSE build
|
||||
|
||||
|
@ -48,16 +91,20 @@ if [ $AUTOUPDATE -eq 0 ]; then
|
|||
echo "start_misskey.sh"
|
||||
else
|
||||
echo "Automatically updating the instance, fingers crossed"
|
||||
echo -n "Stopping..."
|
||||
stop_misskey.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: something went wrong when stopping the instance"
|
||||
exit 1
|
||||
fi
|
||||
echo "done."
|
||||
echo -n "Starting..."
|
||||
start_misskey.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: something went wrong when starting the instance"
|
||||
exit 1
|
||||
fi
|
||||
echo "done."
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in a new issue