当前位置: 首页>>代码示例>>PHP>>正文


PHP parse_opt函数代码示例

本文整理汇总了PHP中parse_opt函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_opt函数的具体用法?PHP parse_opt怎么用?PHP parse_opt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_opt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setupsecondary_main

function setupsecondary_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv;
    $dbf = $sgbl->__var_dbf;
    $prgm = $sgbl->__var_program_name;
    $list = parse_opt($argv);
    if (!isset($list['primary-master'])) {
        print "need --primary-master=\n";
        exit;
    }
    if (!isset($list['sshport'])) {
        print "need --sshport=\n";
        exit;
    }
    $master = $list['primary-master'];
    $sshport = $list['sshport'];
    print "Taking backup of the current database anyway...\n";
    lxshell_php("../bin/common/mebackup.php");
    $slavepass = randomString(7);
    print "Setting up mysql to receive data from master\n";
    add_line_to_secondary_mycnf($master, $slavepass);
    $pass = slave_get_db_pass();
    // TODO: REPLACE MYSQL_CONNECT
    $dblink = mysqli_connect("localhost", "root", $pass, $dbf);
    mysqli_query($dblink, "STOP SLAVE");
    print "Getting initial data from the master\n";
    system("ssh -p {$sshport} {$master} \"(cd /usr/local/lxlabs/{$prgm}/httpdocs ; lphp.exe ../bin/common/setupprimarymaster.php --slavepass={$slavepass})\" | mysql -u root -p{$pass} {$dbf}");
    print "starting mysql data getting process\n";
    mysqli_query($dblink, "CHANGE MASTER TO master_host='{$master}', master_password='{$slavepass}'");
    mysqli_query($dblink, "START SLAVE");
    lxfile_touch("../etc/secondary_master");
    lxfile_touch("../etc/running_secondary");
}
开发者ID:hypervm-ng,项目名称:hypervm-ng,代码行数:34,代码来源:setupsecondary.php

示例2: main

 function main()
 {
     global $gbl, $sgbl, $login, $ghtml;
     global $argv;
     initProgram('admin');
     $login->loadAllObjects('vps');
     $this->bserver_l = $login->getList('centralbackupserver');
     $list = $login->getList('vps');
     foreach ($this->bserver_l as $bso) {
         $bso->setMyselfUp();
     }
     $opt = parse_opt($argv);
     if (!isset($opt['newarg'])) {
         $mess = "\n\nThe architecture of centralized backup has been completely rewritten, and now we have per slave backup-server; you will need to supply --newarg=true for this to work. ";
         $mess .= "More info at http://wiki.lxcenter.org/.";
         print $mess;
         log_log("centralbackup_flag", $mess);
         send_mail_to_admin("Central Backup Failed", $mess);
         exit;
     }
     $this->stopvps = opt_get_single_flag($opt, 'stopvps');
     //$stopxen = opt_get_single_flag($opt, 'stopxen');
     //$stopopenvz = opt_get_single_flag($opt, 'stopopenvz');
     foreach ($list as $l) {
         $this->backup_one_vps($l);
     }
     foreach ((array) $this->global_list as $k => $s) {
         //$res = rl_exec_get(null, $k, 'remove_scpid', array($backupiddsa));
     }
 }
开发者ID:lonelywoolf,项目名称:hypervm,代码行数:30,代码来源:vpsbackup.php

示例3: process_main

function process_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv;
    $list = parse_opt($argv);
    $exitchar = $sgbl->__var_exit_char;
    $res = new Remote();
    $res->exception = null;
    $res->ddata = "hello";
    $res->message = "hello";
    $total = file_get_contents($list['temp-input-file']);
    @lunlink($list['temp-input-file']);
    $string = explode("\n", $total);
    if (csb($total, "__file::")) {
        ob_end_clean();
        file_server(null, $total);
    } else {
        $reply = process_server_input($total);
        //fprint(unserialize(base64_decode($reply)));
        ob_end_clean();
        print "{$reply}\n{$exitchar}\n";
        flush();
    }
    exit;
}
开发者ID:lonelywoolf,项目名称:hypervm,代码行数:25,代码来源:process_single.php

示例4: update_main

function update_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    debug_for_backend();
    $program = $sgbl->__var_program_name;
    $login = new Client(null, null, 'upgrade');
    $opt = parse_opt($argv);
    print "Getting Version Info from the Server...\n";
    if (isset($opt['till-version']) && $opt['till-version'] || lxfile_exists("__path_slave_db")) {
        $sgbl->slave = true;
        $upversion = findNextVersion($opt['till-version']);
        $type = 'slave';
    } else {
        $sgbl->slave = false;
        $upversion = findNextVersion();
        $type = 'master';
    }
    print "Connecting... Please wait....\n";
    if ($upversion) {
        do_upgrade($upversion);
        print "Upgrade Done.. Executing Cleanup....\n";
        flush();
    } else {
        print "{$program} is the latest version\n";
    }
    if (is_running_secondary()) {
        print "Not running Update Cleanup, because this is running secondary \n";
        exit;
    }
    lxfile_cp("htmllib/filecore/php.ini", "/usr/local/lxlabs/ext/php/etc/php.ini");
    $res = pcntl_exec("/bin/sh", array("../bin/common/updatecleanup.sh", "--type={$type}"));
    print "Done......\n";
}
开发者ID:lonelywoolf,项目名称:hypervm,代码行数:34,代码来源:updatelib.php

示例5: lxinstall_main

function lxinstall_main()
{
    global $argv;
    $opt = parse_opt($argv);
    $package = $opt['package-name'];
    lxinstall_package($package);
}
开发者ID:soar-team,项目名称:kloxo,代码行数:7,代码来源:lxinstall.php

示例6: updatecleanup_main

function updatecleanup_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    $program = $sgbl->__var_program_name;
    $opt = parse_opt($argv);
    if ($opt['type'] === 'master') {
        initProgram('admin');
        $flg = "__path_program_start_vps_flag";
        if (!lxfile_exists($flg)) {
            set_login_skin_to_feather();
        }
    } else {
        $login = new Client(null, null, 'update');
    }
    print "Executing UpdateCleanup. This can take a long time. Please be patient\n";
    log_log("update", "Executing Updatecleanup");
    //
    // Cleanup old lxlabs.repo file
    //
    print "Fixing Repo's\n";
    if (lxfile_exists("/etc/yum.repos.d/lxcenter.repo")) {
        if (lxfile_exists("/etc/yum.repos.d/lxlabs.repo")) {
            lxfile_mv("/etc/yum.repos.d/lxlabs.repo", "/etc/yum.repos.d/lxlabs.repo.lxsave");
            system("rm -f /etc/yum.repos.d/lxlabs.repo");
        }
    }
    if (lxfile_exists("CVS")) {
        print "Found Development version, we just go on.\n";
        //		exit;
    }
    if ($opt['type'] === 'master') {
        $sgbl->slave = false;
        if (!is_secondary_master()) {
            print "Update database\n";
            updateDatabaseProperly();
            print "Fix Extra database issues\n";
            fixExtraDB();
            print "Update extra issues\n";
            doUpdateExtraStuff();
            print "Get Driver info\n";
            lxshell_return("__path_php_path", "../bin/common/driverload.php");
        }
        print "Starting Update all slaves\n";
        update_all_slave();
        print "Fix main {$program} databasefile\n";
        cp_dbfile();
    } else {
        $sgbl->slave = true;
    }
    if (!is_secondary_master()) {
        print "Starting update cleanups\n";
        updatecleanup();
    }
    lxfile_touch("__path_program_start_vps_flag");
}
开发者ID:digideskio,项目名称:hypervm,代码行数:56,代码来源:tmpupdatecleanup.php

示例7: switchserver_main

function switchserver_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    //sleep(60);
    initProgram("admin");
    if ($argc === 1) {
        print "Usage: {$argv['0']} --class= --name= --v-syncserver= \n";
        exit;
    }
    try {
        $opt = parse_opt($argv);
        $param = get_variable($opt);
        dprintr($param);
        $class = $opt['class'];
        $name = $opt['name'];
        if (lx_core_lock("{$class}-{$name}.switchserver")) {
            exit;
        }
        $object = new $class(null, 'localhost', $name);
        $object->get();
        if ($object->dbaction === 'add') {
            throw new lxException("no_object", '', '');
            exit;
        }
        if (!$object->syncserver) {
            print "No_synserver...\n";
            throw new lxException("no_syncserver", '', '');
            exit;
        }
        if ($param['syncserver'] === $object->syncserver) {
            print "No Change...\n";
            throw new lxException("no_change", '', '');
            exit;
        }
        $driverapp_old = $gbl->getSyncClass('localhost', $object->syncserver, $object->get__table());
        $driverapp_new = $gbl->getSyncClass('localhost', $param['syncserver'], $object->get__table());
        if ($driverapp_new !== $driverapp_old) {
            //throw new lxException ("the_drivers_are_different_in_two_servers", '', '');
        }
        $object->doupdateSwitchserver($param);
    } catch (exception $e) {
        print $e->getMessage();
        /// hcak ahck... Chnage only the olddelete variable which is the mutex used for locking in the process of switch. The problem is we want to totally bail out if the switchserver fails. The corect way would be save after reverting the syncserve to the old value, but that's a bit risky. So we just use a hack to change only the olddeleteflag; Not a real hack.. This is the better way.
        $message = "{$e->getMessage()}";
        write_to_object($object, $message, $param['syncserver']);
        $fullmesage = "Switch of {$object->get__table()}:{$object->nname} to {$object->syncserver} failed due to {$e->getMessage()}";
        log_switch($fullmesage);
        mail($login->contactemail, "Switch Failed:", "{$fullmesage}\n");
        print "\n";
        exit;
    }
    mail($login->contactemail, "Switch Succeeded", "Switch Succeeded {$object->get__table()}:{$object->nname} to {$param['syncserver']}\n");
}
开发者ID:lonelywoolf,项目名称:hypervm,代码行数:54,代码来源:switchserver.php

示例8: gettraffic_main

function gettraffic_main()
{
    global $argc, $argv;
    $list = parse_opt($argv);
    if (isset($list['delete-table']) && $list['delete-table'] === 'yes') {
        print "clearing Traffic Table\n";
        clearTrafficTable();
        filltraffictable();
    } else {
        filltraffictable();
    }
}
开发者ID:digideskio,项目名称:hypervm,代码行数:12,代码来源:gettraffic.php

示例9: create_main

function create_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    $opt = parse_opt($argv);
    if (file_exists('/usr/local/lxlabs/.git')) {
        $opt['development_found'] = '1';
    }
    lxfile_mkdir("{$sgbl->__path_program_etc}/conf");
    lxfile_mkdir("{$sgbl->__path_program_root}/pid");
    lxfile_mkdir("{$sgbl->__path_program_root}/log");
    lxfile_mkdir("{$sgbl->__path_httpd_root}");
    os_create_program_service();
    if (isset($opt['admin-password'])) {
        $admin_pass = $opt['admin-password'];
    } else {
        $admin_pass = 'admin';
    }
    if ($opt['install-type'] == 'master') {
        if (!isset($opt['development_found'])) {
            create_mysql_db('master', $opt, $admin_pass);
            create_database();
            create_general();
            add_admin($admin_pass);
            create_servername();
            lxshell_return("__path_php_path", "../bin/collectquota.php");
        } else {
            print "Development GIT version found. Skipping creation from scratch of HyperVM-NG.\n";
        }
        print "Updating the system. Will take a while\n";
        system("/usr/local/lxlabs/ext/php/php ../bin/common/updatecleanup-main.php --type=master");
    } else {
        if ($opt['install-type'] == 'slave') {
            if (!isset($opt['development_found'])) {
                init_slave($admin_pass);
            } else {
                print "Development GIT version found. Skipping creation from scratch of HyperVM-NG.\n";
            }
            print "Updating the system. Will take a while\n";
            system("/usr/local/lxlabs/ext/php/php ../bin/common/updatecleanup-main.php --type=slave");
        } else {
            print "Unknown Install type\n";
            flush();
        }
    }
    system("rm -f /etc/sysconfig/network-scripts/ifcfg-*-range*");
    //system("$sgbl->__path_php_path ../bin/misc/fixcentos5xen.php");
    //os_fix_some_permissions();
    system("cp ../sbin/lxxen ../sbin/lxopenvz /usr/bin");
    system("chmod 4755 /usr/bin/lxxen /usr/bin/lxopenvz");
    //os_set_iis_ftp_root_path();
}
开发者ID:hypervm-ng,项目名称:hypervm-ng,代码行数:52,代码来源:create.php

示例10: driverload_main

function driverload_main()
{
    global $argv, $gbl, $sgbl, $login, $ghtml;
    initProgram('admin');
    $p = parse_opt($argv);
    if (isset($p['clear-existing'])) {
        $sq = new Sqlite(null, "driver");
        $sq->rawQuery("delete from driver");
    }
    $list = $login->getList('pserver');
    foreach ($list as $l) {
        $l->getandWriteModuleDriver();
    }
}
开发者ID:lonelywoolf,项目名称:hypervm,代码行数:14,代码来源:driverload.php

示例11: create_main

function create_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    $opt = parse_opt($argv);
    lxfile_mkdir("{$sgbl->__path_program_etc}/conf");
    lxfile_mkdir("{$sgbl->__path_program_root}/pid");
    lxfile_mkdir("{$sgbl->__path_program_root}/log");
    lxfile_mkdir("{$sgbl->__path_httpd_root}");
    os_fix_lxlabs_permission();
    os_create_program_service();
    os_create_kloxo_service_once();
    if (isset($opt['admin-password'])) {
        $admin_pass = $opt['admin-password'];
    } else {
        $admin_pass = 'admin';
    }
    if ($opt['install-type'] == 'master') {
        create_mysql_db('master', $opt, $admin_pass);
        create_database();
        create_general();
        init_main($admin_pass);
        lxshell_return("__path_php_path", "../bin/collectquota.php");
        print "This will take a long time... Please wait...\n";
        system("/usr/local/lxlabs/ext/php/php ../bin/common/tmpupdatecleanup.php --type=master");
    } else {
        if ($opt['install-type'] == 'slave') {
            init_slave($admin_pass);
            print "This will take a long time... Please wait...\n";
            system("/usr/local/lxlabs/ext/php/php ../bin/common/tmpupdatecleanup.php --type=slave");
        } else {
            if ($opt['install-type'] == 'supernode') {
                $sgbl->__path_sql_file = $sgbl->__path_sql_file_supernode;
                $sgbl->__var_dbf = $sgbl->__path_supernode_db;
                $sgbl->__path_admin_pass = $sgbl->__path_super_pass;
                $sgbl->__var_admin_user = $sgbl->__var_super_user;
                create_mysql_db('super', $opt, $admin_pass);
                init_supernode($admin_pass);
                print "\n";
            } else {
                print "Unknown Install type\n";
                flush();
            }
        }
    }
    os_create_default_slave_driver_db();
    os_fix_some_permissions();
}
开发者ID:soar-team,项目名称:kloxo,代码行数:48,代码来源:create.php

示例12: commandline_main

function commandline_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv;
    initProgram('admin');
    $must = array('action');
    $p = parse_opt($argv);
    $pk = array_keys($p);
    foreach ($must as $m) {
        if (!array_search_bool($m, $pk)) {
            print "Need action, class and name\n";
            exit;
        }
    }
    $func = "__cmd_desc_{$p['action']}";
    try {
        $list = $func($p);
        if ($list) {
            if (isset($p['output-type'])) {
                if ($p['output-type'] === 'json') {
                    $out = json_encode($list);
                    print $out;
                } else {
                    if ($p['output-type'] === 'serialize') {
                        $out = serialize($list);
                        print $out;
                    }
                }
            } else {
                foreach ($list as $l) {
                    print "{$l}\n";
                }
            }
        } else {
            print "{$p['action']} succesfully executed\n";
        }
        exit(0);
    } catch (exception $e) {
        print $e->__full_message;
        print "\n";
        exit(8);
    }
}
开发者ID:lonelywoolf,项目名称:hypervm,代码行数:43,代码来源:commandline.php

示例13: pmaster_main

function pmaster_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv;
    ob_start();
    $pass = slave_get_db_pass();
    $tfile = ltempnam("/tmp", "mastertmp");
    $dbf = $sgbl->__var_dbf;
    $list = parse_opt($argv);
    $slavepass = $list['slavepass'];
    add_line_to_master_mycnf();
    mysql_connect("localhost", "root", $pass);
    mysql_query("grant replication slave on *.* to lxlabsslave@'%' identified by '{$slavepass}'");
    system("mysqldump --master-data -u root '-p{$pass}' {$dbf} > {$tfile}");
    ob_clean();
    readfile($tfile);
    ob_start();
    unlink($tfile);
    ob_clean();
}
开发者ID:lonelywoolf,项目名称:hypervm,代码行数:20,代码来源:setupprimarymaster.php

示例14: pmaster_main

function pmaster_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv;
    ob_start();
    $pass = slave_get_db_pass();
    $tfile = ltempnam("/tmp", "mastertmp");
    $dbf = $sgbl->__var_dbf;
    $list = parse_opt($argv);
    $slavepass = $list['slavepass'];
    add_line_to_master_mycnf();
    // TODO: REPLACE MYSQL_CONNECT
    $dblink = mysqli_connect("localhost", "root", $pass, $dbf);
    mysqli_query($dblink, "GRANT REPLICATION SLAVE ON *.* TO lxlabsslave@'%' IDENTIFIED BY '{$slavepass}'");
    system("mysqldump --master-data -u root '-p{$pass}' {$dbf} > {$tfile}");
    ob_clean();
    readfile($tfile);
    ob_start();
    unlink($tfile);
    ob_clean();
}
开发者ID:hypervm-ng,项目名称:hypervm-ng,代码行数:21,代码来源:setupprimarymaster.php

示例15: virt_install_main

function virt_install_main()
{
    global $argv;
    $opt = parse_opt($argv);
    $virtualization = $opt['virtualization-type'];
    $installtype = $opt['install-type'];
    $skipostemplate = false;
    if (isset($opt['skipostemplate'])) {
        $skipostemplate = true;
    }
    if ($virtualization === 'openvz') {
        openvz_install($installtype);
    } else {
        if ($virtualization === 'xen') {
            xen_install($installtype);
        }
    }
    if ($installtype !== 'slave' && !$skipostemplate) {
        installOstemplates($virtualization);
    }
    print "Executing Update Cleanup... Will take a long time to finish....\n";
    lxshell_return("__path_php_path", "../bin/common/updatecleanup.php", "--type={$installtype}");
}
开发者ID:digideskio,项目名称:hypervm,代码行数:23,代码来源:virt-install.php


注:本文中的parse_opt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。