Last active
April 11, 2022 12:20
-
-
Save coltoneshaw/4603f3372b84a765e155671f92a3dade to your computer and use it in GitHub Desktop.
Upgrading Mattermost
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
#!/bin/bash | |
MATTERMOST_INSTALL_DIR=/opt/mattermost | |
SETUP_DIR=/tmp | |
SETUP_DIR=setup | |
echoStatus () { | |
echo "" | |
printf '=%.0s' {1..80} | |
echo "" | |
printf "\n $1 \n" | |
echo "" | |
printf '=%.0s' {1..80} | |
echo "" | |
} | |
bash echoStatus "Downloading and extracting the Mattermost Upgrade" | |
if [[ $1 = 'latest' ]] | |
then | |
wget --content-disposition "https://latest.mattermost.com/mattermost-enterprise-linux" -P $SETUP_DIR | |
else | |
wget "https://releases.mattermost.com/$1/mattermost-$1-linux-amd64.tar.gz" -P $SETUP_DIR | |
fi | |
tar -xf $SETUP_DIR/mattermost*.gz --transform='s,^[^/]\+,\0-upgrade,' -C $SETUP_DIR | |
echo "Done..." | |
bash echoStatus "Stopping Mattermost..." | |
systemctl stop mattermost | |
echo "Done..." | |
bash echoStatus "Making a backup..." | |
cp -ra $MATTERMOST_INSTALL_DIR /opt/mattermost-back-$(date +'%F-%H-%M')/ | |
echo "Done..." | |
bash echoStatus "Deleting old files and moving things around..." | |
find $MATTERMOST_INSTALL_DIR/ $MATTERMOST_INSTALL_DIR/client/ -mindepth 1 -maxdepth 1 \! \( -type d \( -path $MATTERMOST_INSTALL_DIR/client -o -path $MATTERMOST_INSTALL_DIR/client/plugins -path $MATTERMOST_INSTALL_DIR/client -o -path $MATTERMOST_INSTALL_DIR/client/emoji -o -path $MATTERMOST_INSTALL_DIR/config -o -path $MATTERMOST_INSTALL_DIR/logs -o -path $MATTERMOST_INSTALL_DIR/plugins -o -path $MATTERMOST_INSTALL_DIR/data \) -prune \) | sort | sudo xargs rm -r | |
cp -an $SETUP_DIR/mattermost-upgrade/. $MATTERMOST_INSTALL_DIR/ | |
rm -r $SETUP_DIR/mattermost-upgrade/ | |
rm -r $SETUP_DIR/mattermost*.gz | |
chown -R mattermost:mattermost $MATTERMOST_INSTALL_DIR | |
# #enabling local mode within the config.json | |
# bash $SCRIPTS_COMMANDS_VARIOUS_MAINTENCE enableLocalMode | |
echo "Done..." | |
bash echoStatus "Starting Mattermost..." | |
systemctl start mattermost | |
echo "Done..." | |
bash echoStatus "Finished. Enjoy!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment