marknl
2011-08-09 28c819b4402c79db059e584c61af6d8289a3f4d5
Added mysql table check/repair for ISPConfig database while running (auto)update.

http://bugtracker.ispconfig.org/index.php?do=details&task_id=1360
3 files modified
35 ■■■■■ changed files
install/autoupdate.php 5 ●●●●● patch | view | raw | blame | history
install/lib/update.lib.php 26 ●●●●● patch | view | raw | blame | history
install/update.php 4 ●●●● patch | view | raw | blame | history
install/autoupdate.php
@@ -145,6 +145,11 @@
}
/*
 *  Check all tables
*/
checkDbHealth();
/*
 *  Prepare the dump of the database 
*/
prepareDBDump();
install/lib/update.lib.php
@@ -79,6 +79,32 @@
    }
}
function checkDbHealth() {
    global $conf;
    //* Array containing non OK tables (can be repaired, crashed, corrupt)
    $notok = array();
    echo "Checking ISPConfig database .. ";
    exec("mysqlcheck -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' -r ".$conf["mysql"]["database"], $result);
    for( $i=0; $i<sizeof($result);$i++) {
        if ( substr($result[$i], -2) != "OK" ) {
            $notok[] = $result[$i];
        }
    }
    if ( sizeof($notok) > 0 ) {
        echo "\nSome tables where not 'OK'. Please check the list below.\n\n";
        foreach ($notok as $key => $value) {
            echo "$value\n";
        }
        echo "\nPress enter to continue or CTRL-C to cancel the installation ..";
        sread();
    }
    else
      echo "OK\n";
}
function updateDbAndIni() {
    global $inst, $conf;
install/update.php
@@ -187,6 +187,10 @@
    $inst->dbmaster = $inst->db;
}
/*
 *  Check all tables
*/
checkDbHealth();
/*
 *  dump the new Database and reconfigure the server.ini