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"); } }
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; }
function setExecuteCentos5Script() { log_cleanup("Executing centos 5 script and remove epel repo"); if (is_centosfive()) { log_cleanup("- Executing centos5-postpostupgrade script"); lxshell_return("sh", "../pscript/centos5-postpostupgrade"); lxfile_cp("../file/centos-5/CentOS-Base.repo", "/etc/yum.repos.d/CentOS-Base.repo"); log_cleanup("- Remove epel.repo from system"); lxfile_rm("/etc/yum.repos.d/epel.repo"); } else { log_cleanup("- Not needed to execute"); } }
function createShowAlist(&$alist, $subaction = null) { global $gbl, $sgbl, $login, $ghtml; if (!$this->getParentO()->priv->isOn('webhosting_flag')) { $this->getShowActions($alist, 'mmail'); return $alist; } $gen = $login->getObject('general')->generalmisc_b; $webstatsprog = $gen->webstatisticsprogram; if (!$webstatsprog) { $webstatsprog = "awstats"; } if ($subaction === 'config') { return $this->createShowAlistConfig($alist); } /* if (!$this->isLogin()) { //$alist['__title_admin'] = $login->getKeywordUc('administrative_actions'); } */ $alist['__title_domain_administer'] = $login->getKeywordUc('Domain Adm'); //$this->getLxclientActions($alist); $alist['__v_dialog_limit'] = "a=updateform&sa=limit"; //$alist['__title_next'] = $login->getKeywordUc('general'); //$alist['__v_dialog_info'] = 'a=updateform&sa=information'; //$alist['__v_dialog_pass'] = '******'; $web = $this->getObject('web'); $alist[] = 'a=list&c=addondomain'; //$alist['__var_backup_flag'] = "a=show&o=lxbackup"; //$alist[] = "a=list&c=mysqldb"; //$this->getListActions($alist, 'mssqldb'); /* if (check_if_many_server()) { //if (count($this->getParentO()->listpriv->mysqldbpserver_list) > 1) { $alist[] = "a=updateform&sa=ddatabasepserver"; //} } */ if ($login->isLteAdmin() || $login->priv->isOn('dns_manage_flag')) { $alist[] = 'a=show&o=dns'; } //$alist['__title_web'] = $this->getTitleWithSync('web'); $alist['__title_domain_log'] = $login->getKeywordUc('trafficandlog'); $alist['__v_dialog_stat'] = "n=web&a=updateform&sa=stats_protect"; $tmpurl = "n=web&a=show&l[class]=ffile&l[nname]=__lx_error_log"; $alist[] = create_simpleObject(array('url' => "{$tmpurl}", 'purl' => "o=web&a=updateform&sa=error_log", 'target' => "", '__internal' => true)); $tmpurl = "n=web&a=show&l[class]=ffile&l[nname]=__lx_access_log"; $alist[] = create_simpleObject(array('url' => "{$tmpurl}", 'purl' => "o=web&a=updateform&sa=access_log", 'target' => "", '__internal' => true)); $tmpurl = "n=web&a=show&l[class]=ffile&l[nname]=__lx_php_log"; $alist[] = create_simpleObject(array('url' => "{$tmpurl}", 'purl' => "o=web&a=updateform&sa=php_log", 'target' => "", '__internal' => true)); if ($webstatsprog === 'awstats') { $alist[] = create_simpleObject(array('url' => "http://{$this->nname}/awstats/awstats.pl?config={$this->nname}", 'purl' => 'c=domain&a=updateform&sa=show_awstats', 'target' => "target='_blank'")); } else { if ($webstatsprog === 'webalizer') { $alist[] = create_simpleObject(array('url' => "http://{$this->nname}/stats/", 'purl' => 'c=domain&a=updateform&sa=show_stats', 'target' => "target='_blank'")); } } //$alist[] = "n=web&a=graph&sa=webtraffic"; $alist[] = 'a=list&c=domaintraffichistory'; $alist[] = "n=web&a=list&c=weblastvisit"; $alist[] = "n=web&a=updateform&sa=statsconfig"; if ($login->priv->isOn('runstats_flag') && $this->priv->isOn('awstats_flag')) { $alist[] = "n=web&a=updateform&sa=run_stats"; } //$alist[] = "n=web&a=updateform&sa=sesubmit"; $alist['__title_domain_classweb'] = $web->getTitleWithSync(); //$alist['__title_domain_classweb'] = 'web'; //$alist[] = "a=list&c=webindexdir_a"; $alist[] = "n=web&a=list&c=dirprotect"; $alist['__v_dialog_hotlink'] = "n=web&a=updateform&sa=hotlink_protection"; $alist['__v_dialog_ipblock'] = "n=web&a=updateform&sa=blockip"; if ($login->priv->isOn('document_root_flag')) { $alist[''] = "n=web&a=updateform&sa=docroot"; } $alist['__v_dialog_misc'] = "n=web&a=updateform&sa=configure_misc"; $alist['__v_dialog_dirin'] = "n=web&a=updateform&sa=dirindex"; $alist[] = "n=web&a=show&l[class]=ffile&l[nname]=/"; $driverapp = $gbl->getSyncClass($this->__masterserver, $this->syncserver, 'ftpuser'); //$alist[] = "n=web&a=list&c=ftpuser"; //$alist[] = 'n=web&a=list&c=ftpsession'; //$alist[] = "n=web&a=list&c=davuser"; //$web->getSwitchServerUrl($alist); //$alist[] = "a=updateForm&sa=ipaddress"; $alist['__title_script'] = $login->getKeywordUc('script'); //$alist[] = create_simpleObject(array('url' => "http://$this->nname/__kloxo/phpinfo.php?session=$servar", 'purl' => 'n=web&a=updateform&sa=phpinfo', 'target' => "target='_blank'")); $alist[] = "n=web&a=update&sa=phpinfo"; $alist['__v_dialog_phpini'] = "n=web&o=phpini&a=updateform&sa=edit"; if ($login->isAdmin()) { if ($web->__driverappclass === 'lighttpd') { if (is_centosfive()) { $alist[] = "n=web&a=list&c=rubyrails"; } } } $alist['__v_dialog_phpiniadv'] = "n=web&o=phpini&a=updateform&sa=extraedit"; if ($web->__driverappclass === 'lighttpd') { $alist['__v_dialog_perma'] = "n=web&a=updateform&sa=permalink"; $alist['__v_dialog_fcgi'] = "n=web&a=updateform&sa=fcgi_config"; if ($login->isAdmin()) { $alist['__v_dialog_lightyr'] = "n=web&a=updateform&sa=lighty_rewrite"; } } $alist['__v_dialog_comp'] = "n=web&a=list&c=component"; if (!$gen->isOn('disableinstallapp') && $this->getClientParentO()->priv->isOn('installapp_flag')) { $alist[] = "n=web&a=show&k[class]=allinstallapp&k[nname]=installapp"; } /* $alist['action'][] = "a=update&sa=backup"; $alist['action'][] = "a=updateform&sa=restore"; */ /* if ($this->priv->isOn('frontpage_flag')) { $alist[] = create_simpleObject(array( 'url' => "http://$this->nname:8080", 'purl' => 'a=update&sa=frontpage_admin&l[class]=web&l[nname]=$this->nname', 'target' => "target='_blank'")); } */ //$this->getChildShowActions($alist); $this->getShowActions($alist, 'mmail'); $alist['__title_domain_extra'] = $login->getKeywordUc('extra'); $tmpurl = "n=web&a=show&l[class]=ffile&l[nname]=/"; $alist[] = create_simpleObject(array('url' => "{$tmpurl}", 'purl' => "o=web&a=updateform&sa=image_manager", 'target' => "", '__internal' => true)); if ($login->isAdmin()) { $alist[] = "n=web&a=updateform&sa=extra_tag"; } $alist[] = "n=web&a=list&c=server_alias_a"; if ($web->__driverappclass !== 'lighttpd') { $alist[] = "n=web&a=list&c=webhandler"; $alist[] = "n=web&a=list&c=webmimetype"; } $alist[] = "n=web&a=list&c=redirect_a"; $alist['__v_dialog_error'] = "n=web&a=updateform&sa=custom_error"; /* if ($this->getClientParentO()->priv->isOn('cron_manage_flag')) { if ($this->getObject('web')->__driverappclass === 'apache' || $this->getObject('web')->__driverappclass === 'lighttpd') { $alist[] = "n=web&a=list&c=cron"; } } */ if ($login->isNotCustomer()) { // Disabling change owner for the present. $alist[] = "a=updateForm&sa=changeowner"; } //$alist[] = "a=list&c=subweb_a"; //$alist[] = $this->getStubUrl('__stub_domain_view_url'); if ($this->previewdomain) { $alist[] = create_simpleObject(array('url' => "http://{$this->nname}.{$this->previewdomain}", 'purl' => 'c=domain&a=updateform&sa=site_preview', 'target' => "target='_blank'")); } else { $alist[] = create_simpleObject(array('url' => "/sitepreview/{$this->nname}/", 'purl' => 'c=domain&a=updateform&sa=site_preview', 'target' => "target='_blank'")); } if ($login->isAdmin()) { $alist[] = "a=updateform&sa=preview_config"; } $alist[] = create_simpleObject(array('url' => "http://intodns.com/{$this->nname}", 'purl' => 'c=domain&a=updateform&sa=check_dns', 'target' => "target='_blank'")); // $alist['__title_ddatabase'] = "Database"; /* $alist['__title_misc'] = "Misc"; $this->getListActions($alist, 'utmp'); $this->getListActions($alist, 'ticket'); $alist[] = "a=list&c=smessage"; */ return $alist; }
public function createConfig() { global $gbl, $sgbl, $login, $ghtml; if ($this->main->isOn('nosaveconfig_flag')) { return; } if ($this->main->isWindows()) { $this->createWindowsConfig(); return; } $memory = $this->getRealMemory(); if ($this->isLVM()) { $loc = "phy"; } else { $loc = "file"; } $string = null; /* Commented to allow the below if else to handel pygrub & xvd OSTemplates should follow this format With pygrub =centos-5-x86-pygrub-xvd.tar.gz without pygrub=centos-5-x86-default-xvd.tar.gz $sk = "/boot/hypervm-xen-vmlinuz-{$this->main->nname}"; if (lxfile_exists($sk)) { $kern = $sk; } else { $kern = "/boot/hypervm-xen-vmlinuz"; } $string .= "kernel = '$kern'\n"; $customram = "/boot/hypervm-xen-initrd-{$this->main->nname}.img"; if (lxfile_exists($customram)) { $string .= "ramdisk = '$customram'\n"; } else if (lxfile_exists('/boot/hypervm-xen-initrd.img')) { $string .= "ramdisk = '/boot/hypervm-xen-initrd.img'\n"; } */ //Add pygrub configuration if template name contains pygrub $pygrub_record = explode('-', $this->main->ostemplate); if (stripos($pygrub_record[3], 'pygrub') !== FALSE) { $string .= "bootloader = '/usr/bin/pygrub'\n"; } else { /* okay - a bit word here as well... * * 1. RHEL5 Host and not using pygrub template -> use existing kernel * 2. RHEL6 Host and not using pygrub template -> check below: * 2a. if RHEL-5/CentOS-5 or old kloxo (hostinabox) template -> use lxkernel-domU-xen kernel * 2b. if other modern linux template -> copy existing kernel modules */ if (is_centosfive()) { $kernev = trim(`uname -r`); $string .= "kernel = '/boot/hypervm-xen-vmlinuz'\n"; $string .= "ramdisk = '/boot/hypervm-xen-initrd.img'\n"; } else { if (char_search_beg($this->main->ostemplate, "centos-5")) { $string .= "kernel = '/boot/hypervm-xen-vmlinuz-2.6.18'\n"; $string .= "ramdisk = '/boot/hypervm-xen-initrd-2.6.18.img'\n"; } else { $string .= "kernel = '/boot/hypervm-xen-vmlinuz'\n"; $string .= "ramdisk = '/boot/hypervm-xen-initrd.img'\n"; } } } //Add xvd configuration if template name contains xvd $xvd_record = explode('-', $this->main->ostemplate); if (stripos($xvd_record[4], 'xvd') !== FALSE) { $string .= "disk = ['{$loc}:{$this->main->maindisk},xvda1,w', '{$loc}:{$this->main->swapdisk},xvdb1,w']\n"; $string .= "root = '/dev/xvda1 ro selinux=0'\n"; } else { $string .= "disk = ['{$loc}:{$this->main->maindisk},sda1,w', '{$loc}:{$this->main->swapdisk},sda2,w']\n"; $string .= "root = '/dev/sda1 ro selinux=0'\n"; } if ($this->isUnlimited($this->main->priv->cpu_usage)) { $cpu = "100" * os_getCpuNum(); } else { $cpu = $this->main->priv->cpu_usage; } if ($this->isUnlimited($this->main->priv->cpuunit_usage)) { $cpuunit = "1000"; } else { $cpuunit = $this->main->priv->cpuunit_usage; } if (!is_numeric($cpuunit)) { $cpuunit = '1000'; } if (!is_numeric($cpu)) { $cpu = "100" * os_getCpuNum(); } $string .= "memory = {$memory}\n"; //$string .= "cpu_cap = $cpu\n"; $string .= "cpu_weight = {$cpuunit}\n"; $string .= "name = '{$this->main->nname}'\n"; $string .= $this->getVifString(); $string .= "vnc = 0\n"; $string .= $this->addVcpu(); $string .= "vncviewer = 0\n"; $string .= "serial = 'pty'\n"; if ($this->main->text_xen_config) { $string .= "{$this->main->text_xen_config}\n"; } lxfile_mkdir($this->main->configrootdir); lfile_put_contents("{$this->main->configrootdir}/{$this->main->nname}.cfg", $string); }