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"); } } } }
public function rebuild() { if (!$this->main->isOn('rebuild_confirm_f')) { throw new lxException("need_confirm_rebuild", 'rebuild_confirm_f'); } if ($this->main->isWindows()) { $templatefile = "__path_program_home/xen/template/{$this->main->ostemplate}"; } else { $templatefile = "__path_program_home/xen/template/{$this->main->ostemplate}.tar.gz"; } if (!lxfile_nonzero($templatefile)) { $this->main->getOsTemplateFromMaster($templatefile); } if (!lxfile_nonzero($templatefile)) { throw new lxException("no_template_and_could_not_download", 'rebuild_confirm_f'); } $this->stop(); if ($this->main->isNotWindows()) { $mountpoint = $this->mount_this_guy(); if ($this->main->isOn('rebuild_backup_f')) { lxfile_mkdir("/home/hypervm/vps/{$this->main->nname}/__backup/"); $date = date('Y-m-d-') . time(); $dir = "/home/hypervm/vps/{$this->main->nname}/__backup/rebuild-backup.{$date}"; lxfile_cp_rec($mountpoint, $dir); } } $this->umountThis(); if ($this->main->isNotWindows()) { if ($this->isLvm()) { lxshell_return("mkfs.ext3", "-F", $this->main->maindisk); } else { lxfile_rm_rec($this->main->maindisk); $this->createDisk(); } $mountpoint = $this->mount_this_guy(); $ret = lxshell_return("tar", "-C", $mountpoint, '--numeric-owner', "-xpzf", $templatefile); if ($ret) { throw new lxException("rebuild_failed_could_not_untar"); } } else { $templatefile = expand_real_root($templatefile); lxshell_return("parted", "-s", $this->main->maindisk, "mklabel", "msdos"); $this->runParted(); $partition = $this->getPartition(); //lxshell_return("dd", "if=$templatefile", "of={$this->main->maindisk}"); lxshell_return("ntfsclone", "--restore-image", "-O", $partition, $templatefile); $this->kpart_remove(); $this->expandPartitionToImage(); } $this->start(); }