Example #1
0
    echo "\tphp install-cli.php settings.ini\n";
    return 1;
}
function main($ini_file)
{
    $install = new Install($ini_file);
    $response = $install->step1();
    if (is_array($response)) {
        $install->print_errors($response);
    }
    $response = $install->step2();
    if (is_array($response)) {
        $install->print_errors($response);
    }
    $response = $install->step3();
    if (is_array($response)) {
        $install->print_errors($response);
    }
    $response = $install->step4();
    if (is_array($response)) {
        $install->print_errors($response);
    }
    exit(1);
}
if (validate_args($argv, $argc)) {
    echo "There are some erros with the parameters.\n";
    echo "Run --help to print the help.\n";
    exit(-1);
}
$ini_file = $argv[1];
main($ini_file);
Example #2
0
define('OSC_LOG_PREFIX', '__osclog_');
define('OLD_TABLE_PREFIX', '__osc_old_');
ini_set('mysql.connect_timeout', 20);
ini_set('default_socket_timeout', 1800);
ini_set('date.timezone', 'Asia/Chongqing');
if (function_exists('mysql_set_timeout')) {
    mysql_set_timeout(99999999);
}
$db_admin_user = '******';
$db_admin_pass = '******';
$backup_user = '******';
//////////////////////////////
// Main
//////////////////////////////
$validate_arg_array = array("mode" => array("required" => 0, "value_expected" => 1, "default_val" => 'create', "help_alias" => "[ seed | statement | clean ]"), "ddl_file" => array("required" => 0, "value_expected" => 1, "help_alias" => "Required for mode statement.\n                     File with ALTER or CREATE statements"), "seed_tables" => array("required" => 0, "value_expected" => 1, "help_alias" => "Required for mode seed.\n                     Comma seperated list of tables for which schema\n                     should be replicated from seed db"), "seed_host" => array("required" => 0, "value_expected" => 1, "default_val" => null, "help_alias" => "Required for mode seed.\n                     Host with example of desired table structure"), "seed_db" => array("required" => 0, "value_expected" => 1, "default_val" => null, "help_alias" => "Required for mode seed.\n                     Schema with example of desired table structure"), "socket" => array("required" => 0, "value_expected" => 1, "default_val" => null, "help_alias" => "mysqld socket file (default is to run on all)"), "dbname" => array("required" => 0, "value_expected" => 1, "default_val" => null, "help_alias" => "Run on named database\n                     Default is all not like test, mysql, localinfo,\n                     snapshot%, %_restored"), "skip_fk_check" => array("required" => 0, "value_expected" => 0, "default_val" => null, "help_alias" => "Skip foreign key check (not advisable outside udb)"), "skip_trigger_check" => array("required" => 0, "value_expected" => 0, "default_val" => null, "help_alias" => "Skip trigger check (not advisable)"), "eliminate_dups" => array("required" => 0, "value_expected" => 0, "default_val" => null, "help_alias" => "Removes duplicate entries for PK/uniques.\n                     Dangerous if run on slaves before masters."), "eliminate_unused_columns" => array("required" => 0, "value_expected" => 0, "default_val" => null, "help_alias" => "Allows a column to be dropped if it is not\n                     the in the new schema"), "use_new_pk" => array("required" => 0, "value_expected" => 0, "default_val" => null, "help_alias" => "Use new tables PK for doing merging of data.\n                     This option will use more diskspace and be slower."), "create_missing_table" => array("required" => 0, "value_expected" => 0, "default_val" => 0, "help_alias" => "If this option is set the script will create\n                     a missing table"), "ignore_partition_differences" => array("required" => 0, "value_expected" => 0, "default_val" => 0, "help_alias" => "If this option is set the script will not consider\n                     differences in partitions in its view of whether a table\n                     is already in the desired state"), "tmpdir" => array("required" => 0, "value_expected" => 1, "default_val" => null, "help_alias" => "Directory to temporarily store data\n                     Default is schema data directory"), "verbose" => array("required" => 0, "value_expected" => 1, "default_val" => 1, "help_alias" => "A value of 0 only shows errors,\n                     1 is the default and shows most interesting information,\n                     2 is has more detail than is normally useful,\n                     3 is very verbose and can break servers"), "long_trx_time" => array("required" => 0, "value_expected" => 1, "default_val" => 3600, "help_alias" => "Do not run OSC if a trx running longer than X exists"), "osc_class" => array("required" => 0, "value_expected" => 1, "default_val" => "OnlineSchemaChange", "help_alias" => "OnlineSchemaChange class to use instead of default"), "connection_limit" => array("required" => 0, "value_expected" => 1, "default_val" => CONNECTION_LIMIT, "help_alias" => "Wait to run if more than XXX connection exist\n                    DEFAULT is " . CONNECTION_LIMIT . " with a 10 minute timeout"), "scratch_schema" => array("required" => 0, "value_expected" => 1, "default_val" => "test", "help_alias" => "Schema to use instead of test for conversions of ALTERs\n                     into CREATE TABLE statements"), "accept_mysql_version" => array("required" => 0, "value_expected" => 0, "default_val" => null, "help_alias" => "Accept a version of MySQL that has not been white listed\n                    in the main OSC code"), "safe_compression_version" => array("required" => 0, "value_expected" => 1, "default_val" => "5.1.53", "help_alias" => "Strip InnoDB compression from CREATE TABLE statements\n                    if mysql is less than this version (default 5.1.53)"));
if (!($arg_list = validate_args($validate_arg_array))) {
    gen_help($validate_arg_array);
}
if (auth_check() == false) {
    print "ERROR: You have to run this script as root user\n";
    gen_help($validate_arg_array);
    exit(1);
}
foreach ($arg_list as $arg => $value) {
    ${$arg} = $value;
}
if ($osc_class != "OnlineSchemaChange") {
    require_once 'osc_helpers/' . $osc_class . '.php';
}
// get localhost
$op = "/bin/hostname | sed -e 's/\\.facebook\\.com//'";