4b7078
#!/bin/sh
4b7078
4b7078
source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
4b7078
4b7078
upgrade_info_file="$datadir/mysql_upgrade_info"
4b7078
version=0
4b7078
# get version as integer from mysql_upgrade_info file
4b7078
if [ -f "$upgrade_info_file" ] && [ -r "$upgrade_info_file" ] ; then
4b7078
    version_major=$(cat "$upgrade_info_file" | head -n 1 | sed -e 's/\([0-9]*\)\.\([0-9]*\)\..*$/\1/')
4b7078
    version_minor=$(cat "$upgrade_info_file" | head -n 1 | sed -e 's/\([0-9]*\)\.\([0-9]*\)\..*$/\2/')
4b7078
    if [[ $version_major =~ ^[0-9]+$ ]] && [[ $version_minor =~ ^[0-9]+$ ]] ; then
4b7078
        version=$((version_major*100+version_minor))
4b7078
    fi
4b7078
fi
4b7078
4b7078
# compute current version as integer
4b7078
thisversion=$((@MAJOR_VERSION@*100+@MINOR_VERSION@))
4b7078
4b7078
# provide warning in cases we should run mysql_upgrade
4b7078
if [ $version -ne $thisversion ] ; then
4b7078
4b7078
    # give extra warning if some version seems to be skipped
4b7078
    if [ $version -gt 0 ] && [ $version -lt 505 ] ; then
4b7078
        echo "The datadir located at $datadir seems to be older than of a version 5.5. Please, mind that as a general rule, to upgrade from one release series to another, go to the next series rather than skipping a series." >&2
4b7078
    fi
4b7078
4b7078
    cat <<EOF >&2
4b7078
The datadir located at $datadir needs to be upgraded using 'mysql_upgrade' tool. This can be done using the following steps:
4b7078
4b7078
  1. Back-up your data before running 'mysql_upgrade'
4b7078
  2. Start the database daemon using 'systemctl start @DAEMON_NAME@.service'
4b7078
  3. Run 'mysql_upgrade' with a database user that has sufficient privileges
4b7078
4b7078
Read more about 'mysql_upgrade' usage at:
4b7078
https://mariadb.com/kb/en/mariadb/documentation/sql-commands/table-commands/mysql_upgrade/
4b7078
EOF
4b7078
fi
4b7078
4b7078
exit 0