Example #1
0
function plugin_monitoring_install()
{
    include GLPI_ROOT . "/plugins/monitoring/install/update.php";
    $version_detected = pluginMonitoringGetCurrentVersion(PLUGIN_MONITORING_VERSION);
    if (isset($version_detected) and $version_detected != PLUGIN_MONITORING_VERSION and $version_detected != '0') {
        pluginMonitoringUpdate($version_detected);
    } else {
        if (isset($version_detected) and $version_detected == PLUGIN_MONITORING_VERSION) {
            // Yet at right version
        } else {
            include GLPI_ROOT . "/plugins/monitoring/install/install.php";
            pluginMonitoringInstall(PLUGIN_MONITORING_VERSION);
        }
    }
    return true;
}
    }
    function displayWarning($msg, $red = FALSE)
    {
        if ($red) {
            $msg = "** {$msg}";
        }
        echo str_pad($msg, 100) . "\n";
    }
}
/*---------------------------------------------------------------------*/
if (!TableExists("glpi_configs")) {
    die("GLPI not installed\n");
}
$plugin = new Plugin();
include GLPI_ROOT . "/plugins/monitoring/install/update.php";
$current_version = pluginMonitoringGetCurrentVersion(PLUGIN_MONITORING_VERSION);
$migration = new CliMigration($current_version);
if (!isset($current_version)) {
    $current_version = 0;
}
if ($current_version == '0') {
    $migration->displayWarning("***** Install process of plugin MONITORING *****");
} else {
    $migration->displayWarning("***** Update process of plugin MONITORING *****");
}
$migration->displayWarning("Current Monitoring version: {$current_version}");
$migration->displayWarning("Version to update: " . PLUGIN_MONITORING_VERSION);
// To prevent problem of execution time
ini_set("max_execution_time", "0");
ini_set("memory_limit", "-1");
$mess = '';