function doReverseDns() { addLineIfNotExistInside("__path_named_chroot/etc/named.conf", "include \"/etc/lxreverse.conf\";", "//added by hypervm"); list($base, $end) = reversedns::getBaseEnd($this->main->nname, $this->main->__var_rdnsrange); $ddate = date("Ymd"); $v = rand(0, 99); if ($v < 10) { $v = "0{$v}"; } $ddate = "{$ddate}{$v}"; $string = null; $string .= "\$TTL 86400\n"; $string .= "@ IN SOA {$this->main->__var_revdns1}. root.{$this->main->__var_revdns1}. (\n"; $string .= "{$ddate} ; serial\n"; $string .= "28800 ; refresh\n"; $string .= "14400 ; retry\n"; $string .= "1814400 ; expire\n"; $string .= "86400 ; default_tt\n"; $string .= ")\n"; $string .= " IN NS {$this->main->__var_revdns1}.\n"; if ($this->main->__var_revdns2) { $string .= " IN NS {$this->main->__var_revdns2}.\n"; } $result = $this->main->__var_reverse_list; $result = $result[$base]; $this->main->end = $end; $result = merge_array_object_not_deleted($result, $this->main); foreach ($result as $k => $v) { $v['reversename'] = trim($v['reversename']); if (!cse($v['reversename'], ".")) { $v['reversename'] .= "."; } $string .= "{$v['end']}\tIN PTR {$v['reversename']}\n"; } lfile_put_contents("__path_named_realpath/{$base}.in-addr.arpa", $string); $this->createMainFile(); }
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"); } } }
<?php include_once "htmllib/lib/include.php"; $driverapp = slave_get_driver('web'); if ($driverapp === 'lighttpd') { print "Driver is currently lighttpd\n"; exit; } system("yum -y install frontpage"); system("cp -r /usr/local/frontpage/version5.0/apache2/.libs/mod_frontpage.so /etc/httpd/modules/"); system("chmod 755 /var/log/httpd/"); addLineIfNotExistInside("/etc/httpd/conf/httpd.conf", "LoadModule frontpage_module modules/mod_frontpage.so", "");
function setup_scpid($cont) { global $global_dontlogshell; $global_dontlogshell = true; $home = os_get_home_dir("root"); $file = "{$home}/.ssh/authorized_keys2"; lxfile_mkdir("{$home}/.ssh"); lxfile_unix_chmod("{$home}/.ssh", "0700"); addLineIfNotExistInside($file, "\n{$cont}", ''); lxfile_unix_chmod($file, "0700"); $global_dontlogshell = false; return lfile_get_contents("/etc/ssh/ssh_host_rsa_key.pub"); }
static function removeOtherDriver($driverapp) { global $gbl, $sgbl, $login, $ghtml; if ($driverapp === 'bind') { lxshell_return("service", "djbdns", "stop"); lxshell_return("chkconfig", "named", "on"); $pattern = 'include "/etc/global.options.named.conf";'; $file = "/var/named/chroot/etc/named.conf"; $comment = "//Global_options_file"; addLineIfNotExist($file, $pattern, $comment); $options_file = "/var/named/chroot/etc/global.options.named.conf"; $example_options = "acl \"lxcenter\" {\n"; $example_options .= " localhost;\n"; $example_options .= "};\n\n"; $example_options .= "options {\n"; $example_options .= " max-transfer-time-in 60;\n"; $example_options .= " transfer-format many-answers;\n"; $example_options .= " transfers-in 60;\n"; $example_options .= " auth-nxdomain yes;\n"; $example_options .= " allow-transfer { \"lxcenter\"; };\n"; $example_options .= " allow-recursion { \"lxcenter\"; };\n"; $example_options .= " recursion no;\n"; $example_options .= " version \"LxCenter - 1.0\";\n"; $example_options .= "};\n\n"; $example_options .= "# Remove # to see all DNS queries\n"; $example_options .= "#logging {\n"; $example_options .= "# channel query_logging {\n"; $example_options .= "# file \" /var/log / named_query . log\";\n"; $example_options .= "# versions 3 size 100M;\n"; $example_options .= "# print-time yes;\n"; $example_options .= "# };\n\n"; $example_options .= "# category queries {\n"; $example_options .= "# query_logging;\n"; $example_options .= "# };\n"; $example_options .= "#};\n"; if (!lfile_exists($options_file)) { touch($options_file); chown($options_file, "named"); } $cont = lfile_get_contents($options_file); $pattern = "options"; if (!preg_match("+{$pattern}+i", $cont)) { file_put_contents($options_file, "{$example_options}\n"); } $pattern = 'include "/etc/kloxo.named.conf";'; $file = "/var/named/chroot/etc/named.conf"; $comment = "//Kloxo"; addLineIfNotExistInside($file, $pattern, $comment); touch("/var/named/chroot/etc/kloxo.named.conf"); chown("/var/named/chroot/etc/kloxo.named.conf", "named"); lxshell_return("rpm", "-e", "djbdns"); lunlink("/etc/init.d/djbdns"); } else { lxshell_return("service", "named", "stop"); lxshell_return("rpm", "-e", "--nodeps", "bind"); lxshell_return("rpm", "-e", "--nodeps", "bind-chroot"); lxshell_return("chkconfig", "djbdns", "on"); } }
function doReverseDns() { global $sgbl; $this->main->nname = strtoupper($this->main->nname); addLineIfNotExistInside("__path_named_chroot/etc/named.conf", "include \"/etc/lxreverse.conf\";", "//added by hypervm"); list($base, $end) = reversedns::getBaseEnd($this->main->nname, $this->main->__var_rdnsrange); if (reversedns::isIPV6($this->main->nname)) { $isv6 = true; } else { $isv6 = false; } $ddate = date("Ymd"); // We read the last serial from the zone file // default to 0 on error if ($isv6) { $version = $this->getNewSerial("{$sgbl->__path_named_realpath}/" . $base . "ip6.arpa", $ddate); } else { $version = $this->getNewSerial("{$sgbl->__path_named_realpath}/" . $base . "in-addr.arpa", $ddate); } if ($version < 10) { $version = "0" . $version; } $ddate = "{$ddate}{$version}"; $string = null; $string .= "\$TTL 3600\n"; if ($isv6) { $string .= "\$ORIGIN " . $base . "IP6.ARPA.\n"; } else { $string .= "\$ORIGIN {$base}.IN-ADDR.ARPA.\n"; } $string .= "@ IN SOA {$this->main->__var_revdns1}. root.{$this->main->__var_revdns1}. (\n"; $string .= "{$ddate} ; serial\n"; $string .= "18800 ; refresh\n"; $string .= "14400 ; retry\n"; $string .= "1814400 ; expire\n"; $string .= "3600 ; default_tt\n"; $string .= ")\n"; $string .= " IN NS {$this->main->__var_revdns1}.\n"; if ($this->main->__var_revdns2) { $string .= " IN NS {$this->main->__var_revdns2}.\n"; } $result = $this->main->__var_reverse_list; $result = $result[$base]; $this->main->end = $end; $result = merge_array_object_not_deleted($result, $this->main); foreach ($result as $key => $val) { $val['reversename'] = trim($val['reversename']); if (!cse($val['reversename'], ".")) { $val['reversename'] .= "."; } if ($isv6) { $string .= reversedns::createDottedRevedIPV6($val['end']) . "\t IN PTR {$val['reversename']}\n"; } else { $string .= "{$val['end']}\tIN PTR {$val['reversename']}\n"; } } if ($isv6) { lfile_put_contents("__path_named_realpath/" . $base . "ip6.arpa", $string); } else { lfile_put_contents("__path_named_realpath/{$base}.in-addr.arpa", $string); } $this->createMainFile(); }
static function removeOtherDriver($driverapp) { global $gbl, $sgbl, $login, $ghtml; if ($driverapp === 'bind') { lxshell_return("service", "djbdns", "stop"); lxshell_return("chkconfig", "named", "on"); $pattern = 'include "/etc/kloxo.named.conf";'; $file = "/var/named/chroot/etc/named.conf"; $comment = "//Kloxo"; addLineIfNotExistInside($file, $pattern, $comment); touch("/var/named/chroot/etc/kloxo.named.conf"); chown("/var/named/chroot/etc/kloxo.named.conf", "named"); lxshell_return("rpm", "-e", "djbdns"); lunlink("/etc/init.d/djbdns"); } else { lxshell_return("service", "named", "stop"); lxshell_return("rpm", "-e", "--nodeps", "bind"); lxshell_return("rpm", "-e", "--nodeps", "bind-chroot"); lxshell_return("chkconfig", "djbdns", "on"); } }
function setJailshellSystem() { log_cleanup("Installing jailshell to system"); if (!lxfile_exists("/usr/bin/execzsh.sh")) { log_cleanup("- Installing process"); addLineIfNotExistInside("/etc/shells", "/usr/bin/lxjailshell", ""); lxfile_cp("htmllib/filecore/execzsh.sh", "/usr/bin/execzsh.sh"); lxfile_unix_chmod("/usr/bin/execzsh.sh", "0755"); } }