Blame SOURCES/mysql-check-upgrade.sh

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