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