Example #1
0
function vg_diskfree($vgname)
{
    if (is_centosfive()) {
        if (!lxfile_exists("/usr/sbin/vgdisplay")) {
            return;
        }
    } else {
        if (is_centossix()) {
            if (!lxfile_exists("/sbin/vgdisplay")) {
                return;
            }
        } else {
            return;
        }
    }
    $vgname = fix_vgname($vgname);
    $out = exec_with_all_closed_output("vgdisplay -c {$vgname}");
    $out = trim($out);
    $list = explode(":", $out);
    $per = $list[12];
    $num = $list[15];
    return $per * $num / 1024;
}
Example #2
0
function cleanupProcess()
{
    global $gbl, $sgbl, $login, $ghtml, $osversion;
    print "Download 3rdparty\n";
    // Fixes #303 and #304
    download_thirdparty();
    print "Installing binaries\n";
    if (is_openvz()) {
        lxfile_cp("__path_program_root/cexe/lxopenvz", "/usr/bin");
    } else {
        lxfile_cp("__path_program_root/cexe/lxxen", "/usr/bin");
    }
    print "Fixing binaries permissions\n";
    if (is_openvz()) {
        lxfile_generic_chmod("/usr/bin/lxopenvz", "6755");
    } else {
        lxfile_generic_chmod("/usr/bin/lxxen", "6755");
    }
    print "Checking for missing RPM packages...\n";
    $ret = install_if_package_not_exist("rrdtool");
    if ($ret) {
        print "- Installed rrdtool\n";
    }
    if (!is_openvz()) {
        $ret = install_if_package_not_exist("ntfsprogs");
        if ($ret) {
            print "- Installed ntfsprogs\n";
        }
        $ret = install_if_package_not_exist("parted");
        if ($ret) {
            print "- Installed parted\n";
        }
        $ret = install_if_package_not_exist("kpartx");
        if ($ret) {
            print "- Installed kpartx\n";
        }
    }
    $ret = install_if_package_not_exist("openssl");
    if ($ret) {
        print "- Installed openssl\n";
    }
    $ret = install_if_package_not_exist("openssl-devel");
    if ($ret) {
        print "- Installed openssl-devel\n";
    }
    if (!is_openvz()) {
        $ret = install_if_package_not_exist("dhcp");
        if ($ret) {
            print "- Installed dhcp\n";
        }
        system("chkconfig dhcpd on");
        print "Enabled dhcpd at system startup\n";
    }
    if (!is_openvz()) {
        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("/home/hypervm/xen/template")) {
            print "Check Xen windows-lxblank.img template\n";
            system("echo hypervm-windows > /home/hypervm/xen/template/windows-lxblank.img");
        }
    }
    if (lxfile_exists("/var/log/loadvg.log")) {
        lunlink("/var/log/loadvg.log");
    }
    if (lxfile_exists("/etc/vz")) {
        if (is_centossix()) {
            lxfile_cp("__path_program_root/file/sysfile/openvz/centos-6-openvz-ve-vswap-hypervm.conf-sample", "/etc/vz/conf/ve-vswap-hypervm.conf-sample");
        } else {
            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");
    }
    $osversion = find_os_version();
    // Populate openvz repository
    // The repository files will be updated in the future with rpm package
    if (!lxfile_exists("/etc/yum.repos.d/openvz.repo")) {
        print "Installing openvz repo for {$osversion}\n";
        if (is_centossix()) {
            lxfile_cp("../file/centos-6-openvz.repo.template", "/etc/yum.repos.d/openvz.repo");
        } else {
            lxfile_cp("../file/centos-5-openvz.repo.template", "/etc/yum.repos.d/openvz.repo");
        }
    }
    // Populate lxcenter repository
    // The repository files will be updated in the future with rpm package
    if (!lxfile_exists("/etc/yum.repos.d/lxcenter.repo")) {
        print "Installing lxcenter repo for {$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();
    print "Fix memory graph\n";
    memoryGraphFix();
    print "Fix permission of closeallinput\n";
    lxfile_unix_chmod("../cexe/closeallinput", "0755");
    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");
        }
    }
}
Example #3
0
function xen_install($installtype)
{
    // If openvz.repo file exist remove it imediately before install Xen
    if (file_exists("/etc/yum.repos.d/openvz.repo")) {
        unlink("/etc/yum.repos.d/openvz.repo");
    }
    if (is_centossix()) {
        $arch = `arch`;
        $arch = trim($arch);
        if ($arch === 'x86_64') {
            lxfile_cp("../file/centos-6-xen.repo.template", "/etc/yum.repos.d/CentOS-Xen.repo");
        } else {
            echo "Sorry, installation aborted. Xen is not supported at CentOS 6 32bit.";
            exit;
        }
    }
    if (is_centosfive()) {
        $list = array("kernel-xen", "xen", "virt-manager");
    } else {
        $list = array("kernel-xen", "xen", "virt-manager", "lxmkinitrd", "lxkernel-domU-xen");
    }
    run_package_installer($list);
    if (file_exists("/boot/vmlinuz-2.6-xen") && !file_exists("/boot/hypervm-xen-vmlinuz")) {
        system("cd /boot ; ln -s vmlinuz-2.6-xen hypervm-xen-vmlinuz; ln -s initrd-2.6-xen.img hypervm-xen-initrd.img");
    }
    if (file_exists("/etc/init.d/libvirtd")) {
        system("chkconfig libvirtd off");
    }
    system("chkconfig xendomains on");
    system("chkconfig xend on");
    if (is_centossix()) {
        system("../bin/grub-bootxen.sh");
        system("sh /script/fixxenkernel");
    }
}