Skip to content

Instantly share code, notes, and snippets.

@noonedeadpunk
Last active Aug 6, 2020
Embed
What would you like to do?
Mattermost upgrade

In order to use that script, there are some pre-requirements:

1 You're supposed to move content of mattermosts' special directories (config, logs, plugins, client/plugins, and data) to $mattermost_special_dir

2 You should make /opt/mattermost to be a symlink to the real mattermost directory - /opt/mattermost-XX.XX.X/mattermost, where XX.XX.X is current MM version

3 For MM upgrade just run ./upgrade_mattermost.sh YY.YY.Y, where YY.YY.Y is new MM version to be run.

#!/bin/bash
mattermost_dir="/opt"
mattermost_special_dir="${mattermost_dir}/mattermost_special"
mattermost_special="config logs plugins client/plugins data"
function prepare_new_mm {
wget -O /tmp/mattermost-${mm_version}-linux-amd64.tar.gz https://releases.mattermost.com/${mm_version}/mattermost-${mm_version}-linux-amd64.tar.gz
mkdir ${mattermost_dir}/mattermost-${mm_version}
tar -xf /tmp/mattermost-${mm_version}-linux-amd64.tar.gz -C ${mattermost_dir}/mattermost-${mm_version}
rm /tmp/mattermost-${mm_version}-linux-amd64.tar.gz
chown -R mattermost:mattermost ${mattermost_dir}/mattermost-${mm_version}
for special in ${mattermost_special}; do
rm -rf ${mattermost_dir}/mattermost-${mm_version}/mattermost/${special}
ln -s ${mattermost_special_dir}/${special} ${mattermost_dir}/mattermost-${mm_version}/mattermost/${special}
done
}
function launch_new_mm {
if [[ -L ${mattermost_dir}/mattermost ]]; then
service mattermost stop
rm ${mattermost_dir}/mattermost
ln -s ${mattermost_dir}/mattermost-${mm_version}/mattermost ${mattermost_dir}/mattermost
service mattermost start
else
echo "Old mattermost directory is not a symlink!"
exit 1
fi
}
if [[ -z $1 ]]; then
echo "Mattermost version is not provided!"
exit 1
else
mm_version=${1}
prepare_new_mm
launch_new_mm
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment