function setCheckPackages() { log_cleanup("Checking for rpm packages"); $list = array("maildrop-toaster", "spamdyke", "spamdyke-utils", "pure-ftpd", "simscan-toaster", "webalizer", "php-mcrypt", "dos2unix", "rrdtool", "xinetd", "lxjailshell", "php-xml", "libmhash", "lxphp"); foreach ($list as $l) { log_cleanup("- For {$l} package"); install_if_package_not_exist($l); } }
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"); } } }
function doBeforeUpdate() { global $gbl, $sgbl, $login, $ghtml; $program = $sgbl->__var_program_name; // Check for lxlabs yum repo file and if exists // Change to lxcenter repo file if (lxfile_exists("/etc/yum.repos.d/lxlabs.repo")) { log_cleanup("- Deleting old lxlabs yum repo"); lxfile_mv("/etc/yum.repos.d/lxlabs.repo", "/etc/yum.repos.d/lxlabs.repo.lxsave"); exec("rm -f /etc/yum.repos.d/lxlabs.repo"); log_cleanup("- Removed lxlabs.repo"); log_cleanup("- Installing lxcenter.repo"); exec("wget -O /etc/yum.repos.d/lxcenter.repo http://download.lxcenter.org/lxcenter.repo"); log_cleanup("- Installing yum-protectbase plugin"); exec("yum install -y -q yum-protectbase"); } // Project issue #1079 // Install yum-plugin-replace (New since Kloxo 6.1.14) $ret = install_if_package_not_exist("yum-plugin-replace"); if ($ret) { print "Installed RPM package yum-plugin-replace\n"; } // Project issue #1079 // Replace lxphp package (New since Kloxo 6.1.14) $ret = replace_rpm_package("lxphp", "kloxo-core-php"); if ($ret) { print "Replaced RPM package lxphp with kloxo-core-php\n"; } // Fix #388 - phpMyAdmin config.inc.php permission $correct_perm = "0644"; $check_perm = substr(decoct(fileperms("/usr/local/lxlabs/{$program}/httpdocs/thirdparty/phpMyAdmin/config.inc.php")), 2); if ($check_perm != $correct_perm) { lxfile_unix_chmod("/usr/local/lxlabs/{$program}/httpdocs/thirdparty/phpMyAdmin/config.inc.php", "0644"); } // Project issue #1081 // Remove lxrestart if (lxfile_exists("/usr/sbin/lxrestart")) { log_cleanup("- Deleting lxrestart from /usr/sbin/ (not in use anymore)"); lxfile_rm('/usr/sbin/lxrestart'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/cexe/lxrestart')) { log_cleanup("- Deleting lxrestart from cexe (not in use anymore)"); lxfile_rm('/usr/local/lxlabs/' . $program . '/cexe/lxrestart'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/lxrestart.c')) { log_cleanup("- Deleting lxrestart.c from src (not in use anymore)"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/lxrestart.c'); } // Clean Source dir if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/lxrestart')) { log_cleanup("- Clean the sources dir - remove lxrestart"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/lxrestart'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/closeallinput')) { log_cleanup("- Clean the sources dir - remove closeallinput"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/closeallinput'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/lxexec')) { log_cleanup("- Clean the sources dir - remove lxexec"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/lxexec'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/lxphpsu')) { log_cleanup("- Clean the sources dir - remove lxphpsu"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/lxphpsu'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/lxsuexec')) { log_cleanup("- Clean the sources dir - remove lxsuexec"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/lxsuexec'); } // DT18022014 - Cleanup the mess. if (lxfile_exists('/usr/local/lxlabs/' . $program . '/httpdocs/live/common.php')) { log_cleanup("- Remove live dir (not in use)"); lxfile_rm_rec('/usr/local/lxlabs/' . $program . '/httpdocs/live'); lxfile_rm('/usr/local/lxlabs/' . $program . '/etc/phplive.db'); } }