Example #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");
        }
    }
}
Example #2
0
function remove_ssh_self_host_key()
{
    # TODO: Can be removed somewhere in 6.2.x branche
    if (lxfile_exists("/root/.ssh/authorized_keys")) {
        remove_line("/root/.ssh/authorized_keys", "*****@*****.**");
    }
    if (lxfile_exists("/root/.ssh/authorized_keys2")) {
        remove_line("/root/.ssh/authorized_keys2", "*****@*****.**");
    }
}