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.