• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP parse_opt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: remote_main

function remote_main()
{
    global $gbl, $sgbl, $login, $ghtml, $g_dbf;
    global $argv;
    ob_start();
    $args = parse_opt($argv);
    $gbl->is_master = false;
    $gbl->is_slave = false;
    if (isset($args['install-type']) && $args['install-type'] === 'master') {
        $login = new Client(null, null, 'master');
        $gbl->is_master = true;
        $login->get();
    } else {
        $login = new Client(null, null, 'slave');
        //$login->initThisDef();
        $gbl->is_slave = true;
        $rmt = unserialize(lfile_get_contents("__path_slave_db"));
        $login->password = $rmt->password;
    }
    $login->cttype = 'admin';
    // This is to prevent the socket already used error. If use a strict single interface, the socket operations happen through our own functions, and we can set the reuse option.
    $rmt = unserialize(base64_decode($ghtml->frm_rmt));
    $res = do_remote($rmt);
    print_time('full', 'timing');
    $res->message = ob_get_contents();
    $val = base64_encode(serialize($res));
    while (@ob_end_clean()) {
    }
    print $val;
    exit;
}
开发者ID:soar-team,项目名称:kloxo,代码行数:31,代码来源:remotelib.php


示例17: update_main

function update_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    debug_for_backend();
    $prognameNice = $sgbl->__var_program_name_nice;
    $login = new Client(null, null, 'upgrade');
    $opt = parse_opt($argv);
    print "Getting Version Info from the Server...\n";
    print "Connecting... Please wait....\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';
    }
    $thisversion = $sgbl->__ver_major_minor_release;
    if ($upversion) {
        do_upgrade($upversion);
        print "Upgrade Done!\nStarting the Cleanup.\n";
        flush();
    } else {
        print "{$prognameNice} is the latest version ({$thisversion})\n";
        print "Run 'sh /script/cleanup' if you want restore/fix possible issues.\n";
        exit;
    }
    if (is_running_secondary()) {
        print "Not running the Update Cleanup, because this server is a secondary.\n";
        exit;
    }
    // Needs to be here. So any php.ini change takes immediately effect.
    print "Copy Core PHP.ini\n";
    lxfile_cp("htmllib/filecore/php.ini", "/usr/local/lxlabs/ext/php/etc/php.ini");
    pcntl_exec("/bin/sh", array("../bin/common/updatecleanup-core.sh", "--type={$type}"));
    print "{$prognameNice} is Ready!\n\n";
}
开发者ID:hypervm-ng,项目名称:hypervm-ng,代码行数:39,代码来源:updatelib.php


示例18: initprogram

<?php

include_once "htmllib/lib/include.php";
initprogram('admin');
$sgbl->__var_collectquota_run = true;
exit_if_another_instance_running();
$global_dontlogshell = true;
$cmd = parse_opt($argv);
if (!isset($cmd['just-db'])) {
    $sgbl->__var_just_db = false;
    try {
        storeinGblvariables();
    } catch (Exception $e) {
        print $e->getMessage();
        print "\n";
    }
} else {
    $sgbl->__var_just_db = true;
}
// We need to blank it, since all the vpses were loaded once.
$login = null;
initProgram('admin');
$login->collectQuota();
$login->was();
findServerTraffic();
function storeinGblvariables()
{
    global $gbl, $sgbl, $login, $ghtml;
    return;
    $firstofmonth = @mktime(00, 01, 00, @date("n"), 1, @date("Y"));
    $today = time() + 2 * 24 * 60 * 60;
开发者ID:digideskio,项目名称:hypervm,代码行数:31,代码来源:collectquota.php


示例19: lxins_main

function lxins_main()
{
    global $argv, $downloadserver;
    $opt = parse_opt($argv);
    $dir_name = dirname(__FILE__);
    $installtype = $opt['install-type'];
    $dbroot = isset($opt['db-rootuser']) ? $opt['db-rootuser'] : "root";
    $dbpass = isset($opt['db-rootpassword']) ? $opt['db-rootpassword'] : "";
    $osversion = find_os_version();
    $arch = `arch`;
    $arch = trim($arch);
    if (!char_search_beg($osversion, "centos") && !char_search_beg($osversion, "rhel")) {
        print "Kloxo is only supported on CentOS 5 and RHEL 5\n";
        exit;
    }
    if (file_exists("/usr/local/lxlabs/kloxo")) {
        // Ask Reinstall
        if (get_yes_no("Kloxo seems already installed do you wish to continue?") == 'n') {
            print "Installation Aborted.\n";
            exit;
        }
    } else {
        // Ask License
        if (get_yes_no("Kloxo is using AGPL-V3.0 License, do you agree with the terms?") == 'n') {
            print "You did not agree to the AGPL-V3.0 license terms.\n";
            print "Installation aborted.\n\n";
            exit;
        } else {
            print "Installing Kloxo = YES\n\n";
        }
    }
    // Ask for InstallApp
    print "InstallApp: PHP Applications like PHPBB, WordPress, Joomla etc\n";
    print "When you choose Yes, be aware of downloading about 350Mb of data!\n";
    if (get_yes_no("Do you want to install the InstallAPP sotfware?") == 'n') {
        print "Installing InstallApp = NO\n";
        print "You can install it later with /script/installapp-update\n\n";
        $installappinst = false;
    } else {
        print "Installing InstallApp = YES\n\n";
        $installappinst = true;
    }
    print "Adding System users and groups (nouser, nogroup and lxlabs, lxlabs)\n";
    system("groupadd nogroup");
    system("useradd nouser -g nogroup -s '/sbin/nologin'");
    system("groupadd lxlabs");
    system("useradd lxlabs -g lxlabs -s '/sbin/nologin'");
    print "Installing LxCenter yum repository for updates\n";
    install_yum_repo($osversion);
    $packages = array("sendmail", "sendmail-cf", "sendmail-doc", "sendmail-devel", "exim", "vsftpd", "postfix", "vpopmail", "qmail", "lxphp", "lxzend", "pure-ftpd", "imap");
    $list = implode(" ", $packages);
    print "Removing packages {$list}...\n";
    foreach ($packages as $package) {
        exec("rpm -e --nodeps {$package} > /dev/null 2>&1");
    }
    $packages = array("php-mbstring", "php-mysql", "which", "gcc-c++", "php-imap", "php-pear", "php-devel", "lxlighttpd", "httpd", "mod_ssl", "zip", "unzip", "lxphp", "lxzend", "mysql", "mysql-server", "curl", "autoconf", "automake", "libtool", "bogofilter", "gcc", "cpp", "openssl", "pure-ftpd", "yum-protectbase");
    $list = implode(" ", $packages);
    while (true) {
        print "Installing packages {$list}...\n";
        system("PATH=\$PATH:/usr/sbin yum -y install {$list}", $return_value);
        if (file_exists("/usr/local/lxlabs/ext/php/php")) {
            break;
        } else {
            print "Yum Gave Error... Trying Again...\n";
        }
    }
    print "Prepare installation directory\n";
    system("mkdir -p /usr/local/lxlabs/kloxo");
    chdir("/usr/local/lxlabs/kloxo");
    system("mkdir -p /usr/local/lxlabs/kloxo/log");
    @unlink("kloxo-current.zip");
    print "Downloading latest Kloxo release\n";
    system("wget " . $downloadserver . "download/kloxo/production/kloxo/kloxo-current.zip");
    print "\n\nInstalling Kloxo.....\n\n";
    system("unzip -oq kloxo-current.zip", $return);
    if ($return) {
        print "Unzipping the core Failed.. Most likely it is corrupted. Report it at http://forum.lxcenter.org/\n";
        exit;
    }
    unlink("kloxo-current.zip");
    system("chown -R lxlabs:lxlabs /usr/local/lxlabs/");
    chdir("/usr/local/lxlabs/kloxo/httpdocs/");
    system("service mysqld start");
    if ($installtype !== 'slave') {
        check_default_mysql($dbroot, $dbpass);
    }
    $mypass = password_gen();
    print "Prepare defaults and configurations...\n";
    system("/usr/local/lxlabs/ext/php/php {$dir_name}/installall.php");
    our_file_put_contents("/etc/sysconfig/spamassassin", "SPAMDOPTIONS=\" -v -d -p 783 -u lxpopuser\"");
    print "Creating Vpopmail database...\n";
    system("sh {$dir_name}/vpop.sh {$dbroot} \"{$dbpass}\" lxpopuser {$mypass}");
    system("chmod -R 755 /var/log/httpd/");
    system("chmod -R 755 /var/log/httpd/fpcgisock >/dev/null 2>&1");
    system("mkdir -p /var/log/kloxo/");
    system("mkdir -p /var/log/news");
    system("ln -sf /var/qmail/bin/sendmail /usr/sbin/sendmail");
    system("ln -sf /var/qmail/bin/sendmail /usr/lib/sendmail");
    system("echo `hostname` > /var/qmail/control/me");
    system("service qmail restart >/dev/null 2>&1 &");
//.........这里部分代码省略.........
开发者ID:zseand,项目名称:kloxo,代码行数:101,代码来源:lxins.php


示例20: backup_main

function backup_main()
{
    global $argc, $argv;
    global $gbl, $login, $ghtml;
    $gbl->__restore_flag = true;
    if ($argc === 1) {
        print "Usage: {$argv['0']} --restore/--list --accounts='domain-<domain1.com>,client-<client1>,domain-<domain2.com>' <backup-file> [--switchserverlist='oldserver1:newserver1,oldserver2:newserver2']\n Use --accounts=all to restore everything.\n";
        exit;
    }
    initProgram("admin");
    $object = $login;
    $opt = parse_opt($argv);
    if (isset($opt['class']) && isset($opt['name'])) {
        $object = new $opt['class'](null, null, $opt['name']);
        $object->get();
        if ($object->dbaction === 'add') {
            log_error("{$opt['class']} doesnt exist");
            print "{$opt['class']} doesnt exist\n";
            exit;
        }
    }
    $class = $opt['class'];
    $name = $opt['name'];
    if (lx_core_lock("{$class}-{$name}.restore")) {
        print "Another Restore for the same class is happening..\n";
        exit;
    }
    $backup = $object->getObject('lxbackup');
    if (isset($opt['switchserverlist'])) {
        $sq = new Sqlite(null, "pserver");
        $serverlist = $sq->getTable();
        $serverlist = get_namelist_from_arraylist($serverlist);
        $server = $opt['switchserverlist'];
        $list = explode(",", $server);
        foreach ($list as $l) {
            if (!$l) {
                continue;
            }
            $q = explode(":", $l);
            $rlist[$q[0]] = $q[1];
            if (!array_search_bool($q[1], $serverlist)) {
                print "The server {$q[1]} doesn't exist in the server system here\n";
                exit;
            }
        }
        $param['switchserverlist'] = $rlist;
        dprint("\n");
    } else {
        $param['switchserverlist'] = null;
    }
    /*
    	if (!testAllServersWithMessage()) {
    		$backup->restorestage = "Failed due to: could not connect to slave servers";
    		clearLxbackup($backup);
    		exit;
    	}
    */
    $file = $opt['final'];
    //$param = get_variable($opt);
    if (isset($opt['list'])) {
        $gbl->__var_list_flag = true;
        $param['_accountselect'] = null;
    } else {
        if (isset($opt['restore'])) {
            $gbl->__var_list_flag = false;
            if (!isset($opt['accounts'])) {
                print "Restore option needs accounts that are to be restored. --accounts='domain-domain.com,client:clientname'... Use --list to find out all the domain/clients in the backup archive.\n";
                clearLxbackup($backup);
                exit;
            }
            $account = $opt['accounts'];
            //$account = str_replace(":", "_s_vv_p_", $account);
            $account = str_replace(":", "-", $account);
            $accountlist = explode(",", $account);
            $param['_accountselect'] = $accountlist;
        } else {
            print "Usage: {$argv['0']} <--list/--restore --accounts=> <filename>\n";
            clearLxbackup($backup);
            exit;
        }
    }
    if (isset($opt['priority']) && $opt['priority'] === 'low') {
        sleep(20);
    }
    dprintr($param);
    //dprint($file);
    try {
        $backup->doUpdateRestore($file, $param);
        $backup->restorestage = 'done';
    } catch (exception $e) {
        log_error("Restore Failed. Reason: {$e->__full_message} \n");
        print "Restore Failed. Reason: {$e->__full_message} \n";
        $mess = $e->__full_message;
        mail($object->contactemail, "Restore Failed..", "Restore Failed for {$object->nname} with the Message {$mess}");
        $backup->restorestage = "Restore failed due to {$mess}";
    }
    clearLxbackup($backup);
}
开发者ID:lonelywoolf,项目名称:hypervm,代码行数:98,代码来源:restore.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP parse_options函数代码示例发布时间:2022-05-15
下一篇:
PHP parse_navbar函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap