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"); } } }
function get_kloxo_ostemplate() { $ver = getHIBversion(); if (!$ver) { return; } if (is_openvz()) { if (lxfile_exists("/vz/template/cache")) { if (!lxfile_real("/vz/template/cache/centos-5-i386-hostinabox{$ver}.tar.gz")) { system("cd /vz/template/cache/ ;rm -f centos-?-i386-lxadmin*.tar.gz ; rm -f centos-?-i386-hostinabox*.tar.gz; wget download.lxcenter.org/download/openvztemplates/base/centos-5-i386-hostinabox{$ver}.tar.gz"); } } } else { if (lxfile_exists("/home/hypervm/xen/template/")) { if (!lxfile_nonzero("/home/hypervm/xen/template/centos-5-i386-hostinabox{$ver}.tar.gz")) { system("cd /home/hypervm/xen/template/ ; rm -f centos-?-i386-lxadmin*.tar.gz; rm -f centos-?-i386-hostinabox*.tar.gz; wget download.lxcenter.org/download/xentemplates/base/centos-5-i386-hostinabox{$ver}.tar.gz"); } } } }
include_once "htmllib/lib/include.php"; include_once "htmllib/lib/lxserverlib.php"; kill_and_save_pid('hypervm.php'); debug_for_backend(); $global_dontlogshell = true; execSisinfoc(); system("iptables -t nat -L"); vpstraffic__openvz::iptables_delete(); vpstraffic__openvz::iptables_create(); if ($argv[1] === 'master') { start_portmonitor(); } dprint("Starting Server\n"); system("echo 16536 > /proc/sys/net/ipv4/tcp_max_tw_buckets_ve"); system("echo 256 > /proc/sys/net/ipv4/tcp_max_tw_kmem_fraction"); if (is_openvz()) { //system("sysctl net.ipv4.conf.all.proxy_arp=1"); } lxshell_php("../bin/fix/fixippool.php"); $global_dontlogshell = false; lxserver_main(); function timed_execution() { global $global_dontlogshell; $global_dontlogshell = true; timed_exec(2, "checkRestart"); timed_exec(2 * 5, "execSisinfoc"); $global_dontlogshell = false; } function execSisinfoc() {