Beispiel #1
0
function setMysqlOptimize($select, $database = null)
{
    global $gbl, $sgbl, $login, $ghtml;
    log_cleanup("Mysql Optimization");
    $database = $database ? $database : "_all_";
    $pass = slave_get_db_pass();
    if ($select === 'repair') {
        log_cleanup("- Repairing database");
        if ($database === '_all_') {
            system("mysqlcheck --user=root --password=\"{$pass}\" --repair --all-databases");
        } else {
            system("mysqlcheck --user=root --password=\"{$pass}\" --repair --databases {$dbname}");
        }
    } else {
        if ($select === 'optimize') {
            log_cleanup("- Compacting database");
            if ($database === '_all_') {
                system("mysqlcheck --user=root --password=\"{$pass}\" --optimize --all-databases");
            } else {
                system("mysqlcheck --user=root --password=\"{$pass}\" --optimize --databases {$dbname}");
            }
        }
    }
    log_cleanup("- MySQL Service restart");
    $ret = lxshell_return("service", "mysqld", "restart");
    if ($ret) {
        throw new lxexception('mysqld_restart_failed', 'parent');
    }
}
Beispiel #2
0
 function updateSwitchProgram($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if_demo_throw_exception('switchprog');
     $this->web_driver = $gbl->getSyncClass($this->__masterserver, $this->nname, 'web');
     $this->dns_driver = $gbl->getSyncClass($this->__masterserver, $this->nname, 'dns');
     $this->spam_driver = $gbl->getSyncClass($this->__masterserver, $this->nname, 'spam');
     $a['web'] = $this->web_driver;
     $a['dns'] = $this->dns_driver;
     $a['spam'] = $this->spam_driver;
     foreach ($param as $k => $v) {
         if ($this->{$k} === $v) {
             dprint("No change for {$k}: {$v}\n");
         } else {
             $class = strtilfirst($k, "_");
             $drstring = "{$class}_driver";
             rl_exec_get(null, $this->nname, array($class, 'switchDriver'), array($class, $this->{$drstring}, $v));
             changeDriver($this->nname, $class, $v);
             $fixc = $class;
             if ($class === 'spam') {
                 $fixc = "mmail";
             }
             lxshell_return("__path_php_path", "../bin/fix/fix{$fixc}.php", "--server={$this->nname}");
             $a[$class] = $v;
             rl_exec_get(null, $this->nname, 'slave_save_db', array('driver', $a));
         }
     }
 }
Beispiel #3
0
 static function installMe()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $ret = lxshell_return("yum", "-y", "install", "lighttpd", "lighttpd-fastcgi");
     if ($ret) {
         throw new lxexception('install_lighttpd_failed', 'parent');
     }
     lxshell_return("chkconfig", "lighttpd", "on");
     lxfile_mkdir("/etc/lighttpd/");
     //-- old structure
     lxfile_rm("/etc/lighttpd/conf/kloxo");
     //-- new structure
     $path = "/home/lighttpd/conf";
     $list = array("defaults", "domains", "redirects", "webmails", "wildcards", "exclusive");
     foreach ($list as $k => $l) {
         if (!lxfile_exists("{$path}/{$l}")) {
             lxfile_mkdir("{$path}/{$l}");
         }
     }
     lxfile_cp("/usr/local/lxlabs/kloxo/file/lighttpd/lighttpd.conf", "/etc/lighttpd/lighttpd.conf");
     $cver = "###version0-7###";
     $fver = file_get_contents("/etc/lighttpd/conf.d/~lxcenter.conf");
     if (stristr($fver, $cver) === FALSE) {
         lxfile_cp("/usr/local/lxlabs/kloxo/file/lighttpd/~lxcenter.conf", "/etc/lighttpd/conf.d/~lxcenter.conf");
     }
     lxfile_cp("../file/lighttpd/etc_init.d", "/etc/init.d/lighttpd");
     lxfile_unix_chmod("/etc/init.d/lighttpd", "0755");
     lxfile_unix_chmod("/etc/init.d/lighttpd", "0755");
     lxfile_mkdir("/home/kloxo/httpd/lighttpd");
     lxfile_unix_chown("/home/kloxo/httpd/lighttpd", "apache");
     createRestartFile("lighttpd");
 }
 function dbactionUpdate($subaction)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $dir = $this->main->__var_full_directory;
     $dir = expand_real_root($dir);
     switch ($subaction) {
         case "full_update":
             $pass = $this->main->realpass;
             lxshell_input("{$pass}\n{$pass}\n", "pure-pw", "passwd", $this->main->nname, "-m");
             lxshell_return("pure-pw", "usermod", $this->main->nname, "-d", $dir, "-m");
             $this->toggleStatus();
             $this->setQuota();
             break;
         case "password":
             $pass = $this->main->realpass;
             lxshell_input("{$pass}\n{$pass}\n", "pure-pw", "passwd", $this->main->nname, "-m");
             break;
         case "toggle_status":
             $this->toggleStatus();
             break;
         case "edit":
             lxshell_return("pure-pw", "usermod", $this->main->nname, "-d", $dir, "-m");
             $this->setQuota();
             break;
         case "changeowner":
             lxshell_return("pure-pw", "usermod", $this->main->nname, "-u", $this->main->__var_username, "-d", $dir, "-m");
             break;
     }
 }
Beispiel #5
0
 static function installMe()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $ret = lxshell_return("yum", "-y", "install", "httpd", "mod_ssl");
     if ($ret) {
         throw new lxexception('install_httpd_failed', 'parent');
     }
     lxshell_return("chkconfig", "httpd", "on");
     $cver = "###version0-6###";
     $fver = file_get_contents("/etc/httpd/conf.d/~lxcenter.conf");
     if (stristr($fver, $cver) === FALSE) {
         lxfile_cp("/usr/local/lxlabs/kloxo/file/apache/~lxcenter.conf", "/etc/httpd/conf.d/~lxcenter.conf");
     }
     lxfile_cp("/usr/local/lxlabs/kloxo/file/centos-5/httpd.conf", "/etc/httpd/conf/httpd.conf");
     // MR -- old structure
     lxfile_rm("/etc/httpd/conf/kloxo");
     lxfile_rm("/home/httpd/conf");
     // MR -- new structure
     $path = "/home/apache/conf";
     $list = array("defaults", "domains", "redirects", "webmails", "wildcards", "exclusive");
     foreach ($list as $k => $l) {
         if (!lxfile_exists("{$path}/{$l}")) {
             lxfile_mkdir("{$path}/{$l}");
         }
     }
     // MR -- some vps include /etc/httpd/conf.d/swtune.conf
     lxfile_rm("/etc/httpd/conf.d/swtune.conf");
     // issue #527
     lxfile_cp("../file/apache/etc_init.d", "/etc/init.d/httpd");
     lxshell_return("{$sgbl->__path_php_path}", "../bin/misc/installsuphp.php");
     createRestartFile("apache");
 }
 static function checkService($name)
 {
     $servicepath = "__path_real_etc_root/init.d";
     $ret = lxshell_return("{$servicepath}/{$name}", "status");
     $state = $ret ? "off" : "on";
     return $state;
 }
 static function getServiceDetails($list)
 {
     $ps = lxshell_output("ps", "ax");
     $run = Service__linux::getRunLevel();
     $rclist = lscandir_without_dot("__path_real_etc_root/rc{$run}.d/");
     foreach ($list as &$__l) {
         $__l['install_state'] = 'dull';
         $__l['state'] = 'off';
         $__l['boot_state'] = 'off';
         if (lxfile_exists("__path_real_etc_root/init.d/{$__l['servicename']}")) {
             $__l['install_state'] = 'on';
         } else {
             continue;
         }
         if (self::checkServiceInRc($rclist, $__l['servicename'])) {
             $__l['boot_state'] = 'on';
         }
         if ($__l['grepstring']) {
             if (preg_match("/[\\/ ]{$__l['grepstring']}/i", $ps)) {
                 $__l['state'] = 'on';
             }
         } else {
             $ret = lxshell_return("/etc/init.d/{$__l['servicename']}", "status");
             if ($ret) {
                 $__l['state'] = 'off';
             } else {
                 $__l['state'] = 'on';
             }
         }
     }
     return $list;
 }
 function dbactionUpdate($subaction)
 {
     if_demo_throw_exception('lxguard');
     $rmt = new Remote();
     $rmt->data['disablehit'] = $this->main->disablehit;
     lfile_put_serialize("__path_home_root/lxguard/config.info", $rmt);
     lxshell_return("__path_php_path", "../bin/common/lxguard.php");
 }
 function dosyncToSystemPost()
 {
     global $sgbl;
     $ret = lxshell_return("rndc", "reload");
     if ($ret) {
         createRestartFile("bind");
     }
 }
Beispiel #10
0
 static function doUpdate($list)
 {
     $cmd = self::getYumCommand();
     $file = fix_nname_to_be_variable($cmd);
     $file = "__path_program_root/cache/{$file}";
     lxshell_return("yum", "-y", "install", implode(" ", $list));
     lunlink($file);
 }
Beispiel #11
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");
}
 function updateWht()
 {
     $res = $this->main->__var_whitelist;
     $res = merge_array_object_not_deleted($res, $this->main);
     $list = get_namelist_from_arraylist($res, 'ipaddress');
     $rmt = new Remote();
     $rmt->data = $list;
     lfile_put_serialize("__path_home_root/lxguard/whitelist.info", $rmt);
     lxshell_return("__path_php_path", "../bin/common/lxguard.php");
 }
Beispiel #13
0
function create_dev()
{
    if (lxfile_exists("/sbin/udevd")) {
        lxfile_mv("/sbin/udevd", "/sbin/udevd.back");
    }
    lxshell_return('tar', '-C', '/dev', '-xzf', '../file/centos-5/vps-dev.tgz');
    lxshell_return('/sbin/MAKEDEV', 'pty');
    lxshell_return('/sbin/MAKEDEV', 'tty');
    lxshell_return('/sbin/MAKEDEV', 'loop');
    lxshell_return('/sbin/MAKEDEV', 'random');
    lxshell_return('/sbin/MAKEDEV', 'urandom');
}
Beispiel #14
0
 function shellModify()
 {
     global $gbl, $sgbl, $login, $ghtml;
     if_demo_throw_exception();
     $shell = fix_disabled($this->main->shell, $sgbl->__var_noaccess_shell);
     lxshell_return("usermod", "-s", $shell, $this->main->nname);
     if ($this->main->isOn('disable_system_flag')) {
         lxshell_return("usermod", "-L", $this->main->nname);
     } else {
         lxshell_return("usermod", "-U", $this->main->nname);
     }
 }
Beispiel #15
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();
}
Beispiel #16
0
function schedulebackup_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    $progname = $sgbl->__var_program_name;
    initProgram('admin');
    $login->loadAllBackups();
    $list = $login->lxbackup_l;
    foreach ($list as $l) {
        $l->backupstage = 'done';
        $l->setUpdateSubaction();
        $l->write();
        if ($l->parent_clname !== $login->getClName() && !$l->priv->isOn('backupschedule_flag')) {
            continue;
        }
        if ($l->getParentClass() === 'domain') {
            continue;
        }
        if (!$l->backupschedule_type) {
            continue;
        }
        if ($l->backupschedule_type === 'disabled') {
            continue;
        }
        if ($l->backupschedule_type === 'weekly' && date('D') !== 'Sun') {
            continue;
        }
        if ($l->backupschedule_type === 'monthly' && date('d') !== '01') {
            continue;
        }
        /*
        	try {
        		$param['backup_to_file_f'] = "$progname-scheduled";
        		$param['upload_to_ftp'] = $l->upload_to_ftp;
        		$backup = $l;
        		$object = $l->getParentO();
        		$backup->doupdateBackup($param);
        		$backup->backupstage = 'done';
        	} catch (exception $e) {
        		$mess = "{$e->__full_message}\n";
        		$backup->backupstage = "Failed due to: $mess";
        		lx_mail($progname, $object->contactemail, "Backup Failed..", "Backup Failed for $object->nname with the Message $mess");
        	}
        */
        $class = $l->getParentClass();
        $name = $l->getParentName();
        $fname = "{$progname}-scheduled";
        print "Scheduling for {$class} {$name}\n";
        lxshell_return("__path_php_path", "../bin/common/backup.php", "--class={$class}", "--name={$name}", "--v-backup_file_name={$fname}");
    }
}
 function dbactionAdd()
 {
     global $gbl, $sgbl, $login;
     if (if_demo()) {
         return;
     }
     $_filepath = "__path_home_root/lxguard/hostdeny.info";
     $result = $this->main->__var_hostlist;
     $result = merge_array_object_not_deleted($result, $this->main);
     $list = get_namelist_from_arraylist($result, 'hostname', 'hostname');
     dprintr($list);
     lfile_put_serialize($_filepath, $list);
     lxshell_return("__path_php_path", "../bin/common/lxguard.php");
 }
Beispiel #18
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();
}
 static function getAspnetVersion()
 {
     //print("\nI am here\n");
     //$r=exec("c:\regASPVer.vbs");
     $cm = "cmd /K CD C:\\Dir";
     lxshell_return("cmd", "/K", "cd", "c:\\dir");
     //print($r."\n");
     //$r = system('cscript.exe c:\regASPVer.vbs.vbs', $a);
     //cscript.exe regASPVer.vbs
     //regASPVer.vbs
     foreach ($a as $b) {
         $res['version'] = "aab";
         $res['sss'] = 'ab';
         $ret[] = $res;
     }
 }
 function dbactionUpdate($subaction)
 {
     switch ($subaction) {
         case "toggle_status":
             if ($this->main->isOn('status')) {
                 lxshell_return("update-rc.d", $this->main->servicename, 'defaults');
             } else {
                 lxshell_return("update-rc.d", "-f", $this->main->servicename, 'remove');
             }
             break;
         case "toggle_state":
             if ($this->main->isOn('state')) {
                 lxshell_return("__path_real_etc_root/init.d/{$this->main->servicename}", "start");
             } else {
                 lxshell_return("__path_real_etc_root/init.d/{$this->main->servicename}", "stop");
             }
             break;
     }
 }
 static function addform($parent, $class, $typetd = null)
 {
     $res = Dnsbase::getIpaddressList($parent);
     if (!$res) {
         lxshell_return("__path_php_path", "../bin/fixIpAddress.php");
     }
     $res = Dnsbase::getIpaddressList($parent);
     if (!$res) {
         throw new lxexception('no_ip_address', 'parent');
     }
     $vlist['nname'] = null;
     $vlist['webipaddress'] = array('s', $res);
     $vlist['mmailipaddress'] = array('s', $res);
     $vlist['nameserver_f'] = null;
     $vlist['secnameserver_f'] = null;
     $ret['action'] = 'add';
     $ret['variable'] = $vlist;
     return $ret;
 }
 static function readAuthorizedKey($username)
 {
     $p = os_get_home_dir($username);
     if ($p === '/tmp' && $username) {
         lxfile_mkdir("/home/{$username}");
         lxshell_return("usermod", "-d", "/home/{$username}", $username);
         lxfile_unix_chown_rec("/home/{$username}", "{$username}:{$username}");
         $p = "/home/{$username}";
     }
     if (!$p) {
         return;
     }
     $f = "{$p}/.ssh/authorized_keys";
     if (lxfile_exists("{$f}2")) {
         $s = lfile_get_contents("{$f}2");
         $s = "\n{$s}\n";
         lfile_put_contents($f, $s, FILE_APPEND);
         lunlink("{$f}2");
     }
     return lfile_get_contents($f);
 }
 static function findTotaltrafficUsage($list, $oldtime, $newtime)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!isset($oldtime)) {
         return null;
     }
     $file = '/var/log/lxiptraffic.log';
     $processedir = "/var/log/";
     $processfile = $file;
     lxshell_return("__path_php_path", "../bin/sisinfoc.php");
     foreach ($list as $d) {
         $tlist[$d->nname] = self::get_usage($processfile, $d->vpsid, $oldtime, $newtime);
     }
     self::iptables_delete();
     self::iptables_delete();
     self::iptables_create();
     $stat = stat($file);
     if ($stat['size'] >= 10 * 1024 * 1024) {
         lxfile_mv($file, getNotexistingFile($processedir, basename($file)));
     }
     return $tlist;
 }
Beispiel #24
0
 static function run_awstats($statsprog, $list)
 {
     global $gbl, $sgbl, $login, $ghtml;
     global $global_dontlogshell;
     log_log("run_stats", "In awstats");
     $global_dontlogshell = true;
     foreach ($list as $p) {
         log_log("run_stats", "In awstats for {$p->nname} {$statsprog}");
         if ($p->priv->isOn('awstats_flag')) {
             lxfile_mkdir("__path_httpd_root/{$p->nname}/webstats/");
             $name = $p->nname;
             web::createstatsConf($p->nname, $p->stats_username, $p->stats_password);
             if (is_disabled($statsprog)) {
                 continue;
             }
             log_log("run_stats", "Execing {$statsprog}");
             //system("rm /home/httpd/$p->nname/webstats/*");
             if ($statsprog === 'webalizer') {
                 print "webalizer: {$p->nname}\n";
                 lxshell_return("nice", "-n", "15", "webalizer", "-n", $p->nname, "-t", $p->nname, "-c", "__path_real_etc_root/webalizer/webalizer.{$p->nname}.conf");
             } else {
                 print "awstats: {$p->nname}\n";
                 putenv("GATEWAY_INTERFACE=");
                 //system("nice -n 15 perl /home/kloxo/httpd/awstats/wwwroot/cgi-bin/awstats.pl -update -config=$name > /tmp/test 2>&1");
                 lxshell_return("nice", "-n", "15", "perl", "__path_kloxo_httpd_root/awstats/wwwroot/cgi-bin/awstats.pl", "-update", "-config={$name}");
                 //lxshell_return("__path_kloxo_httpd_root/awstats/tools/awstats_buildstaticpages.pl", "-awstatsprog=$sgbl->__path_kloxo_httpd_root/awstats/wwwroot/cgi-bin/awstats.pl", "-dir=$sgbl->__path_httpd_root/$name/webstats/", "-config=$name");
                 //lxfile_cp("__path_httpd_root/$name/webstats/awstats.$name.html", "__path_httpd_root/$name/webstats/index.html");
             }
         }
     }
     /// Needed to get the domain list from the files in the /etc/awstats directory.
     /*	$list = lscandir_without_dot("__path_real_etc_root/awstats");
     	foreach($list as $l) {
     		$p = preg_replace("/awstats\.(.*)\.conf/", "$1", $l);
     		dprint($p);
     		dprint("\n");
     */
 }
Beispiel #25
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}");
}
 static function findTotaltrafficUsage($list, $oldtime, $newtime)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!isset($oldtime)) {
         return null;
     }
     $file = '/var/log/lxinterfacetraffic.log';
     $processedir = "/var/log/";
     $processfile = $file;
     lxshell_return("__path_php_path", "../bin/common/iptraffic.php");
     $globaliplist = null;
     foreach ($list as $d) {
         foreach ($d->viflist as $iface) {
             $tlist[$d->nname] = self::get_usage($processfile, $iface, $oldtime, $newtime);
             $globalifacelist[] = $iface;
         }
     }
     lfile_put_contents("__path_program_etc/xeninterface.list", implode("\n", $globalifacelist));
     $stat = stat($file);
     if ($stat['size'] >= 10 * 1024 * 1024) {
         lxfile_mv($file, getNotexistingFile($processedir, basename($file)));
     }
     return $tlist;
 }
Beispiel #27
0
 function throw_if_not_magick()
 {
     $ret = lxshell_return("rpm", "-q", "ImageMagick");
     if ($ret) {
         throw new lxexception('no_imagemagick', '');
     }
 }
Beispiel #28
0
    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");
$lightout = lxshell_output("/usr/local/lxlabs/ext/lxlighttpd/sbin/kloxo.httpd", "-v");
$php_st = null;
if (csa($lightout, "1.4.") && csa($out, "cgi-fcgi") && $sgbl->isKloxo() && $ret === 15) {
    $php_st .= "fastcgi.server  = (\".php\" => \n";
    $php_st .= "\t\t(( \"socket\" => \"/usr/local/lxlabs/{$sgbl->__var_program_name}/etc/php_socket.socket\",\n";
    $php_st .= "\t\t   \"bin-path\" => \"/usr/local/lxlabs/ext/php/bin/php_cgi\",\n";
    $php_st .= "\t\t   \"min-procs\" => 0,\n";
    $php_st .= "\t\t   \"max-procs\" => {$phpcgi_num},\n";
Beispiel #29
0
function fix_ipconntrack()
{
    addLineIfNotExistInside("/etc/sysctl.conf", "net.ipv4.ip_conntrack_max=32760", null);
    lxshell_return("sysctl", "-p");
}
Beispiel #30
0
 static function switchProgramPre($old, $new)
 {
     // issue #589 - Change httpd config structure
     if ($new === 'apache') {
         lxfile_cp("/etc/sysconfig/httpd", "/etc/sysconfig/httpd.bck");
         $ret = lxshell_return("yum", "-y", "install", "httpd", "mod_ssl");
         if ($ret) {
             throw new lxexception('install_httpd_failed', 'parent');
         }
         lxfile_rm("/etc/sysconfig/httpd");
         lxfile_mv("/etc/sysconfig/httpd.bck", "/etc/sysconfig/httpd");
         lxshell_return("service", "lighttpd", "stop");
         lxshell_return("rpm", "-e", "--nodeps", "lighttpd");
         lunlink("/etc/init.d/lighttpd");
         lxshell_return("chkconfig", "httpd", "on");
     } else {
         $ret = lxshell_return("yum", "-y", "install", "lighttpd", "lighttpd-fastcgi");
         if ($ret) {
             throw new lxexception('install_lighttpd_failed', 'parent');
         }
         lxfile_unix_chmod("/etc/init.d/lighttpd", "0755");
         lxshell_return("service", "httpd", "stop");
         lxshell_return("rpm", "-e", "--nodeps", "httpd");
         lxshell_return("chkconfig", "lighttpd", "on");
     }
     if ($new === 'apache') {
         //		addLineIfNotExistInside("/etc/httpd/conf/httpd.conf", "Include /etc/httpd/conf/kloxo/kloxo.conf", "");
         lxshell_return("__path_php_path", "../bin/misc/installsuphp.php");
         //lxshell_return("__path_php_path", "../bin/fix/fixfrontpage.php");
     } else {
         lxfile_mkdir("/etc/lighttpd/");
         lxfile_mkdir("/etc/lighttpd/conf/kloxo");
         lxfile_cp("../file/lighttpd/lighttpd.conf", "/etc/lighttpd/lighttpd.conf");
         //		lxfile_cp("../file/lighttpd/conf/kloxo/kloxo.conf", "/etc/lighttpd/conf/kloxo/kloxo.conf");
         //		lxfile_cp("../file/lighttpd/conf/kloxo/webmail.conf", "/etc/lighttpd/conf/kloxo/webmail.conf");
         lxfile_cp("../file/lighttpd/etc_init.d", "/etc/init.d/lighttpd");
         lxfile_unix_chmod("/etc/init.d/lighttpd", "0755");
         lxfile_mkdir("/home/kloxo/httpd/lighttpd");
         lxfile_unix_chown("/home/kloxo/httpd/lighttpd", "apache");
     }
 }