Пример #1
0
function updateApplicableToSlaveToo()
{
    global $gbl, $sgbl, $login, $ghtml, $osversion;
    print "Download 3rdparty\n";
    // Fixes #303 and #304
    download_thirdparty();
    print "Installing binaries\n";
    lxfile_cp("__path_program_root/cexe/lxxen", "/usr/bin");
    lxfile_cp("__path_program_root/cexe/lxopenvz", "/usr/bin");
    print "Fixing binaries permissions\n";
    lxfile_generic_chmod("/usr/bin/lxopenvz", "6755");
    lxfile_generic_chmod("/usr/bin/lxxen", "6755");
    print "Install missing rpm packages if any";
    install_if_package_not_exist("rrdtool");
    print "-rrdtool-";
    install_if_package_not_exist("ntfsprogs");
    print "-ntfsprogs-";
    install_if_package_not_exist("parted");
    print "-parted-";
    install_if_package_not_exist("kpartx");
    print "-kpartx-";
    install_if_package_not_exist("dhcp");
    print "-dhcp-";
    install_if_package_not_exist("openssl");
    print "-openssl-";
    install_if_package_not_exist("openssl-devel");
    print "-openssl-devel-\n";
    system("chkconfig dhcpd on");
    print "Enable dhcpd at system startup\n";
    if (lxfile_exists("/etc/xen")) {
        lxfile_mkdir("/etc/xen/hypervm");
        if (!lxfile_exists("/boot/hypervm-xen-vmlinuz")) {
            system("cd /boot ; ln -sf vmlinuz-2.6-xen hypervm-xen-vmlinuz; ln -sf initrd-2.6-xen.img hypervm-xen-initrd.img");
        }
        $list = lscandir_without_dot("/etc/xen/auto");
        foreach ($list as $l) {
            $dir = strtil($l, ".cfg");
            lunlink("/etc/xen/auto/{$l}");
            if (lxfile_exists("/home/xen/{$dir}/{$l}")) {
                lxfile_symlink("/home/xen/{$dir}/{$l}", "/etc/xen/auto/{$l}");
            }
        }
    }
    if (lxfile_exists("/var/log/loadvg.log")) {
        lunlink("/var/log/loadvg.log");
    }
    if (lxfile_exists("/etc/vz")) {
        lxfile_cp("__path_program_root/file/sysfile/openvz/ve-vps.basic.conf-sample", "/etc/vz/conf");
        print "Set NEIGHBOUR_DEVS=all to vz.conf\n";
        vps__openvz::staticChangeConf("/etc/vz/vz.conf", "NEIGHBOUR_DEVS", "all");
    }
    print "Fixing openvz repo\n";
    // add openvz.repo
    lxfile_cp("../file/openvz.repo", "/etc/yum.repos.d/openvz.repo");
    print "Fixing lxcenter repo\n";
    // add lxcenter.repo
    $osversion = find_os_version();
    print "- Your OS {$osversion}\n";
    $cont = our_file_get_contents("../file/lxcenter.repo");
    $cont = str_replace("%distro%", $osversion, $cont);
    our_file_put_contents("/etc/yum.repos.d/lxcenter.repo", $cont);
    print "Fix RHN\n";
    fix_rhn_sources_file();
    print "Fix ipconntrack\n";
    fix_ipconntrack();
    if (lxfile_exists("/home/hypervm/xen/template")) {
        print "Check Xen windows-lxblank.img template\n";
        system("echo hypervm-windows > /home/hypervm/xen/template/windows-lxblank.img");
    }
    print "Fix memory graph\n";
    memoryGraphFix();
    print "Fix permission of closeallinput\n";
    lxfile_unix_chmod("../cexe/closeallinput", "0755");
    print "Fix LxEtc\n";
    installLxetc();
    print "Check binaries\n";
    system("cp ../sbin/lxrestart /usr/sbin/");
    system("chown root:root /usr/sbin/lxrestart");
    system("chmod 755 /usr/sbin/lxrestart");
    system("chmod ug+s /usr/sbin/lxrestart");
    system("chmod 777 /tmp");
    system("chmod o+t /tmp");
    print "Create script dir\n";
    copy_script();
    if (!lxfile_exists("/usr/local/lxlabs/kloxo/")) {
        print "Remove /usr/local/lxlabs/kloxo/ as it should not be here!\n";
        system("rmdir /usr/local/lxlabs/kloxo/httpdocs/ >/dev/null 2>&1");
        system("rmdir /usr/local/lxlabs/kloxo/ >/dev/null 2>&1");
    }
    if (!lxfile_exists("/var/named/chroot/etc/kloxo.named.conf")) {
        if (lxfile_exists("/var/named/chroot/etc/lxadmin.named.conf")) {
            remove_line("/var/named/chroot/etc/named.conf", "lxadmin.named.conf");
            $pattern = 'include "/etc/kloxo.named.conf";';
            $file = "/var/named/chroot/etc/named.conf";
            $comment = "//Kloxo";
            @addLineIfNotExistInside($file, $pattern, $comment);
            @lxfile_mv("/var/named/chroot/etc/lxadmin.named.conf", "/var/named/chroot/etc/kloxo.named.conf");
        }
    }
}
Пример #2
0
 public function dbactionUpdate($subaction)
 {
     global $gbl, $sgbl, $login, $ghtml;
     switch ($subaction) {
         case "changelocation":
             return $this->changelocation();
             break;
         case "rebuild":
             $this->rebuild();
             break;
         case "recovervps":
             $this->recovervps();
             break;
         case "mount":
             $this->mount_this_guy();
             break;
         case "createuser":
             return $this->main->syncCreateUser();
             break;
         case "full_update":
             $this->setDiskUsage();
             $this->setMemoryUsage();
             $this->setCpuUsage();
             $this->setSwapUsage();
             $this->toggleStatus();
             break;
         case "password":
             $this->changeUserPassword();
             break;
         case "createtemplate":
             return $this->createTemplate();
             break;
         case "disable":
         case "enable":
         case "toggle_status":
             $this->toggleStatus();
             break;
         case "change_disk_usage":
             $this->setDiskUsage();
             break;
         case "change_realmem_usage":
             $this->setMemoryUsage();
             break;
         case "change_swap_usage":
             $this->setSwapUsage();
             break;
         case "change_process_usage":
             //$this->setProcessUsage();
             break;
         case "rootpassword":
             $this->setRootPassword();
             break;
         case "installkloxo":
             $this->installKloxo();
             break;
         case "network":
         case "information":
             $this->setInformation();
             $this->setDhCP();
             break;
         case "add_vmipaddress_a":
             $this->setDhCP();
             break;
         case "delete_vmipaddress_a":
             $this->setDhCP();
             break;
         case "boot":
             $this->start();
             break;
         case "poweroff":
             $this->stop();
             $this->mount_this_guy();
             break;
         case "reboot":
             $this->reboot();
             break;
         case "change_cpu_usage":
             $this->setCpuUsage();
             break;
         case "hardpoweroff":
             $this->hardstop();
             break;
         case "createconfig":
             $this->createConfig();
             $ret = lxfile_symlink("{$this->main->configrootdir}/{$this->main->nname}.cfg", "/etc/xen/auto");
             break;
         case "graph_traffic":
             return rrd_graph_vps("traffic", "xen-{$this->main->vifname}.rrd", $this->main->rrdtime);
             break;
         case "graph_cpuusage":
             return rrd_graph_vps("cpu", "{$this->main->nname}.rrd", $this->main->rrdtime);
             break;
     }
 }
Пример #3
0
 function createDir()
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!$this->customer_name) {
         log_log("critical", "Lack customername for web: {$this->nname}");
         return;
     }
     $web_home = $sgbl->__path_httpd_root;
     $base_root = $sgbl->__path_httpd_root;
     $v_dir = "{$web_home}/{$this->nname}/conf";
     $log_path = "{$web_home}/{$this->nname}/stats";
     $cgi_path = "{$this->getFullDocRoot()}/cgi-bin/";
     $log_path1 = "{$log_path}/";
     $cust_log = "{$log_path1}/{$this->nname}-custom_log";
     $err_log = "{$log_path1}/{$this->nname}-error_log";
     $awstat_conf = "{$sgbl->__path_real_etc_root}/awstats/";
     $awstat_dirdata = "{$sgbl->__path_kloxo_httpd_root}/awstats/";
     $user_home = $this->getFullDocRoot();
     if (!lxfile_exists("{$this->getCustomerRoot()}/public_html")) {
         lxfile_symlink($this->nname, "{$this->getCustomerRoot()}/public_html");
     }
     $domname = $this->nname;
     /*
     	print("+++++++++++++++++++++++++++++++++++++++++++++++++++++");
     	print("This is the Conf file Path  $v_dir 		=" );
         print("This is the LogPath  	$log_path 	= ");
         print("This is the  LogPath $log_path1 	="); 
         print("This is the Custom  LogPath $cust_log 	=" );
         print("This is the Error LoG Path  $err_log 	= ");
     	print("$stat_conf 	= ");
     	print("This is THE User Home $user_home = ");	
     	print("+++++++++++++++++++++++++++++++++++++++++++++++++++");
     */
     // Protection for webstats.
     /*
     	$new_user_dir = false;
     	lxfile_mkdir($user_home);
     
     	if ((count(lscandir_without_dot($user_home)) == 0) && isset($this->__var_skelfile) && $this->__var_skelfile) {
     		$this->getAndUnzipSkeleton($this->__var_skelmachine, $this->__var_skelfile, "$user_home/");
     		$new_user_dir = true;
     	}
     	lxfile_mkdir("$web_home/$domname/webstats");
     */
     $wsstring = "Stats not yet generated\n";
     lfile_put_contents("{$web_home}/{$domname}/webstats/index.html", $wsstring);
     lxfile_mkdir($cgi_path);
     lxfile_mkdir($user_home);
     // Sort of hack.. Changes the domain.com/domain.com to domain.com/httpdocs.
     // Which is easier to remember. Slowly we need to change all the code from dom/dom to dom/httpdocs..
     // but for now, just create a symlink.
     lxfile_generic_chmod("{$web_home}/{$this->nname}", "0755");
     lxfile_mkdir("{$user_home}/");
     lxfile_generic_chmod($user_home, "0755");
     lxfile_mkdir($v_dir);
     lxfile_mkdir($log_path);
     //lxfile_mkdir($log_path1);
     // issue #589 - Change httpd config structure
     //	lxfile_mkdir("__path_apache_path/kloxo");
     //	lxfile_touch("__path_apache_path/kloxo/virtualhost.conf");
     $parent_doc_root = $this->getParentFullDocRoot();
     if ($user_home != $parent_doc_root) {
         lxfile_generic_chown_rec($parent_doc_root, "{$this->username}:{$this->username}");
     } else {
         lxfile_generic_chown_rec($user_home, "{$this->username}:{$this->username}");
     }
     /*
     	// Issue #565 - Domain skeleton files chmodded to 0755
     	// latest info from William
     
     	if ($new_user_dir) {
     		lxfile_generic_chmod_rec($user_home, "755");
     	}
     
     
     	system("find {$user_home} -type f -exec chmod 644 {} \;");
     	system("find {$user_home} -type d -exec chmod 755 {} \;");
     */
     // MR --- consistence with fix-chownchmod script
     // fixed 64bit slave (skeleton.zip always zero)
     // back to original because problem with suphp
     lxfile_generic_chown($user_home, "{$this->username}:apache");
     lxfile_generic_chown("__path_customer_root/{$this->customer_name}", "{$this->username}:apache");
     lxfile_generic_chmod("__path_customer_root/{$this->customer_name}", "750");
     lxfile_generic_chown($log_path1, "apache:apache");
     lxfile_generic_chmod($log_path1, "770");
     lxfile_generic_chown("{$web_home}/{$this->nname}", "{$this->username}:apache");
     if (!lxfile_exists("{$web_home}/{$this->nname}/httpdocs")) {
         //lxfile_mkdir("$sgbl->__path_customer_root/$this->customer_name/domain/$this->nname");
         //lxfile_symlink("{$this->getFullDocRoot()}", "$sgbl->__path_customer_root/$this->customer_name/domain/$this->nname/www");
         lxfile_symlink("{$this->getFullDocRoot()}", "{$web_home}/{$this->nname}/httpdocs");
         //lxfile_symlink("$web_home/{$this->nname}/httpdocs", "$web_home/{$this->nname}/{$this->nname}");
     }
     $this->createstatsConf($this->nname, $this->stats_username, $this->stats_password);
     /*
     	print("This is the User Home : $user_home \n");                                                   
     	print("This is the certificate Pah : $sgbl->__path_ssl_root/certificate/\n");            
     	print("This is the Private Key Pah: $sgbl->__path_ssl_root/privatekey/\n");             
     	print("This is the Domain Name :$web_home/{$this->nname}\n");                              
     	
     	print( "This is teh User Httpdocs  :$user_home/www/");                                         
     	print("GO to the User Dir (chmod 775");                                                    
     	print("Chown To The :{$this->username}:{$this->username}, $user_home\n");  
     	print("This is the Vdir :  $v_dir\n");                                                         
     	print("Creating log path :$log_path\n");                                                            
     	print("Creating Dir:$log_path1\n");                                                           
     	print("Touching :$sgbl->__path_apache_path/kloxo\n");                           
     	print("Touching Virtual hOPs$sgbl->__path_apache_path/kloxo/virtualhost.conf\n");                  
     	print("$err_log\n");                                                             
     	print("Install ALL : $install_all\n");
     	print("chown  :{$this->username} , $web_home/{$this->nname}\n");
     	exit;
     */
     // MR -- make guarantee the last process!
     // mod_php still possible not work (ftp issue) for tranfer skeleton.zip from master to slave
     $this->getAndUnzipSkeleton($this->__var_skelmachine, $this->__var_skelfile, "{$user_home}/");
     dprint("end\n");
 }
Пример #4
0
function os_fix_lxlabs_permission()
{
    global $gbl, $sgbl, $login, $ghtml;
    lxfile_mkdir("__path_program_root/session");
    lxfile_unix_chown_rec("__path_program_root", "lxlabs");
    lxfile_unix_chmod_rec("__path_program_root/sbin/", "0755");
    lxfile_unix_chmod_rec("__path_program_root/httpdocs/img/", "0755");
    lxfile_unix_chmod("__path_program_etc", "0700");
    lxfile_unix_chmod("__path_program_root/log", "0700");
    lxfile_unix_chmod("__path_program_root/session", "0700");
    // prevent php warning when file exist - already since 6.1.7
    if (!lxfile_exists("/usr/bin/lphp.exe")) {
        lxfile_symlink("__path_php_path", "/usr/bin/lphp.exe");
    }
}
Пример #5
0
<?php

include_once "htmllib/lib/include.php";
initProgram('admin');
$login->loadAllObjects('client');
$list = $login->getList('client');
foreach ($list as $c) {
    $dlist = $c->getList('domain');
    $d = getFirstFromList($dlist);
    lunlink("/home/{$c->nname}/www");
    lxfile_symlink("/home/{$c->nname}/domain/{$d->nname}/www", "/home/{$c->nname}/www");
    foreach ($dlist as $l) {
        $web = $l->getObject('web');
        $web->setUpdateSubaction('full_update');
        $web->was();
    }
}
Пример #6
0
function os_fix_lxlabs_permission()
{
    global $gbl, $sgbl, $login, $ghtml;
    lxfile_mkdir("__path_program_root/session");
    lxfile_unix_chown_rec("__path_program_root", "lxlabs");
    lxfile_unix_chmod_rec("__path_program_root/sbin/", "0755");
    lxfile_unix_chmod_rec("__path_program_root/httpdocs/img/", "0755");
    lxfile_unix_chmod("__path_program_etc", "0700");
    lxfile_unix_chmod("__path_program_root/log", "0700");
    lxfile_unix_chmod("__path_program_root/session", "0700");
    lxfile_symlink("__path_php_path", "/usr/bin/lphp.exe");
}
Пример #7
0
 function createDir()
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!$this->customer_name) {
         log_log("critical", "Lack customername for web: {$this->nname}");
         return;
     }
     $web_home = $sgbl->__path_httpd_root;
     $base_root = $sgbl->__path_httpd_root;
     $v_dir = "{$web_home}/{$this->nname}/conf";
     $log_path = "{$web_home}/{$this->nname}/stats";
     $cgi_path = "{$this->getFullDocRoot()}/cgi-bin/";
     $log_path1 = "{$log_path}/";
     $cust_log = "{$log_path1}/{$this->nname}-custom_log";
     $err_log = "{$log_path1}/{$this->nname}-error_log";
     $awstat_conf = "{$sgbl->__path_real_etc_root}/awstats/";
     $awstat_dirdata = "{$sgbl->__path_kloxo_httpd_root}/awstats/";
     $user_home = $this->getFullDocRoot();
     if (!lxfile_exists("{$this->getCustomerRoot()}/public_html")) {
         lxfile_symlink($this->nname, "{$this->getCustomerRoot()}/public_html");
     }
     $domname = $this->nname;
     $wsstring = "Stats not yet generated\n";
     lfile_put_contents("{$web_home}/{$domname}/webstats/index.html", $wsstring);
     lxfile_mkdir($cgi_path);
     lxfile_mkdir($user_home);
     // Sort of hack.. Changes the domain.com/domain.com to domain.com/httpdocs.
     // Which is easier to remember. Slowly we need to change all the code from dom/dom to dom/httpdocs..
     // but for now, just create a symlink.
     lxfile_generic_chmod("{$web_home}/{$this->nname}", "0755");
     lxfile_mkdir("{$user_home}/");
     lxfile_generic_chmod($user_home, "0755");
     lxfile_mkdir($v_dir);
     lxfile_mkdir($log_path);
     $parent_doc_root = $this->getParentFullDocRoot();
     // Removed the recursive chown
     if ($user_home != $parent_doc_root) {
         lxfile_generic_chown($parent_doc_root, "{$this->username}:{$this->username}");
     } else {
         lxfile_generic_chown($user_home, "{$this->username}:{$this->username}");
     }
     lxfile_generic_chown($user_home, "{$this->username}:apache");
     lxfile_generic_chown("__path_customer_root/{$this->customer_name}", "{$this->username}:apache");
     lxfile_generic_chmod("__path_customer_root/{$this->customer_name}", "750");
     lxfile_generic_chown($log_path1, "apache:apache");
     lxfile_generic_chmod($log_path1, "770");
     lxfile_generic_chown("{$web_home}/{$this->nname}", "{$this->username}:apache");
     if (!lxfile_exists("{$web_home}/{$this->nname}/httpdocs")) {
         lxfile_symlink("{$this->getFullDocRoot()}", "{$web_home}/{$this->nname}/httpdocs");
     }
     $this->createstatsConf($this->nname, $this->stats_username, $this->stats_password);
     // MR -- make guarantee the last process!
     // mod_php still possible not work (ftp issue) for tranfer skeleton.zip from master to slave
     $this->getAndUnzipSkeleton($this->__var_skelmachine, $this->__var_skelfile, "{$user_home}/");
     dprint("end\n");
 }
Пример #8
0
    lxfile_mkdir("{$cdir}/old");
    lxfile_mkdir("{$cdir}/cgi-bin");
    foreach ($dlist as $l) {
        if (lxfile_exists("{$cdir}/{$l->nname}")) {
            lxfile_mv_rec("{$cdir}/{$l->nname}", "{$cdir}/old/");
        }
        if (!is_link("{$cdir}/domain/{$l->nname}/www/")) {
            lxfile_mv_rec("{$cdir}/domain/{$l->nname}/www/", "{$cdir}/{$l->nname}");
        }
        /*
        	foreach($l->subweb_a as $k => $v) {
        		lxfile_mv_rec("$cdir/domain/$l->nname/subdomains/$v->nname", "$cdir/$l->nname/$v->nname");
        	}
        */
        if (!is_link("{$cdir}/domain/{$l->nname}/cgi-bin/")) {
            lxfile_mv_rec("{$cdir}/domain/{$l->nname}/cgi-bin/", "{$cdir}/cgi-bin/{$l->nname}");
        }
        lunlink("{$cdir}/domain/{$l->nname}/www");
        lxfile_symlink("{$cdir}/{$l->nname}", "{$cdir}/domain/{$l->nname}/www");
        lxfile_symlink("{$cdir}/cgi-bin/{$l->nname}", "{$cdir}/domain/{$l->nname}/cgi-bin");
        $web = $l->getObject('web');
        $web->setUpdateSubaction('full_update');
        $dirlist = $web->getList('dirprotect');
        foreach ($dirlist as $dir) {
            $dir->setUpdateSubaction('full_update');
            $dir->was();
        }
        $web->was();
    }
}
lxshell_return("__path_php_path", "../bin/misc/fixftpuserclient.phps");
Пример #9
0
function setSomePermissions()
{
    log_cleanup("Install/Fix Services/Permissions/Configfiles");
    if (!lxfile_exists("/usr/bin/lxphp.exe")) {
        log_cleanup("- Create lxphp.exe Symlink");
        lxfile_symlink("__path_php_path", "/usr/bin/lxphp.exe");
    }
    log_cleanup("- Set permissions for /usr/bin/php-cgi");
    lxfile_unix_chmod("/usr/bin/php-cgi", "0755");
    log_cleanup("- Set permissions for closeallinput binary");
    lxfile_unix_chmod("../cexe/closeallinput", "0755");
    log_cleanup("- Set permissions for lxphpsu binary");
    lxfile_unix_chown("../cexe/lxphpsu", "root:root");
    lxfile_unix_chmod("../cexe/lxphpsu", "0755");
    lxfile_unix_chmod("../cexe/lxphpsu", "ug+s");
    log_cleanup("- Set permissions for phpsuexec.sh script");
    lxfile_unix_chmod("../file/phpsuexec.sh", "0755");
    log_cleanup("- Set permissions for /home/kloxo/httpd/lighttpd/ dir");
    system("chown -R apache:apache /home/kloxo/httpd/lighttpd/");
    log_cleanup("- Set permissions for /var/lib/php/session/ dir");
    system("chmod 777 /var/lib/php/session/");
    system("chmod o+t /var/lib/php/session/");
    log_cleanup("- Set permissions for /var/bogofilter/ dir");
    system("chmod 777 /var/bogofilter/");
    system("chmod o+t /var/bogofilter/");
    log_cleanup("- Kill sisinfoc system process");
    system("pkill -f sisinfoc");
}
Пример #10
0
 function setupDefaultDomain()
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!$sgbl->isKloxo()) {
         return;
     }
     if (!$this->main->default_domain) {
         return;
     }
     lunlink("/home/{$this->main->getPathFromName('nname')}/public_html");
     if ($this->main->isDisabled('default_domain')) {
         return;
     }
     dprint("linking {$this->main->__var_defdocroot}\n");
     lxfile_symlink("/home/{$this->main->getPathFromName()}/{$this->main->__var_defdocroot}/", "/home/{$this->main->getPathFromName()}/public_html");
 }