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