示例#1
0
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='******'");
    mysqli_query($dblink, "START SLAVE");
    lxfile_touch("../etc/secondary_master");
    lxfile_touch("../etc/running_secondary");
}
示例#2
0
 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));
     }
 }
示例#3
0
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;
}
示例#4
0
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";
}
示例#5
0
function lxinstall_main()
{
    global $argv;
    $opt = parse_opt($argv);
    $package = $opt['package-name'];
    lxinstall_package($package);
}
示例#6
0
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");
}
示例#7
0
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");
}
示例#8
0
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();
    }
}
示例#9
0
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 = '******';
    }
    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();
}
示例#10
0
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();
    }
}
示例#11
0
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 = '******';
    }
    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();
}
示例#12
0
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);
    }
}
示例#13
0
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();
}
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();
}
示例#15
0
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}");
}
示例#16
0
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;
}
示例#17
0
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";
}
示例#18
0
<?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;
示例#19
0
文件: lxins.php 项目: zseand/kloxo
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'] : "******";
    $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 &");
    system("service courier-imap restart >/dev/null 2>&1 &");
    $dbfile = "/home/kloxo/httpd/webmail/horde/scripts/sql/create.mysql.sql";
    if (file_exists($dbfile)) {
        if ($dbpass == "") {
            system("mysql -u {$dbroot}  <{$dbfile}");
        } else {
            system("mysql -u {$dbroot} -p{$dbpass} <{$dbfile}");
        }
    }
    system("mkdir -p /home/kloxo/httpd");
    chdir("/home/kloxo/httpd");
    @unlink("skeleton-disable.zip");
    system("chown -R lxlabs:lxlabs /home/kloxo/httpd");
    system("/etc/init.d/kloxo restart >/dev/null 2>&1 &");
    chdir("/usr/local/lxlabs/kloxo/httpdocs/");
    system("/usr/local/lxlabs/ext/php/php /usr/local/lxlabs/kloxo/bin/install/create.php --install-type={$installtype} --db-rootuser={$dbroot} --db-rootpassword={$dbpass}");
    system("/usr/local/lxlabs/ext/php/php /usr/local/lxlabs/kloxo/bin/misc/secure-webmail-mysql.phps");
    system("/bin/rm /usr/local/lxlabs/kloxo/bin/misc/secure-webmail-mysql.phps");
    system("/script/centos5-postpostupgrade");
    if ($installappinst) {
        system("/script/installapp-update");
        // First run (gets installappdata)
        system("/script/installapp-update");
        // Second run (gets applications)
    }
    print "Congratulations. Kloxo has been installed succesfully on your server as {$installtype} \n";
    if ($installtype === 'master') {
        print "You can connect to the server at https://<ip-address>:7777 or http://<ip-address>:7778\n";
        print "Please note that first is secure ssl connection, while the second is normal one.\n";
        print "The login and password are 'admin' 'admin'. After Logging in, you will have to change your password to something more secure\n";
        print "We hope you will find managing your hosting with Kloxo refreshingly pleasurable, and also we wish you all the success on your hosting venture\n";
        print "Thanks for choosing Kloxo to manage your hosting, and allowing us to be of service\n";
    } else {
        print "You should open the port 7779 on this server, since this is used for the communication between master and slave\n";
        print "To access this slave, to go admin->servers->add server, give the ip/machine name of this server. The password is 'admin'. The slave will appear in the list of slaves, and you can access it just like you access localhost\n\n";
    }
}
示例#20
0
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);
}
示例#21
0
<?php

include_once "htmllib/lib/include.php";
initProgram('admin');
$login->loadAllObjects('client');
$list = $login->getList('client');
$par = parse_opt($argv);
$newip = null;
if (isset($par['oldip'])) {
    $oldip = $par['oldip'];
}
if (isset($par['newip'])) {
    $newip = $par['newip'];
}
foreach ($list as $c) {
    $dlist = $c->getList('domain');
    foreach ($dlist as $l) {
        $web = $l->getObject('web');
        $web->setUpdateSubaction('full_update');
        if ($newip && $oldip) {
            $web->ipaddress = $newip;
        }
        $web->was();
        $dns = $l->getObject('dns');
        $dns->setUpdateSubaction('full_update');
        if ($newip && $oldip) {
            foreach ($dns->dns_record_a as $drec) {
                if ($drec->ttype !== 'a') {
                    continue;
                }
                if ($drec->param === $oldip) {
示例#22
0
function monitor_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv;
    global $global_ip_array;
    global $global_remoteserver;
    global $global_remoteport;
    error_reporting(E_ALL);
    $list = parse_opt($argv);
    if (isset($list['data-server'])) {
        $global_remoteserver = $list['data-server'];
        $global_remoteport = "8888";
    } else {
        $global_remoteserver = "localhost";
        $global_remoteport = "5558";
    }
    if (false) {
        if (function_exists("posix_getpwnam")) {
            if (!isset($list['switch-user'])) {
                print "Needs a non-privileged user to be suplied as --switch-user=<user>... Using lxlabs\n";
                $list['switch-user'] = '******';
            }
            $pw = posix_getpwnam($list['switch-user']);
            if (!$pw) {
                print "User {$list['switch-user']} doesnt exist. Please create it\n\n\n\n";
                exit;
            }
            posix_setuid($pw['uid']);
            posix_setgid($pw['gid']);
        }
    }
    $sgbl->thisserver = get_my_name();
    $list = get_data_from_server();
    if (!$list) {
        print "No list from the server...\n";
    }
    dprintr($list);
    getDnsesFirst($list);
    $oldserverhistlist = null;
    $maincount = 0;
    while (1) {
        $maincount++;
        $serverhistlist = null;
        $sendserverhistlist = null;
        $startmaintime = time();
        foreach ($list as $l) {
            $ports = $l['monitorport_l'];
            $porthistlist = null;
            foreach ($ports as $p) {
                if (isset($portmonlist[$l['nname']][$p['nname']][2])) {
                    print "Socket Already exists... \n";
                    socket_close($portmonlist[$l['nname']][$p['nname']][2]);
                }
                $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
                socket_set_nonblock($socket);
                $portmonlist[$l['nname']][$p['nname']] = array($l['servername'], $p['portnumber'], $socket);
            }
        }
        $serverhistlist = null;
        dprintr($portmonlist);
        do_monitor_list($portmonlist, $serverhistlist);
        $portmonlist = prepare_error_portmonlist($serverhistlist);
        dprintr("Second try\n\n");
        dprintr($portmonlist);
        sleep(1);
        do_monitor_list($portmonlist, $serverhistlist);
        $endmaintime = time();
        if ($oldserverhistlist) {
            foreach ($serverhistlist as $s => $slist) {
                foreach ($slist as $p => $plist) {
                    if (!isset($oldserverhistlist[$s][$p])) {
                        $sendserverhistlist[$s][$p] = $serverhistlist[$s][$p];
                        continue;
                    }
                    if ($serverhistlist[$s][$p]['portstatus'] !== $oldserverhistlist[$s][$p]['portstatus']) {
                        $sendserverhistlist[$s][$p] = $serverhistlist[$s][$p];
                    }
                }
            }
        } else {
            $sendserverhistlist = $serverhistlist;
        }
        $oldserverhistlist = $serverhistlist;
        if ($sendserverhistlist) {
            dprint("Sending Data\n");
            //print_r($sendserverhistlist);
            dprintr($sendserverhistlist);
            send_data_to_server($sendserverhistlist);
        }
        $timeleft = 60 - $endmaintime + $startmaintime;
        if ($timeleft > 0) {
            //print("Sleep for $timeleft\n");
            sleep($timeleft);
        } else {
            //print("No sleep for $timeleft\n");
        }
        if ($maincount === 10) {
            $maincount = 1;
            if ($global_failure) {
                //print("Sending Data\n");
                //print($serverhistlist);
                send_data_to_server($serverhistlist);
            }
            $list = get_data_from_server();
            send_alive_info();
            //print("Getting again from server\n");
            //$oldserverhistlist = null;
            //print_r($list);
            getDnsesFirst($list);
        }
    }
}
示例#23
0
function lxins_main()
{
    global $argv, $downloadserver;
    $opt = parse_opt($argv);
    $dir_name = dirname(__FILE__);
    $installtype = $opt['install-type'];
    $installversion = isset($opt['version']) ? $opt['version'] : null;
    $dbroot = "root";
    $dbpass = "";
    $osversion = find_os_version();
    $arch = `arch`;
    $arch = trim($arch);
    //--- Create temporary flags for install
    system("mkdir -p /var/cache/kloxo/");
    system("echo 1 > /var/cache/kloxo/kloxo-install-firsttime.flg");
    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;
        //--- Temporary flag so InstallApp won't be installed
        system("echo 1 > /var/cache/kloxo/kloxo-install-disableinstallapp.flg");
    } 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";
            if (get_yes_no("Try again?") == 'n') {
                print "- EXIT: Fix the problem and install Kloxo again.\n";
                exit;
            }
        }
    }
    print "Prepare installation directory\n";
    system("mkdir -p /usr/local/lxlabs/kloxo");
    if ($installversion) {
        if (substr($installversion, 0, 4) == '6.0.') {
            print "\n*** Need additional files installing {$installversion} (less then 6.1.0)***\n";
            print "      Run 'sh /script/kloxo-installer.sh' (without argument)\n\n";
            exit;
        }
        chdir("/usr/local/lxlabs/kloxo");
        system("mkdir -p /usr/local/lxlabs/kloxo/log");
        @unlink("/usr/local/lxlabs/kloxo/kloxo-current.zip");
        print "Downloading Kloxo {$installversion} release\n";
        system("wget {$downloadserver}download/kloxo/production/kloxo/kloxo-{$installversion}.zip");
        system("mv -f ./kloxo-{$installversion}.zip ./kloxo-current.zip");
    } else {
        if (file_exists("../kloxo-current.zip")) {
            //--- Install from local file if exists
            @unlink("/usr/local/lxlabs/kloxo/kloxo-current.zip");
            print "Local copying Kloxo release\n";
            system("mkdir -p /var/cache/kloxo");
            system("cp -rf ../kloxo-current.zip /usr/local/lxlabs/kloxo");
            //--- The first step - Remove packages
            system("rm -f /var/cache/kloxo/kloxo-thirdparty*.zip");
            system("rm -f /var/cache/kloxo/lxawstats*.tar.gz");
            system("rm -f /var/cache/kloxo/lxwebmail*.tar.gz");
            system("rm -f /var/cache/kloxo/kloxophpsixfour*.tar.gz");
            system("rm -f /var/cache/kloxo/kloxophp*.tar.gz");
            system("rm -f /var/cache/kloxo/*-version");
            //--- The second step - copy from packer script if exist
            system("cp -rf ../kloxo-thirdparty*.zip /var/cache/kloxo");
            system("cp -rf ../lxawstats*.tar.gz /var/cache/kloxo");
            system("cp -rf ../lxwebmail*.tar.gz /var/cache/kloxo");
            system("cp -rf ../kloxo-thirdparty-version /var/cache/kloxo");
            system("cp -rf ../lxawstats-version /var/cache/kloxo");
            system("cp -rf ../lxwebmail-version /var/cache/kloxo");
            if (file_exists("/usr/lib64")) {
                if (!is_link("/usr/lib/kloxophp")) {
                    system("rm -rf /usr/lib/kloxophp");
                }
                system("cp -rf ../kloxophpsixfour*.tar.gz /var/cache/kloxo");
                system("cp -rf ../kloxophpsixfour-version /var/cache/kloxo");
                system("mkdir -p /usr/lib64/kloxophp");
                system("ln -s /usr/lib64/kloxophp /usr/lib/kloxophp");
                system("mkdir -p /usr/lib64/php");
                system("ln -s /usr/lib64/php /usr/lib/php");
                system("mkdir -p /usr/lib64/httpd");
                system("ln -s /usr/lib64/httpd /usr/lib/httpd");
                system("mkdir -p /usr/lib64/lighttpd");
                system("ln -s /usr/lib64/lighttpd /usr/lib/lighttpd");
            } else {
                //--- Needs version checks in the future
                system("rename ../kloxophpsixfour ../_kloxophpsixfour ../kloxophpsixfour*");
                system("cp -rf ../kloxophp*.tar.gz /var/cache/kloxo");
                system("rename ../_kloxophpsixfour ../kloxophpsixfour ../_kloxophpsixfour*");
                system("cp -rf ../kloxophp-version /var/cache/kloxo");
            }
            chdir("/usr/local/lxlabs/kloxo");
            system("mkdir -p /usr/local/lxlabs/kloxo/log");
        } else {
            chdir("/usr/local/lxlabs/kloxo");
            system("mkdir -p /usr/local/lxlabs/kloxo/log");
            @unlink("/usr/local/lxlabs/kloxo/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";
    install_main();
    file_put_contents("/etc/sysconfig/spamassassin", "SPAMDOPTIONS=\" -v -d -p 783 -u lxpopuser\"");
    print "\nCreating Vpopmail database...\n";
    system("sh {$dir_name}/kloxo-linux/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 &");
    system("service courier-imap restart >/dev/null 2>&1 &");
    print "Prepare /home/kloxo/httpd...\n";
    system("mkdir -p /home/kloxo/httpd");
    chdir("/home/kloxo/httpd");
    @unlink("skeleton-disable.zip");
    system("chown -R lxlabs:lxlabs /home/kloxo/httpd");
    system("/etc/init.d/kloxo restart >/dev/null 2>&1 &");
    chdir("/usr/local/lxlabs/kloxo/httpdocs/");
    system("/usr/local/lxlabs/ext/php/php /usr/local/lxlabs/kloxo/bin/install/create.php --install-type={$installtype} --db-rootuser={$dbroot} --db-rootpassword={$dbpass}");
    if ($installappinst) {
        print "Install InstallApp...\n";
        system("/script/installapp-update");
        // First run (gets installappdata)
        system("/script/installapp-update");
        // Second run (gets applications)
    }
    //--- Remove all temporary flags because the end of install
    print "\nRemove Kloxo install flags...\n";
    system("rm -rf /var/cache/kloxo/*-version");
    system("rm -rf /var/cache/kloxo/kloxo-install-*.flg");
    //--- Prevent mysql socket problem (especially on 64bit system)
    if (!file_exists("/var/lib/mysql/mysql.sock")) {
        print "Create mysql.sock...\n";
        system("/etc/init.d/mysqld stop");
        system("mksock /var/lib/mysql/mysql.sock");
        system("/etc/init.d/mysqld start");
    }
    //--- Prevent for Mysql not start after reboot for fresh kloxo slave install
    print "Setting Mysql for always running after reboot and restart now...\n";
    system("chkconfig mysqld on");
    system("service mysqld restart");
    //--- Fix for old thirdparty version
    if (!file_exists("/usr/local/lxlabs/kloxo/httpdocs/thirdparty")) {
        system("cp -rf /var/cache/kloxo/kloxo-thirdparty*.zip /usr/local/lxlabs/kloxo");
        system("cd /usr/local/lxlabs/kloxo; unzip -oq kloxo-thirdparty*.zip");
        system("chown -R lxlabs:lxlabs /usr/local/lxlabs/kloxo/httpdocs/thirdparty");
        system("chown -R lxlabs:lxlabs /usr/local/lxlabs/kloxo/httpdocs/htmllib");
        system("rm -f /usr/local/lxlabs/kloxo/kloxo-thirdparty*.zip");
    }
    //--- Set ownership for Kloxo httpdocs dir
    system("chown -R lxlabs:lxlabs /usr/local/lxlabs/kloxo/httpdocs");
    print "\nCongratulations. Kloxo has been installed succesfully on your server as {$installtype}\n\n";
    if ($installtype === 'master') {
        print "You can connect to the server at:\n";
        print "\thttps://<ip-address>:7777 - secure ssl connection, or\n";
        print "\thttp://<ip-address>:7778 - normal one.\n\n";
        print "The login and password are 'admin' 'admin'. After Logging in, you will have to\n";
        print "change your password to something more secure\n\n";
        print "We hope you will find managing your hosting with Kloxo\n";
        print "refreshingly pleasurable, and also we wish you all the success\n";
        print "on your hosting venture\n\n";
        print "Thanks for choosing Kloxo to manage your hosting, and allowing us to be of\n";
        print "service\n";
    } else {
        print "You should open the port 7779 on this server, since this is used for\n";
        print "the communication between master and slave\n\n";
        print "To access this slave, to go admin->servers->add server,\n";
        print "give the ip/machine name of this server. The password is 'admin'.\n\n";
        print "The slave will appear in the list of slaves, and you can access it\n";
        print "just like you access localhost\n\n";
    }
    print "\n";
    print "---------------------------------------------\n";
}
示例#24
0
<?php

include_once "htmllib/lib/displayinclude.php";
$nonsslhash = "#";
$sslport = $sgbl->__var_prog_ssl_port;
$nonsslport = $sgbl->__var_prog_port;
$list = parse_opt($argv);
if (!isset($list['default-port']) && !lxfile_exists("__path_slave_db")) {
    initProgram('admin');
    $gen = $login->getObject('general')->portconfig_b;
    if ($gen) {
        if ($gen->isOn('nonsslportdisable_flag')) {
            $nonsslhash = "";
        }
        if ($gen->sslport) {
            $sslport = $gen->sslport;
        }
        if ($gen->nonsslport) {
            $nonsslport = $gen->nonsslport;
        }
    }
}
$list = lfile("htmllib/filecore/lighttpd.conf");
$ret = lxshell_return("__path_php_path", "../bin/common/misc/checktotalmemory.php");
if ($ret === 15) {
    $user = "******";
} else {
    $user = "******"lxlabs\"";
}
$phpcgi_num = 1;
$out = lxshell_output("/usr/local/lxlabs/ext/php/bin/php_cgi", "-v");
示例#25
0
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');
    }
    log_cleanup("*** Executing Update (cleanup) - BEGIN ***");
    //
    // Check for lxlabs yum repo file and if exists
    // Change to lxcenter repo file
    //
    if (lxfile_exists("/etc/yum.repos.d/lxlabs.repo")) {
        log_cleanup("- Deleting old lxlabs yum repo");
        lxfile_mv("/etc/yum.repos.d/lxlabs.repo", "/etc/yum.repos.d/lxlabs.repo.lxsave");
        exec("rm -f /etc/yum.repos.d/lxlabs.repo");
        log_cleanup("- Removed lxlabs.repo");
        log_cleanup("- Installing lxcenter.repo");
        exec("wget -O /etc/yum.repos.d/lxcenter.repo http://download.lxcenter.org/lxcenter.repo");
        log_cleanup("- Installing yum-protectbase plugin");
        exec("yum install -y -q yum-protectbase");
    }
    // Fix #388 - phpMyAdmin config.inc.php permission
    $correct_perm = "0644";
    $check_perm = substr(decoct(fileperms("/usr/local/lxlabs/{$program}/httpdocs/thirdparty/phpMyAdmin/config.inc.php")), 2);
    if ($check_perm != $correct_perm) {
        lxfile_unix_chmod("/usr/local/lxlabs/{$program}/httpdocs/thirdparty/phpMyAdmin/config.inc.php", "0644");
    }
    //
    if (lxfile_exists(".svn")) {
        log_cleanup("- SVN Found... Exiting");
        exit;
    }
    if ($opt['type'] === 'master') {
        $sgbl->slave = false;
        if (!is_secondary_master()) {
            updateDatabaseProperly();
            fixDataBaseIssues();
            doUpdates();
            lxshell_return("__path_php_path", "../bin/common/driverload.php");
        }
        update_all_slave();
        cp_dbfile();
    } else {
        $sgbl->slave = true;
    }
    if (!is_secondary_master()) {
        updatecleanup();
    }
    if ($opt['type'] === 'master') {
        lxfile_touch("__path_program_start_vps_flag");
    }
    // issue #716 -- [beta] Unresolved dependency on Apache version
    // --- remove httpd-itk rpm (from webtatic.repo or others) because may conflict with
    // httpd 2.2.21 that include mpm itk beside mpm worker and event
    exec("rpm -q httpd-itk | grep -i 'not installed'", $out, $ret);
    // --- not work with !$ret
    if ($ret !== 0) {
        log_cleanup("Remove httpd-itk rpm package");
        log_cleanup("- Remove httpd-itk");
        exec("rpm -e httpd-itk --nodeps");
        exec("rpm -q httpd | grep -i 'not installed'", $out2, $ret2);
        if ($ret2 === 0) {
            log_cleanup("- Reinstall httpd");
            exec("yum reinstall httpd -y");
        }
    }
    // MR -- mysql not start after kloxo slave install
    log_cleanup("Preparing MySQL service");
    log_cleanup("- MySQL activated");
    exec("chkconfig mysqld on");
    log_cleanup("- MySQL restarted");
    exec("service mysqld restart");
    // MR -- importance for update from 6.1.6 or previous where change apache/lighttpd structure
    // or others for next version
    $slist = array("httpd*", "lighttpd*", "bind*", "djbdns*", "pure-ftpd*", "php*", "vpopmail", "courier-imap-toaster", "courier-authlib-toaster", "qmail", "safecat", "spamassassin", "bogofilter", "ezmlm-toaster", "autorespond-toaster", "clamav-toaster");
    setUpdateServices($slist);
    // MR -- use this trick for qmail non-daemontools based
    log_cleanup("Preparing some services again");
    log_cleanup("- courier-imap enabled and restart queue");
    exec("chkconfig courier-imap on");
    createRestartFile("courier-imap");
    log_cleanup("- qmail enabled and restart queue");
    exec("chkconfig qmail on");
    createRestartFile("qmail");
    $fixapps = array("dns", "web", "php", "mail", "ftpuser", "vpop");
    setUpdateConfigWithVersionCheck($fixapps, $opt['type']);
    // --- for anticipate change xinetd listing
    exec("service xinetd restart");
}
示例#26
0
function lxins_main()
{
    global $argv;
    $opt = parse_opt($argv);
    $installtype = $opt['install-type'];
    $highmem = false;
    if (isset($opt['has-highmem'])) {
        $highmem = true;
    }
    if (!isset($opt['virtualization-type'])) {
        print "Need virtualization type --virtualization-type=xen/openvz/NONE\n";
        exit;
    } else {
        $virtualization = $opt['virtualization-type'];
    }
    $skipostemplate = false;
    if (isset($opt['skip-ostemplate'])) {
        $skipostemplate = true;
    }
    if (array_search($virtualization, array("xen", "openvz", "NONE")) === false) {
        print "Only xen/openvz/NONE are curently supported\n";
        exit;
    }
    $dbroot = isset($opt['db-rootuser']) ? $opt['db-rootuser'] : "******";
    $dbpass = isset($opt['db-rootpassword']) ? $opt['db-rootpassword'] : "";
    $osversion = find_os_version();
    if (file_exists("/usr/local/lxlabs/hypervm")) {
        print "HyperVM is installed do you wish to continue?(No/Yes):\n";
        flush();
        $stdin = fopen('php://stdin', 'r');
        $argq = fread($stdin, 5);
        $arg = trim($argq);
        if (!($arg == 'y' || $arg == 'yes' || $arg == 'Yes' || $arg == 'Y' || $arg == 'YES')) {
            print "Exiting.....\n";
            exit;
        }
    }
    if ($virtualization === 'xen') {
        if (!char_search_beg($osversion, "centos-6") && !char_search_beg($osversion, "centos-5") && !char_search_beg($osversion, "rhel-5") && !char_search_beg($osversion, "rhel-6")) {
            print "Xen is only supported on CentOS 5 and CentOS 6 distributions with HyperVM as management system\n";
            exit;
        }
    }
    if ($virtualization === 'openvz') {
        if (!char_search_beg($osversion, "centos-6") && !char_search_beg($osversion, "centos-5") && !char_search_beg($osversion, "rhel-5") && !char_search_beg($osversion, "rhel-6")) {
            print "OpenVZ is only supported on CentOS 5 and CentOS 6 distributions with HyperVM as management system\n";
            exit;
        }
    }
    //install_rhn_sources($osversion);
    install_yum_repo($osversion);
    exec("groupadd lxlabs");
    exec("useradd lxlabs -g lxlabs -s '/sbin/nologin'");
    // New since HyperVM 2.1.0 hypervm-core-php yum-plugin-replace
    $list = array("which", "lxlighttpd", "zip", "unzip", "hypervm-core-php", "curl", "yum-plugin-replace");
    /* Because our builder is on CentOS-6 the binaries like closeallinput are linked against libssl.so.10
     * To keep backward compatibility with RHEL-5 / CentOS-5 systems HyperVM-NG provides openssl10 package
     */
    if (char_search_beg($osversion, "centos-5") && char_search_beg($osversion, "rhel-5")) {
        $libssl = array("openssl10");
        $list = array_merge($list, $libssl);
    }
    if ($installtype !== 'slave') {
        $mysql = array("mysql", "mysql-server");
        $list = array_merge($list, $mysql);
    }
    // When installing development version, don't loop yum (.git found)
    if (!file_exists('/usr/local/lxlabs/.git')) {
        while (true) {
            run_package_installer($list);
            if (file_exists("/usr/local/lxlabs/ext/php/php")) {
                break;
            } else {
                // This can be a endless loop, needs another check!
                print "Yum Gave Error... Trying Again...\n";
            }
        }
    } else {
        run_package_installer($list);
    }
    if ($installtype !== 'slave') {
        check_default_mysql($dbroot, $dbpass);
    }
    $xenfailed = false;
    //  why is that?
    //	exec("killall wget");
    system("mkdir -p /usr/local/lxlabs/hypervm");
    chdir("/usr/local/lxlabs/hypervm");
    system("mkdir -p /usr/local/lxlabs/hypervm/log");
    // Prevents deleting the development package
    if (!file_exists('/usr/local/lxlabs/.git')) {
        @unlink("hypervm-current.zip");
    }
    if (file_exists('/usr/local/lxlabs/.git')) {
        echo 'Development GIT version found. Skipping download from HyperVM-NG.';
    } else {
        system("wget http://download.hypervm-ng.org/download/hypervm-ng/production/hypervm-current.zip");
    }
    system("unzip -oq hypervm-current.zip", $return);
    if ($return) {
        print "\nUnzipping the core Failed.. Most likely it is corrupted. Please contact the support personnel\n";
        exit;
    }
    unlink("hypervm-current.zip");
    system("chown -R lxlabs:lxlabs /usr/local/lxlabs/");
    $dir_name = dirname(__FILE__);
    fix_network_forwarding();
    system("mkdir -p /usr/local/lxlabs/hypervm/etc/");
    @unlink("/usr/local/lxlabs/hypervm/etc/install_xen");
    @unlink("/usr/local/lxlabs/hypervm/etc/install_openvz");
    touch("/usr/local/lxlabs/hypervm/etc/install_{$virtualization}");
    chdir("/usr/local/lxlabs/hypervm/httpdocs/");
    system("/bin/cp /usr/local/lxlabs/hypervm/httpdocs/htmllib/filecore/php.ini /usr/local/lxlabs/ext/php/etc/php.ini");
    system("/usr/local/lxlabs/ext/php/php ../bin/install/create.php --install-type={$installtype} --db-rootuser={$dbroot} --db-rootpassword={$dbpass}");
    system("chmod 755 /etc/init.d/hypervm");
    system("/sbin/chkconfig hypervm on");
    system("/sbin/chkconfig iptables off");
    $skiparg = null;
    if ($skipostemplate) {
        $skiparg = "--skipostemplate=true";
    }
    if ($virtualization === "NONE") {
        print "No Virtualization has been chosen. It is assumed that it is an existing installation\n";
    } else {
        print "Virtualization is {$virtualization}. Installing {$virtualization} Components\n";
    }
    //
    // call script to install base OS templates and OpenVZ repo
    //
    passthru("/usr/local/lxlabs/ext/php/php ../bin/install/virt-install.php --install-type={$installtype} --virtualization-type={$virtualization} {$skiparg}");
    echo smart_wordwrap("\n\n\nCongratulations!.\nHyperVM has been installed successfully on your server as {$installtype} \n");
    if ($installtype === 'master') {
        echo smart_wordwrap("\nYou can browse to the administration interface at:\n");
        echo smart_wordwrap("Secure - https://<ip-address>:8887\n");
        echo smart_wordwrap("Normal -  http://<ip-address>:8888\n\n");
        echo smart_wordwrap("The login and password are 'admin' 'admin'. After Logging in, you will have to change your password to something more secure.\n");
        echo smart_wordwrap("Thanks for choosing HyperVM to manage your Server, and allowing us to be of service.\n");
    } else {
        echo smart_wordwrap("You should open the port 8889 on this server, since this is used for the communication between master and slave.\n");
        echo smart_wordwrap("To access this slave, go admin->slaves->add slave, give the ip/machine name of this server. The password is 'admin'. The slave will appear in the list of slaves, and you can access it just like you access localhost.\n");
    }
    if ($virtualization === 'openvz') {
        echo smart_wordwrap("\n***There is one more step you have to do to make this complete. Open /etc/grub.conf, and change the 'default=1' line to 'default=0', and reboot this machine. You will be rebooted into the OpenVZ kernel and will able to manage VPSes from the HyperVM interface.\n");
    } else {
        if ($virtualization === 'xen') {
            echo smart_wordwrap("\n**** You will have to reboot for the XEN kernel to take effect. Once rebooted, you will able to manage XEN virtual machines using the HyperVM interface.\n");
        }
    }
    echo smart_wordwrap("\n\nExtra note:\n");
    echo smart_wordwrap("To install extra XEN and/or OpenVZ OS templates please run:\n\n");
    echo smart_wordwrap("sh /script/install-extra-ostemplates\n");
    echo smart_wordwrap("\nThese templates are left out the install process to speed up the HyperVM installation. By default only CentOS 5 and HostInBox(Kloxo) OS templates are installed.\n\n");
    echo smart_wordwrap("\n#!# Reboot your system to boot into the right kernel #!#\n\n");
    if (file_exists('/usr/local/lxlabs/.git')) {
        echo smart_wordwrap("Remember, you installed a Development version. Do not use it on production servers!\n\n");
    }
}
示例#27
0
function update_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    log_cleanup("*** Executing Update (upcp) - BEGIN ***");
    debug_for_backend();
    $login = new Client(null, null, 'upgrade');
    $DoUpdate = false;
    $opt = parse_opt($argv);
    log_cleanup("Kloxo Install/Update");
    if (lxfile_exists("/var/cache/kloxo/kloxo-install-firsttime.flg")) {
        log_cleanup("- Installing Kloxo packages at the first time");
        $DoUpdate = true;
    } else {
        log_cleanup("- Getting Version Info from the LxCenter download Server");
        $upversion = false;
        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';
        }
        if ($upversion) {
            log_cleanup("- Connecting LxCenter download server");
            do_upgrade($upversion);
            log_cleanup("- Upgrade Done. Cleanup....");
            flush();
        } else {
            $localversion = $sgbl->__ver_major_minor_release;
            log_cleanup("- Kloxo is the latest version ({$localversion})");
        }
        // Thirdparty/Webmail/AWstats checks
        $verWM = getVersionNumber(get_package_version("lxwebmail"));
        $verAW = getVersionNumber(get_package_version("lxawstats"));
        $ver = file_get_contents("http://download.lxcenter.org/download/thirdparty/kloxo-version.list");
        $verTP = getVersionNumber($ver);
        if (!lxfile_exists("/var/cache/kloxo/lxwebmail{$verWM}.tar.gz")) {
            $retWM = true;
        } else {
            $retWM = false;
        }
        if (!lxfile_exists("/var/cache/kloxo/lxawstats{$verAW}.tar.gz")) {
            $retAW = true;
        } else {
            $retAW = false;
        }
        if (!lxfile_exists("/var/cache/kloxo/kloxo-thirdparty.{$verTP}.zip")) {
            $retTP = true;
        } else {
            $retTP = false;
        }
        installThirdparty();
        installWebmail();
        installAwstats();
        // Run cleanups or not
        if ($retTP || $retWM || $retAW || $upversion) {
            $DoUpdate = true;
        } else {
            $DoUpdate = false;
        }
    }
    log_cleanup("*** Executing Update (upcp) - END ***");
    if ($DoUpdate == false) {
        log_cleanup("Run /script/cleanup if you want to fix/restore/(re)install non-working components.");
        exit;
    }
    if (is_running_secondary()) {
        log_cleanup("Not running Update cleanup, because this is running as secondary\n");
        exit;
    }
    //
    // Executing update/cleanup process
    //
    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}"));
}
示例#28
0
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}.livemigrate")) {
            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->getClass());
        $driverapp_new = $gbl->getSyncClass('localhost', $param['syncserver'], $object->getClass());
        $oldserver = $object->syncserver;
        $newserver = $param['syncserver'];
        if ($driverapp_new !== $driverapp_old) {
            throw new lxException("the_drivers_are_different_in_two_servers", '', '');
        }
        $actualserver = getFQDNforServer($newserver);
        setup_ssh_channel($oldserver, $newserver, $actualserver);
        $ssh_port = db_get_value("sshconfig", $newserver, "ssh_port");
        if (!$ssh_port) {
            $ssh_port = "22";
        }
        $res = rl_exec_get(null, $oldserver, "exec_vzmigrate", array($object->vpsid, $actualserver, $ssh_port));
        list($ret, $error) = $res;
        if ($ret !== 0) {
            throw new lxException("vzmigrate_failed_due_to:{$error}", '', '');
        }
        $object->olddeleteflag = 'done';
        $object->syncserver = $newserver;
        $object->username = null;
        $object->makeSureTheUserExists();
        $object->setUpdateSubaction();
        $object->write();
    } 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()}";
        $message = str_replace("'", "", $message);
        write_to_object($object, $message, $param['syncserver']);
        $fullmesage = "Switch of {$object->getClass()}:{$object->nname} to {$param['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->getClass()}:{$object->nname} to {$param['syncserver']}\n");
}
示例#29
0
function lxins_main()
{
    global $argv;
    $opt = parse_opt($argv);
    $installtype = $opt['install-type'];
    $highmem = false;
    if (isset($opt['has-highmem'])) {
        $highmem = true;
    }
    if (!isset($opt['virtualization-type'])) {
        print "Need virtualization type --virtualization-type=xen/openvz/NONE\n";
        exit;
    } else {
        $virtualization = $opt['virtualization-type'];
    }
    $skipostemplate = false;
    if (isset($opt['skip-ostemplate'])) {
        $skipostemplate = true;
    }
    if (array_search($virtualization, array("xen", "openvz", "NONE")) === false) {
        print "Only xen/openvz/NONE are curently supported\n";
        exit;
    }
    $dbroot = isset($opt['db-rootuser']) ? $opt['db-rootuser'] : "******";
    $dbpass = isset($opt['db-rootpassword']) ? $opt['db-rootpassword'] : "";
    if (!$dbpass) {
        //$dbpass = slave_get_db_pass("hypervm");
    }
    $osversion = find_os_version();
    if (file_exists("/usr/local/lxlabs/hypervm")) {
        print "HyperVM is installed do you wish to continue?(No/Yes):\n";
        flush();
        $stdin = fopen('php://stdin', 'r');
        $argq = fread($stdin, 5);
        $arg = trim($argq);
        if (!($arg == 'y' || $arg == 'yes' || $arg == 'Yes' || $arg == 'Y' || $arg == 'YES')) {
            print "Exiting.....\n";
            exit;
        }
    }
    if ($virtualization === 'xen') {
        if (!char_search_beg($osversion, "fedora-9") && !char_search_beg($osversion, "centos-5") && !char_search_beg($osversion, "rhel-5")) {
            print "Xen is only supported on Fedora 9 or CentOS 5\n";
            exit;
        }
    }
    if ($virtualization === 'openvz') {
        if (!char_search_beg($osversion, "centos") && !char_search_beg($osversion, "rhel")) {
            print "OpenVZ is only supported on CentOS 4/5, RHEL 4/5 distributions\n";
            exit;
        }
    }
    /*
    	$file = "http://download.lxlabs.com/download/update/$osversion/headers/header.info";
    	$cont = @file_get_contents($file);
    	if (!$cont) {
    		print("This OS is not suported at this moment.... Please contact our Support personnel\n");
    		exit;
    	}
    */
    //install_rhn_sources($osversion);
    install_yum_repo($osversion);
    exec("groupadd lxlabs");
    exec("useradd lxlabs -g lxlabs -s '/sbin/nologin'");
    $list = array("which", "lxlighttpd", "zip", "unzip", "lxphp", "lxzend", "curl");
    if ($installtype !== 'slave') {
        $mysql = array("mysql", "mysql-server", "mysqlclient*");
        $list = array_merge($list, $mysql);
    }
    while (true) {
        run_package_installer($list);
        if (file_exists("/usr/local/lxlabs/ext/php/php")) {
            break;
        } else {
            print "Yum Gave Error... Trying Again...\n";
        }
    }
    if ($installtype !== 'slave') {
        check_default_mysql($dbroot, $dbpass);
    }
    $xenfailed = false;
    exec("killall wget");
    system("mkdir -p /usr/local/lxlabs/hypervm");
    chdir("/usr/local/lxlabs/hypervm");
    system("mkdir -p /usr/local/lxlabs/hypervm/log");
    @unlink("hypervm-current.zip");
    if (file_exists('.git')) {
        echo 'Development GIT version found. Skipping download sources.';
    } else {
        system("wget http://download.lxcenter.org/download/hypervm/production/hypervm/hypervm-current.zip");
    }
    system("unzip -oq hypervm-current.zip", $return);
    if ($return) {
        print "Unzipping the core Failed.. Most likely it is corrupted. Please contact the support personnel\n";
        exit;
    }
    unlink("hypervm-current.zip");
    system("chown -R lxlabs:lxlabs /usr/local/lxlabs/");
    $dir_name = dirname(__FILE__);
    fix_network_forwarding();
    system("mkdir -p /usr/local/lxlabs/hypervm/etc/");
    @unlink("/usr/local/lxlabs/hypervm/etc/install_xen");
    @unlink("/usr/local/lxlabs/hypervm/etc/install_openvz");
    touch("/usr/local/lxlabs/hypervm/etc/install_{$virtualization}");
    chdir("/usr/local/lxlabs/hypervm/httpdocs/");
    system("/bin/cp /usr/local/lxlabs/hypervm/httpdocs/htmllib/filecore/php.ini /usr/local/lxlabs/ext/php/etc/php.ini");
    system("/usr/local/lxlabs/ext/php/php ../bin/install/create.php --install-type={$installtype} --db-rootuser={$dbroot} --db-rootpassword={$dbpass}");
    //@ unlink("/usr/local/lxlabs/lxadmin/bin/install/create.php");
    system("chmod 755 /etc/init.d/hypervm");
    system("/sbin/chkconfig hypervm on");
    system("/sbin/chkconfig iptables off");
    $skiparg = null;
    if ($skipostemplate) {
        $skiparg = "--skipostemplate=true";
    }
    if ($virtualization === "NONE") {
        print "No Virtualization has been chosen. It is assumed that it is an existing installation\n";
    } else {
        print "Virtualization is {$virtualization}. Installing {$virtualization} Components\n";
    }
    //
    // call script to install base OS templates and OpenVZ repo
    //
    passthru("/usr/local/lxlabs/ext/php/php ../bin/install/virt-install.php --install-type={$installtype} --virtualization-type={$virtualization} {$skiparg}");
    print "Congratuations. HyperVM has been installed succesfully on your server as {$installtype} \n";
    if ($installtype === 'master') {
        print "You can connect to the server at https://<ip-address>:8887 or http://<ip-address>:8888\n";
        print "Please note that first is secure ssl connection, while the second is normal one.\n";
        print "The login and password are 'admin' 'admin'. After Logging in, you will have to change your password to something more secure.\n";
        print "Thanks for choosing HyperVM to manage your Server, and allowing us to be of service.\n";
    } else {
        print "You should open the port 8889 on this server, since this is used for the communication between master and slave.\n";
        print "To access this slave, go admin->slaves->add slave, give the ip/machine name of this server. The password is 'admin'. The slave will appear in the list of slaves, and you can access it just like you access localhost.\n";
    }
    if ($virtualization === 'openvz') {
        print "\n***There is one more step you have to do to make this complete. Open /etc/grub.conf, and change the 'default=1' line to 'default=0', and reboot this machine. You will be rebooted into the OpenVZ kernel and will able to manage VPSes from the HyperVM interface.\n";
    } else {
        if ($virtualization === 'xen') {
            print "\n**** You will have to reboot for the XEN kernel to take effect. Once rebooted, you will able to manage XEN virtual machines using the HyperVM interface.\n";
        }
    }
    print "\n\nExtra note:\n";
    print "To install extra XEN and/or OpenVZ OS templates please run:\n\n";
    print "sh /script/install-extra-ostemplates\n";
    print "\nThese template are left out the install process to speed up the HyperVM installation. By default only CentOS 5 and HostInBox(Kloxo) OS templates are installed.";
}
示例#30
0
<?php

include "lib/include.php";
if ($argc === 1) {
    print "Usage: {$argv['0']} --admin-password= --count= --v-template_name= --basename=\n";
    print "Example {$argv['0']} --admin-password= --count=10 --v-template_name=gighost --basename=example\n";
    exit;
}
$opt = parse_opt($argv);
try {
    checkIfVariablesSet($opt, array('basename', 'count', 'admin-password'));
} catch (exception $e) {
    print $e->getMessage() . "\n";
    exit;
}
$base = $opt['basename'];
$count = $opt['count'];
$temp = $opt['v-template_name'];
$admin_passowrd = $opt['admin-password'];
for ($i = 1; $i <= $count; $i++) {
    $name = "{$base}{$i}.vm";
    $ip = "{$ipbase}.{$i}";
    print "Creating {$name} with ip {$ip} with password admin from template {$temp}\n";
    passthru("{$sgbl->__path_php_path}  ../bin/common/commandline.php --login-class=client --login-name=admin --login-password={$admin_passowrd} --class=vps --name={$name} --action=add --v-template_name={$temp} --v-password=admin", $return);
    if ($return) {
        print "Adding Failed\n";
        exit;
    }
}