#!/bin/sh

MYSQL_UPGRADE="/usr/clearos/sandbox/usr/bin/mysql_upgrade"

DB_CONFIG="/var/clearos/system_database/root"

FORCE=''
if [ "$1" = "--force" ]; then
    FORCE=$1
fi

# Grab root database password
#----------------------------

ROOTPASS=`grep ^password $DB_CONFIG 2>/dev/null | sed "s/^password[[:space:]]*=[[:space:]]*//"`

if [ -z "$ROOTPASS" ]; then
    echo "Unable to authenticate with database"
    exit 1;
fi
$MYSQL_UPGRADE -uroot -p"$ROOTPASS" $FORCE
