Пример #1
0
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");
    }
}
Пример #2
0
function cp_dbfile()
{
    global $gbl, $sgbl, $login, $ghtml;
    $progname = $sgbl->__var_program_name;
    lxfile_cp("../sbin/{$progname}db", "/usr/bin/{$progname}db");
    lxfile_generic_chmod("/usr/bin/{$progname}db", "0755");
}
Пример #3
0
 static function installMe()
 {
     $ret = lxshell_return("yum", "-y", "install", "spamassassin");
     if ($ret) {
         throw new lxexception('install_spamassassin_failed', 'parent');
     }
     lxshell_return("chkconfig", "spamassassin", "on");
     lxfile_cp("../file/sysconfig_spamassassin", "/etc/sysconfig/spamassassin");
     createRestartFile("spamassassin");
 }
Пример #4
0
function openvz_install($installtype)
{
    $arch = `arch`;
    $arch = trim($arch);
    if ($arch === 'x86_64') {
        $list = array("vzctl.x86_64", "vzquota.x86_64", "ovzkernel.x86_64");
    } else {
        $list = array("vzctl", "vzquota", "ovzkernel-PAE");
    }
    lxfile_cp("../file/openvz.repo", "/etc/yum.repos.d/openvz.repo");
    run_package_installer($list);
}
Пример #5
0
 static function installMe()
 {
     lxshell_return("yum", "-y", "install", "djbdns", "daemontools");
     if ($ret) {
         throw new lxexception('install_djbdns_failed', 'parent');
     }
     lxfile_rm_rec("/var/tinydns");
     lxfile_rm_rec("/var/axfrdns");
     lxshell_return("__path_php_path", "../bin/misc/djbdnsstart.php");
     lxfile_cp("../file/djbdns.init", "/etc/init.d/djbdns");
     lxfile_unix_chmod("/etc/init.d/djbdns", "0755");
     lxshell_return("chkconfig", "djbdns", "on");
     createRestartFile("djbdns");
 }
Пример #6
0
function os_createLowMem()
{
    if (!lxfile_exists("/proc/user_beancounters") && !lxfile_exists("/proc/xen")) {
        if (!lxshell_return("diff", "../file/lowmem/my.cnf.lowmem", "/etc/my.cnf")) {
            lxfile_cp("/etc/lowmem.saved.my.cnf", "/etc/my.cnf");
            createRestartFile("mysqld");
        }
        return;
    }
    if (lxfile_exists("__path_program_etc/flag/lowmem.flag")) {
        if (!lxfile_exists("/etc/lowmem.saved.my.cnf")) {
            lxfile_cp("/etc/my.cnf", "/etc/lowmem.saved.my.cnf");
            lxfile_cp("../file/lowmem/my.cnf.lowmem", "/etc/my.cnf");
            createRestartFile('mysql');
            createRestartFile('courier-imap');
        }
        //lxfile_cp("../file/lowmem/spamassassin.lowmem", "/etc/sysconfig/spamassassin");
    }
}
Пример #7
0
 function dbactionUpdate($subaction)
 {
     $name = sslcert::getSslCertnameFromIP($this->main->nname);
     $path = "__path_ssl_root";
     $contentscer = $this->main->text_crt_content;
     $contentskey = $this->main->text_key_content;
     $contentsca = trim($this->main->text_ca_content);
     if (!$contentscer || !$contentskey) {
         throw new lxException("certificate_key_file_empty", '');
     }
     sslcert::checkAndThrow($contentscer, $contentskey, $name);
     lfile_put_contents("{$path}/{$name}.crt", $contentscer);
     lfile_put_contents("{$path}/{$name}.key", $contentskey);
     $contentpem = "{$contentscer}\n{$contentskey}";
     lfile_put_contents("{$path}/{$name}.pem", $contentpem);
     if ($contentsca) {
         lfile_put_contents("{$path}/{$name}.ca", $contentsca);
     } else {
         lxfile_cp("htmllib/filecore/program.ca", "{$path}/{$name}.ca");
     }
     createRestartFile($this->main->__var_webdriver);
 }
Пример #8
0
function add_line_to_secondary_mycnf($master, $slavepass)
{
    global $gbl, $sgbl, $login, $ghtml;
    if (!lxfile_exists("/etc/secondary_master.copy.my.cnf")) {
        lxfile_cp("/etc/my.cnf", "/etc/secondary_master.copy.my.cnf");
    }
    $list = lfile_trim("/etc/my.cnf");
    foreach ($list as $k => $l) {
        if (check_if_skip($l)) {
            continue;
        }
        $ll[] = $l;
        if ($l == '[mysqld]') {
            $ll[] = "server-id=2";
            $ll[] = "master-host={$master}";
            $ll[] = "master-user=lxlabsslave";
            $ll[] = "master-password={$slavepass}";
        }
    }
    lfile_put_contents("/etc/my.cnf", implode("\n", $ll));
    system("service mysqld restart");
}
Пример #9
0
function add_line_to_master_mycnf()
{
    global $gbl, $sgbl, $login, $ghtml;
    $dbf = $sgbl->__var_dbf;
    if (!lxfile_exists("/etc/primary_master.copy.my.cnf")) {
        lxfile_cp("/etc/my.cnf", "/etc/primary_master.copy.my.cnf");
    }
    $v = lfile_get_contents("/etc/my.cnf");
    if (csa($v, "binlog-do-db")) {
        print "Line already exists in /etc/my.cnf\n";
        return;
    }
    $list = lfile_trim("/etc/my.cnf");
    foreach ($list as $k => $l) {
        $ll[] = $l;
        if ($l == '[mysqld]') {
            $ll[] = "log-bin=mysql-bin";
            $ll[] = "binlog-do-db={$dbf}";
            $ll[] = "server-id=1";
        }
    }
    lfile_put_contents("/etc/my.cnf", implode("\n", $ll));
    system("service mysqld restart");
}
Пример #10
0
 function enablePhp()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $domname = $this->main->nname;
     $uname = $this->main->username;
     if (!$this->main->priv->isOn('php_flag')) {
         return "AddType application/x-httpd-php-source .php\n";
     }
     $string = null;
     lxfile_unix_chown("/home/httpd/{$domname}", "{$uname}:apache");
     lxfile_unix_chmod("/home/httpd/{$domname}", "0775");
     if (!lxfile_exists("/home/httpd/{$domname}/php.ini")) {
         // MR -- issue #650 - lxuser_cp doesn't work and change to lxfile_cp; lighttpd use lxfile_cp
         lxfile_cp("/etc/php.ini", "/home/httpd/{$domname}/php.ini");
     }
     return $string;
 }
Пример #11
0
    }
}
foreach ($list as &$l) {
    $l = preg_replace("/__cgi_or_fcgi__/", $php_st, $l);
    $l = preg_replace("/__program_name__/", $sgbl->__var_program_name, $l);
    $l = preg_replace("/__program_disable_nonssl__/", $nonsslhash, $l);
    $l = preg_replace("/__program_port__/", $nonsslport, $l);
    $l = preg_replace("/__program_sslport__/", $sslport, $l);
    $l = preg_replace("/__program_user__/", $user, $l);
}
lfile_put_contents("../file/lighttpd.conf", implode("", $list));
$pemfile = "__path_program_root/etc/program.pem";
$cafile = "__path_program_root/etc/program.ca";
if (!lxfile_exists($pemfile)) {
    lxfile_cp("__path_program_htmlbase/htmllib/filecore/program.pem", $pemfile);
    lxfile_generic_chown($pemfile, "lxlabs");
}
// Merged from 6.1.x/kloxo/bin/common/misc/fixlighty.php	(revision 472)
lxfile_touch("__path_program_root/log/lighttpd_error.log");
lxfile_touch("__path_program_root/log/access_log");
lxfile_generic_chmod("__path_program_root/log", "0700");
lxfile_generic_chown("__path_program_root/log", "lxlabs:lxlabs");
lxfile_generic_chmod("__path_program_root/log/lighttpd_error.log", "0644");
lxfile_generic_chmod("__path_program_root/log/access_log", "0644");
lxfile_generic_chown("__path_program_root/log/lighttpd_error.log", "lxlabs:root");
lxfile_generic_chown("__path_program_root/log/access_log", "lxlabs:root");
//
if (!lxfile_exists($cafile)) {
    lxfile_cp("__path_program_htmlbase/htmllib/filecore/program.ca", $cafile);
    lxfile_generic_chown($cafile, "lxlabs");
}
Пример #12
0
 function updateupload_Logo($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $progname = $sgbl->__var_program_name;
     $parent = $this->getParentO();
     $imgname = $parent->getClName();
     //	$param['specialplay_b-logo_image'] = "/img/logo/$imgname.gif";
     //	$param['specialplay_b-logo_image_loading'] = "/img/logo/$imgname-loading.gif";
     //	make_sure_directory_is_lxlabs("__path_program_htmlbase/img/logo");
     $param['specialplay_b-logo_image'] = "/img/user-logo.png";
     $fullpath_logo_image = __path_program_htmlbase . $param['specialplay_b-logo_image'];
     // temporary only for admin - 6.1.7
     if ($_FILES['logo_image_f']['tmp_name']) {
         lxfile_mv($_FILES['logo_image_f']['tmp_name'], $fullpath_logo_image);
     }
     /*
     	else {
     		lxfile_cp("__path_program_htmlbase/img/$progname-logo.gif", "__path_program_htmlbase" . $param['specialplay_b-logo_image']);
     	}
     */
     lxfile_cp($fullpath_logo_image, "/usr/local/lxlabs/kloxo/file/user-logo.png");
     // must chown to lxlabs for successful display on 'Upload Logo'
     lxfile_unix_chown($fullpath_logo_image, "lxlabs");
     passthru("lxphp.exe /usr/local/lxlabs/kloxo/bin/fix/fix-userlogo.php --select=all");
     /*
     	if ($_FILES['logo_image_loading_f']['tmp_name']) {
     		lxfile_mv($_FILES['logo_image_loading_f']['tmp_name'], "__path_program_htmlbase" .$param['specialplay_b-logo_image_loading']);
     	} else {
     		lxfile_cp("__path_program_htmlbase/img/$progname-splash.gif", "__path_program_htmlbase" . $param['specialplay_b-logo_image_loading']);
     	}
     */
     $tsp = $parent->getObject("sp_childspecialplay");
     $tsp->specialplay_b->logo_image = $param['specialplay_b-logo_image'];
     //	$tsp->specialplay_b->logo_image_loading = $param['specialplay_b-logo_image_loading'];
     $tsp->setUpdateSubaction('upload_logo');
     $this->setUpdateSubaction('upload_logo');
     return $param;
 }
Пример #13
0
 public function do_restore($docd)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $this->hardstop();
     $this->createDisk();
     $tmpbasedir = $this->main->__var_tmp_base_dir;
     if ($this->checkForSnapshot()) {
         lvm_remove($this->getSnapshotName());
         if ($this->checkForSnapshot()) {
             throw new lxException("snapshot_for_this_exists_and_coudnt_remove");
         }
     }
     if (!$this->main->isWindows()) {
         $mountpoint = $this->mount_this_guy();
         lxshell_unzip_numeric_with_throw($mountpoint, $docd);
         //lxshell_return("tar", "-C", "$mountpoint/dev", "-xzf", "__path_program_root/file/vps-dev.tgz");
         if ($this->main->__old_driver !== 'xen') {
             log_restore("Restoring {$this->main->nname} from a different driver {$this->main->__old_driver} to xen");
             /*
             	if (!lxfile_exists("__path_program_home/xen/template/{$this->main->ostemplate}.tar.gz")) {
             		throw new lxException("migrating_from_{$this->main->__old_driver}_needs_osImage");
             }
             */
             //lxshell_return("tar", "-C", $mountpoint, "-xzf", "__path_program_home/xen/template/{$this->main->ostemplate}.tar.gz", "etc/rc.d", "sbin", "etc/hotplug.d", "etc/dev.d", "etc/udev", "lib", "usr", "bin", "etc/inittab", "etc/sysconfig");
             //lxshell_return("tar", "-C", $mountpoint, "-xzf", "__path_program_home/xen/template/{$this->main->ostemplate}.tar.gz", "etc/rc.d", "sbin", "etc/hotplug.d", "etc/dev.d", "etc/udev", "lib", "usr", "bin", "etc/inittab");
             lxfile_cp("../file/sysfile/xen/fstab", "{$mountpoint}/etc/fstab");
             lxfile_cp("__path_program_root/file/sysfile/xen/inittab", "{$mountpoint}/etc/inittab");
             lunlink("{$mountpoint}/etc/mtab");
             lunlink("{$mountpoint}/etc/init.d/vzquota");
             $this->copyKernelModules();
         }
         lxfile_mkdir("{$mountpoint}/proc");
         $this->createConfig();
         $this->setMemoryUsage();
         $this->setCpuUsage();
         $this->setSwapUsage();
     } else {
         $tmpdir = createTempDir($tmpbasedir, "lx_{$this->main->nname}_backup");
         lxshell_unzip_with_throw($tmpdir, $docd);
         $partition = $this->getPartition();
         lxshell_return("ntfsclone", "--restore-image", "--force", "-O", $partition, "{$tmpdir}/backup.img");
         lxfile_tmp_rm_rec("{$tmpdir}");
         $this->kpart_remove();
     }
     $this->main->status = 'on';
     try {
         $this->toggleStatus();
     } catch (Exception $e) {
     }
     $this->start();
     // Saving state doesn't seem to be an option. The thing is, it is the file system itself that's left in an inconsistent state, and there's little we can do about it.
     /*
     	$statefile = "$mountpoint/__hypervm_xensavestate";
     	if (lxfile_exists($statefile)) {
     		$tmp = lx_tmp_file("/tmp", "xen_ram");
     		lxfile_mv($statefile, $tmp);
     		$this->umountThis();
     		$this->restoreXen($tmp);
     		lunlink($tmp);
     	} else {
     		$this->start();
     	}
     */
 }
Пример #14
0
function update_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    log_cleanup("*** Executing Update (upcp) - BEGIN ***");
    debug_for_backend();
    $login = new Client(null, null, 'upgrade');
    $DoUpdate = false;
    $opt = parse_opt($argv);
    log_cleanup("Kloxo Install/Update");
    if (lxfile_exists("/var/cache/kloxo/kloxo-install-firsttime.flg")) {
        log_cleanup("- Installing Kloxo packages at the first time");
        $DoUpdate = true;
    } else {
        log_cleanup("- Getting Version Info from the LxCenter download Server");
        $upversion = false;
        if (isset($opt['till-version']) && $opt['till-version'] || lxfile_exists("__path_slave_db")) {
            $sgbl->slave = true;
            $upversion = findNextVersion($opt['till-version']);
            $type = 'slave';
        } else {
            $sgbl->slave = false;
            $upversion = findNextVersion();
            $type = 'master';
        }
        if ($upversion) {
            log_cleanup("- Connecting LxCenter download server");
            do_upgrade($upversion);
            log_cleanup("- Upgrade Done. Cleanup....");
            flush();
        } else {
            $localversion = $sgbl->__ver_major_minor_release;
            log_cleanup("- Kloxo is the latest version ({$localversion})");
        }
        // Thirdparty/Webmail/AWstats checks
        $verWM = getVersionNumber(get_package_version("lxwebmail"));
        $verAW = getVersionNumber(get_package_version("lxawstats"));
        $ver = file_get_contents("http://download.lxcenter.org/download/thirdparty/kloxo-version.list");
        $verTP = getVersionNumber($ver);
        if (!lxfile_exists("/var/cache/kloxo/lxwebmail{$verWM}.tar.gz")) {
            $retWM = true;
        } else {
            $retWM = false;
        }
        if (!lxfile_exists("/var/cache/kloxo/lxawstats{$verAW}.tar.gz")) {
            $retAW = true;
        } else {
            $retAW = false;
        }
        if (!lxfile_exists("/var/cache/kloxo/kloxo-thirdparty.{$verTP}.zip")) {
            $retTP = true;
        } else {
            $retTP = false;
        }
        installThirdparty();
        installWebmail();
        installAwstats();
        // Run cleanups or not
        if ($retTP || $retWM || $retAW || $upversion) {
            $DoUpdate = true;
        } else {
            $DoUpdate = false;
        }
    }
    log_cleanup("*** Executing Update (upcp) - END ***");
    if ($DoUpdate == false) {
        log_cleanup("Run /script/cleanup if you want to fix/restore/(re)install non-working components.");
        exit;
    }
    if (is_running_secondary()) {
        log_cleanup("Not running Update cleanup, because this is running as secondary\n");
        exit;
    }
    //
    // Executing update/cleanup process
    //
    lxfile_cp("htmllib/filecore/php.ini", "/usr/local/lxlabs/ext/php/etc/php.ini");
    $res = pcntl_exec("/bin/sh", array("../bin/common/updatecleanup.sh", "--type={$type}"));
}
Пример #15
0
 static function switchProgramPre($old, $new)
 {
     if ($new === 'bind') {
         lxshell_return("service", "djbdns", "stop");
         $ret = lxshell_return("yum", "-y", "install", "bind", "bind-chroot");
         if ($ret) {
             throw new lxexception('install_bind_failed', 'parent');
         }
         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("yum", "-y", "install", "djbdns", "daemontools-toaster");
         if ($ret) {
             throw new lxexception('install_djbdns_failed', 'parent');
         }
         lxshell_return("service", "named", "stop");
         lxfile_rm_rec("/var/tinydns");
         lxfile_rm_rec("/var/axfrdns");
         lxshell_return("__path_php_path", "../bin/misc/djbdnsstart.php");
         lxshell_return("rpm", "-e", "--nodeps", "bind");
         lxshell_return("rpm", "-e", "--nodeps", "bind-chroot");
         lxfile_cp("../file/djbdns.init", "/etc/init.d/djbdns");
         lxfile_unix_chmod("/etc/init.d/djbdns", "0755");
         lxshell_return("chkconfig", "djbdns", "on");
     }
 }
Пример #16
0
function os_create_program_service()
{
    global $gbl, $sgbl, $login, $ghtml;
    $pgm = $sgbl->__var_program_name;
    $pgminit = "__path_program_htmlbase/htmllib/filecore/{$pgm}.init.program";
    if (lxfile_exists($pgminit)) {
        lxfile_cp($pgminit, "/etc/init.d/{$pgm}");
    } else {
        lxfile_cp("__path_program_htmlbase/htmllib/filecore/init.program", "/etc/init.d/{$pgm}");
    }
    lxfile_cp("__path_program_htmlbase/htmllib/filecore/php.ini", "__path_lxlabs_base/ext/php/etc/php.ini");
    lxfile_unix_chmod("/etc/init.d/{$pgm}", "0755");
}
Пример #17
0
 function do_restore($docd)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $dbadmin = $this->main->__var_dbadmin;
     $dbpass = $this->main->__var_dbpassword;
     $vd = tempnam("/tmp", "mysqldump");
     lunlink($vd);
     mkdir($vd);
     $docf = "{$vd}/mysql-{$this->main->dbname}.dump";
     $ret = lxshell_unzip_with_throw($vd, $docd);
     if (!lxfile_exists($docf)) {
         throw new lxException('could_not_find_matching_dumpfile_for_db', '', '');
     }
     $cont = lfile_get_contents($docf);
     if ($this->main->dbpassword) {
         $ret = lxshell_input($cont, "__path_mysqlclient_path", "-u", $this->main->username, "-p{$this->main->dbpassword}", $this->main->dbname);
     } else {
         $ret = lxshell_input($cont, "__path_mysqlclient_path", "-u", $this->main->username, $this->main->dbname);
     }
     if ($ret) {
         log_restore("Mysql restore failed.... Copying the mysqldump file {$docf} to {$sgbl->__path_kloxo_httpd_root}...");
         lxfile_cp($docf, "__path_kloxo_httpd_root");
         throw new lxException('mysql_error_could_not_restore_data', '', '');
     }
     lunlink($docf);
     lxfile_tmp_rm_rec($vd);
 }
Пример #18
0
 static function copyCertificate($devname, $machinename)
 {
     $name = $devname . "___" . $machinename;
     $name = sslcert::getSslCertnameFromIP($name);
     if (!lxfile_exists("__path_ssl_root")) {
         lxfile_mkdir("__path_ssl_root");
     }
     if (!lxfile_exists("__path_ssl_root/{$name}.crt")) {
         lxfile_cp("__path_program_root/file/default.crt", "__path_ssl_root/{$name}.crt");
     }
     if (!lxfile_exists("__path_ssl_root/{$name}.key")) {
         lxfile_cp("__path_program_root/file/default.key", "__path_ssl_root/{$name}.key");
     }
     if (!lxfile_exists("__path_ssl_root/{$name}.ca")) {
         lxfile_cp("__path_program_root/file/default.ca", "__path_ssl_root/{$name}.ca");
     }
 }
Пример #19
0
 static function switchProgramPost($old, $new)
 {
     if ($new === 'spamassassin') {
         lxfile_cp("../file/sysconfig_spamassassin", "/etc/sysconfig/spamassassin");
         createRestartFile("spamassassin");
     }
 }
Пример #20
0
function fixZshEtc()
{
    return;
    // TODO: Remove /root/.etc/
    global $global_dontlogshell;
    $global_dontlogshell = true;
    $dir = os_get_home_dir("root");
    if (lxfile_exists("{$dir}/.etc")) {
        lxfile_cp("htmllib/filecore/lxetc/commands.shell", "{$dir}/.etc/");
        return;
    }
    $ret = lxshell_return("rpm", "-q", "zsh", "vim-ehhanced");
    if ($ret) {
        system("yum -y install zsh vim-enhanced");
    }
    print "Copy LxEtc\n";
    lxfile_cp_rec("htmllib/filecore/lxetc/", "{$dir}/.etc");
}
Пример #21
0
                if ($drec->param === $oldip) {
                    $drec->param = $newip;
                }
            }
        }
        $dns->was();
    }
}
$list = lscandir_without_dot("/home/httpd");
foreach ($list as $l) {
    if (!is_dir("/home/httpd/{$l}")) {
        continue;
    }
    lxfile_unix_chown_rec("/home/httpd/{$l}/stats/", "apache");
}
$driverapp = $gbl->getSyncClass(null, 'localhost', 'web');
if ($driverapp === 'apache') {
    // --- issue #589
    //	addLineIfNotExistInside("/etc/httpd/conf/httpd.conf", "Include /etc/httpd/conf/kloxo/kloxo.conf", "");
    lxshell_return("__path_php_path", "../bin/misc/installsuphp.php");
} else {
    lxfile_cp("../file/lighttpd/lighttpd.conf", "/etc/lighttpd/lighttpd.conf");
    // --- issue #598
    //	lxfile_cp("../file/lighttpd/conf/kloxo/kloxo.conf", "/etc/lighttpd/conf/kloxo/kloxo.conf");
    //	lxfile_cp("../file/lighttpd/conf/kloxo/webmail.conf", "/etc/lighttpd/conf/kloxo/webmail.conf");
    lxfile_cp("../file/lighttpd/~lxcenter.conf", "/etc/lighttpd/conf.d/~lxcenter.conf");
    lxfile_cp("../file/lighttpd/conf/kloxo/webmail.conf", "/home/lighttpd/conf/defaults/webmail.conf");
    lxfile_mkdir("/home/kloxo/httpd/lighttpd");
    lxfile_unix_chown("/home/kloxo/httpd/lighttpd", "apache");
}
print "\n\n";
Пример #22
0
 function getAndUnzipSkeleton($ip, $filepass, $dir)
 {
     $oldir = getcwd();
     // File may be a variable path.
     dprintr($filepass);
     $file = $filepass['file'];
     // The thing is this needs to be executed even on secondary master and then the primary master would be down.
     // So if we cannot connect back, we just continue. Skeleton is not an important thing.
     try {
         getFromFileserv($ip, $filepass, "{$dir}/{$file}");
     } catch (exception $e) {
         return;
     }
     lxfile_generic_chown("{$dir}/{$file}", $this->username);
     lxshell_unzip($this->username, $dir, "{$dir}/{$file}");
     lunlink("{$dir}/{$file}");
     $this->replaceVariables("{$dir}/index.html");
     // --- also copy /home/kloxo/httpd/user-logo.png to each domain path
     if (lxfile_exists("../file/user-logo.png")) {
         lxfile_cp("../file/user-logo.png", "{$dir}/images/logo.png");
     }
 }
Пример #23
0
function cp_if_not_exists($src, $dst)
{
    if (lxfile_exists($dst)) {
        return;
    }
    if (!lxfile_exists($src)) {
        return;
    }
    lxfile_cp($src, $dst);
}
Пример #24
0
 function updateupload_Logo($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $progname = $sgbl->__var_program_name;
     $parent = $this->getParentO();
     $imgname = $parent->getClName();
     $param['specialplay_b-logo_image'] = "/img/logo/{$imgname}.gif";
     $param['specialplay_b-logo_image_loading'] = "/img/logo/{$imgname}-loading.gif";
     make_sure_directory_is_lxlabs("__path_program_htmlbase/img/logo");
     if ($_FILES['logo_image_f']['tmp_name']) {
         lxfile_mv($_FILES['logo_image_f']['tmp_name'], "__path_program_htmlbase" . $param['specialplay_b-logo_image']);
     } else {
         lxfile_cp("__path_program_htmlbase/img/{$progname}-logo.gif", "__path_program_htmlbase" . $param['specialplay_b-logo_image']);
     }
     if ($_FILES['logo_image_loading_f']['tmp_name']) {
         lxfile_mv($_FILES['logo_image_loading_f']['tmp_name'], "__path_program_htmlbase" . $param['specialplay_b-logo_image_loading']);
     } else {
         lxfile_cp("__path_program_htmlbase/img/{$progname}-splash.gif", "__path_program_htmlbase" . $param['specialplay_b-logo_image_loading']);
     }
     $tsp = $parent->getObject("sp_childspecialplay");
     $tsp->specialplay_b->logo_image = $param['specialplay_b-logo_image'];
     $tsp->specialplay_b->logo_image_loading = $param['specialplay_b-logo_image_loading'];
     $tsp->setUpdateSubaction('upload_logo');
     $this->setUpdateSubaction('upload_logo');
     return $param;
 }
Пример #25
0
function lxfile_mv($src, $dst)
{
    global $gbl, $sgbl, $login, $ghtml;
    $src = expand_real_root($src);
    $dst = expand_real_root($dst);
    if (is_dir($dst)) {
        $base = basename($src);
        $dst = $dst . "/{$base}";
    }
    if ($sgbl->dbg > 0) {
        log_filesys("Moving {$src} {$dst}");
    }
    if (!lxfile_cp($src, $dst)) {
        lxfile_rm($src);
        return true;
    }
    return false;
}
Пример #26
0
function lxfile_cp_content_file($dirsource, $dirdest)
{
    $username = "******";
    $dirdest = expand_real_root($dirdest);
    $dirsource = expand_real_root($dirsource);
    if (!lxfile_exists($dirdest)) {
        lxfile_mkdir($dirdest);
    }
    $list = lscandir_without_dot($dirsource);
    foreach ($list as $l) {
        if (!is_dir("{$dirsource}/{$l}")) {
            lxfile_cp("{$dirsource}/{$l}", "{$dirdest}/{$l}");
        }
    }
}
Пример #27
0
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");
        }
    }
}
Пример #28
0
function doRealGetFromFileServ($cmd, $serv, $filepass, $copyto = null)
{
    $file = $filepass['file'];
    $pass = $filepass['pass'];
    $size = $filepass['size'];
    $base = basename($file);
    if ($serv === 'localhost') {
        $array = lfile_get_unserialize("__path_serverfile/{$base}");
        $realfile = $array['filename'];
        log_log("servfile", "getting local file {$realfile}");
        if (lxfile_exists($realfile) && lis_readable($realfile)) {
            lunlink("__path_serverfile/{$base}");
            if ($cmd === 'fileprint') {
                slow_print($realfile);
            } else {
                lxfile_mkdir(dirname($copyto));
                lxfile_cp($realfile, $copyto);
            }
            fileserv_unlink_if_tmp($realfile);
            return;
        }
        if (os_isSelfSystemUser()) {
            log_log("servfile", "is System User, but can't access {$realfile} returning");
            //return;
        } else {
            log_log("servfile", "is Not system user, can't access so will get {$realfile} through backend");
        }
    }
    $fd = null;
    if ($copyto) {
        lxfile_mkdir(dirname($copyto));
        $fd = lfopen($copyto, "wb");
        if (!$fd) {
            log_log("servfile", "Could not write to {$copyto}... Returning.");
            return;
        }
        lxfile_generic_chmod($copyto, "0700");
    }
    doGetOrPrintFromFileServ($serv, $filepass, $cmd, $fd);
    if ($fd) {
        fclose($fd);
    }
}
Пример #29
0
 function resizeImage()
 {
     $this->throw_if_not_magick();
     $oldimage = coreFfile::getRealPath($this->main->old_image_name_f);
     if ($this->main->isOn('copy_old_image_flag_f')) {
         lxfile_cp($this->main->getFullPath(), "{$this->main->root}/{$oldimage}");
     }
     $tfile = lx_tmp_file("resizeimage");
     lxfile_rm($tfile);
     $fp = $this->main->getFullPath();
     $fp = expand_real_root($fp);
     $ext = coreFfile::getExtension($fp);
     $tfile .= ".{$ext}";
     $geom = "{$this->main->image_width}x{$this->main->image_height}";
     lxfile_cp($this->main->getFullPath(), $tfile);
     lxuser_return($this->main->__username_o, "convert", "-scale", $geom, $tfile, $this->main->getFullPath());
     lxfile_rm($tfile);
 }
Пример #30
0
function fix_self_ssl()
{
    global $gbl, $sgbl, $login, $ghtml;
    $pgm = $sgbl->__var_program_name;
    $ret = lxshell_return("diff", "../etc/program.pem", "htmllib/filecore/old.program.pem");
    if (!$ret) {
        lxfile_cp("htmllib/filecore/program.pem", "../etc/program.pem");
    }
    //system("/etc/init.d/$pgm restart");
}