예제 #1
0
 static function getServiceDetails($list)
 {
     $ps = lxshell_output("ps", "ax");
     $run = Service__linux::getRunLevel();
     $rclist = lscandir_without_dot("__path_real_etc_root/rc{$run}.d/");
     foreach ($list as &$__l) {
         $__l['install_state'] = 'dull';
         $__l['state'] = 'off';
         $__l['boot_state'] = 'off';
         if (lxfile_exists("__path_real_etc_root/init.d/{$__l['servicename']}")) {
             $__l['install_state'] = 'on';
         } else {
             continue;
         }
         if (self::checkServiceInRc($rclist, $__l['servicename'])) {
             $__l['boot_state'] = 'on';
         }
         if ($__l['grepstring']) {
             if (preg_match("/[\\/ ]{$__l['grepstring']}/i", $ps)) {
                 $__l['state'] = 'on';
             }
         } else {
             $ret = lxshell_return("/etc/init.d/{$__l['servicename']}", "status");
             if ($ret) {
                 $__l['state'] = 'off';
             } else {
                 $__l['state'] = 'on';
             }
         }
     }
     return $list;
 }
예제 #2
0
function fixlogdir_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    $progname = $sgbl->__var_program_name;
    $logl = lscandir_without_dot("../log");
    lxfile_mkdir("../processed_log");
    @lunlink("../log/access_log");
    @lunlink("/usr/local/lxlabs/ext/php/error.log");
    $dir = getNotexistingFile("../processed_log", "proccessed");
    system("mv ../log ../processed_log/{$dir}");
    mkdir("../log");
    $list = lscandir_without_dot("../processed_log");
    foreach ($list as $l) {
        remove_directory_if_older_than_a_day("../processed_log/{$l}", 6);
    }
    foreach ($logl as $l) {
        lxfile_touch("../log/{$l}");
    }
    lxfile_generic_chown_rec("../log", "lxlabs:lxlabs");
    //
    // Related to Issue #15
    //
    lxfile_generic_chmod_rec("../log", "0640");
    lxfile_generic_chmod_rec("../processed_log", "0640");
    lxfile_generic_chmod("../log", "0700");
    lxfile_generic_chmod("../processed_log", "0700");
    lxfile_generic_chmod("../log/lighttpd_error.log", "0644");
    lxfile_generic_chmod("../log/access_log", "0644");
    lxfile_generic_chown("../log/lighttpd_error.log", "lxlabs:root");
    lxfile_generic_chown("../log/access_log", "lxlabs:root");
    //
    os_restart_program();
}
예제 #3
0
 static function getweb_usage($name, $customer_name, $oldtime, $newtime, $d)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $web_home = "{$sgbl->__path_httpd_root}";
     $log_path = "{$web_home}/{$name}/stats";
     $processedir = "{$sgbl->__path_customer_root}/{$customer_name}/__processed_stats/";
     lxfile_mkdir($processedir);
     $dir1 = "{$log_path}/";
     $files = lscandir_without_dot($dir1);
     $total = 0;
     foreach ($files as $file) {
         if (!strstr($file, "gz")) {
             $total += self::getEachwebfilequota("{$dir1}/{$file}", $oldtime, $newtime);
             $stat = stat("{$dir1}/{$file}");
             if ($stat['size'] >= 50 * 1024 * 1024) {
                 if (isOn($d->remove_processed_stats)) {
                     lxfile_rm("{$dir1}/{$file}");
                 } else {
                     lxfile_mv("{$dir1}/{$file}", getNotexistingFile($processedir, $file));
                 }
             }
         }
     }
     return $total;
 }
예제 #4
0
 static function getServiceList()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $val = lscandir_without_dot("__path_real_etc_root/init.d");
     $val = array_remove($val, $sgbl->__var_programname_web);
     $val = array_remove($val, $sgbl->__var_programname_dns);
     $val = array_remove($val, $sgbl->__var_programname_imap);
     $val = array_remove($val, $sgbl->__var_programname_mmail);
     $nval = self::getMainServiceList();
     $nval = lx_array_merge(array($nval, $val));
     return $nval;
 }
예제 #5
0
function __xenimport_get_data()
{
    lxfile_mkdir("/home/oldxenconfig-hypervm");
    $list = lscandir_without_dot("/etc/xen/oldxen");
    foreach ($list as $l) {
        $vm[] = __xenimport_parse_config("/etc/xen/oldxen/{$l}");
        //lxfile_mv("/etc/xen/$l", "/home/oldxenconfig-hypervm");
        lunlink("/etc/xen/auto/{$l}");
    }
    dprintr($vm);
    return $vm;
}
예제 #6
0
function __xenimport_get_data()
{
    lxfile_mkdir("/home/oldxenconfig-hypervm");
    $list = lscandir_without_dot("/home/xen");
    foreach ($list as $l) {
        if (!cse($l, ".vm")) {
            continue;
        }
        $vm[] = __xenimport_parse_config("/home/xen/{$l}/{$l}.cfg");
        //lxfile_mv("/etc/xen/$l", "/home/oldxenconfig-hypervm");
    }
    dprintr($vm);
    return $vm;
}
예제 #7
0
function __xenimport_get_data()
{
    lxfile_mkdir("/home/oldxenconfig-hypervm");
    $list = lscandir_without_dot("/etc/hypervm/");
    foreach ($list as $l) {
        if (!csb($l, "xm")) {
            continue;
        }
        if (csb($l, "xmexample")) {
            continue;
        }
        $vm[] = __xenimport_parse_config("/etc/xen/{$l}");
        //lxfile_mv("/etc/xen/$l", "/home/oldxenconfig-hypervm");
        lunlink("/etc/xen/auto/{$l}");
    }
    dprintr($vm);
    return $vm;
}
예제 #8
0
        $dns = $l->getObject('dns');
        $dns->setUpdateSubaction('full_update');
        if ($newip && $oldip) {
            foreach ($dns->dns_record_a as $drec) {
                if ($drec->ttype !== 'a') {
                    continue;
                }
                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");
예제 #9
0
function checkRestart()
{
    if (if_demo()) {
        return;
    }
    log_log("cron_exec", "Check service restarts...\n");
    $res = lscandir_without_dot("__path_program_etc/.restart");
    if ($res === false) {
        dprint(".restart does not exist... Creating\n");
        lxfile_mkdir("__path_program_etc/.restart");
        lxfile_generic_chown("__path_program_etc/.restart", "lxlabs");
    }
    foreach ((array) $res as $r) {
        if (csb($r, "._restart_")) {
            $cmd = strfrom($r, "._restart_");
        }
        lunlink("__path_program_etc/.restart/{$r}");
        dprint("Restarting {$cmd}\n");
        switch ($cmd) {
            case 'lxcollectquota':
                log_log("cron_exec", "Start collecting Quota's\n");
                exec_justdb_collectquota();
                break;
            case 'openvz_tc':
                log_log("cron_exec", "Start openvz_tc script\n");
                exec_openvz_tc();
                break;
            default:
                log_log("cron_exec", "Restarting {$cmd}\n");
                exec_with_all_closed("/etc/init.d/{$cmd} restart");
                break;
        }
    }
}
예제 #10
0
파일: lib.php 프로젝트: lonelywoolf/hypervm
function do_serve_file($fd, $rem)
{
    $file = $rem->filename;
    $file = basename($file);
    $file = "__path_serverfile/{$file}";
    if (!lxfile_exists($file)) {
        log_log("servfile", "datafile {$file} dosn't exist, exiting");
        print_or_write($fd, "fFile Doesn't {$file} Exist...\n\n\n\n");
        return false;
    }
    $array = lfile_get_unserialize($file);
    lunlink($file);
    $realfile = $array['filename'];
    $pass = $array['password'];
    if ($fd) {
        dprint("Got request for {$file}, realfile: {$realfile}\n");
    }
    log_log("servfile", "Got request for {$file} realfile {$realfile}");
    if (!($pass && $pass === $rem->password)) {
        print_or_write($fd, "fPassword doesn't match\n\n");
        return false;
    }
    if (is_dir($realfile)) {
        // This should neverhappen. The directories are zipped at cp-fileserv and tar_to_filserved then itself.
        $b = basename($realfile);
        lxfile_mkdir("__path_serverfile/tmp/");
        $tfile = tempnam("__path_serverfile/tmp/", "{$b}.tar");
        $list = lscandir_without_dot($realfile);
        lxshell_tar($realfile, $tfile, $list);
        $realfile = $tfile;
    }
    $fpr = lfopen($realfile, "rb");
    if (!$fpr) {
        print_or_write($fd, "fCouldn't open {$realfile}\n\n");
        return false;
    }
    print_or_write($fd, "s");
    while (!feof($fpr)) {
        $written = print_or_write($fd, fread($fpr, 8092));
        if ($written <= 0) {
            break;
        }
    }
    // Just send a newline so that the fgets will break after reading. This has to be removed after the file is read.
    print_or_write($fd, "\n");
    fclose($fpr);
    fileserv_unlink_if_tmp($realfile);
    return true;
}
예제 #11
0
파일: linuxfslib.php 프로젝트: zseand/kloxo
function lxfile_cp_content($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) {
        lxfile_cp_rec("{$dirsource}/{$l}", "{$dirdest}/{$l}");
    }
}
예제 #12
0
 function updatecollectModInfo()
 {
     $modlist = $this->getList('module');
     foreach ((array) $modlist as $m) {
         $m->delete();
         $m->metadbaction = 'writeonly';
     }
     $this->was();
     $list = lscandir_without_dot(getreal("/module/"));
     foreach ($list as $l) {
         if ($l === 'define.inc') {
             continue;
         }
         $m = new Module(null, null, $l);
         $m->dbaction = 'add';
         $m->parent_clname = $this->getClName();
         $m->write();
     }
     return null;
 }
예제 #13
0
 static function clear_extra_backups($class, $name, $object)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $progname = $sgbl->__var_program_name;
     $bpath = "__path_program_home/{$class}/{$name}/__backup";
     $list = lscandir_without_dot($bpath);
     $dellist = self::getDeleteList($object, $list);
     dprint("Delete list\n");
     dprintr($dellist);
     $num = $object->rm_last_number ? $object->rm_last_number : 5;
     print "Deleting Old backups.... Will retain {$num}.\n";
     $bpath = "__path_program_home/{$class}/{$name}/__backup";
     foreach ($dellist as $k => $v) {
         print "deleting {$v}\n";
         lunlink("{$bpath}/{$v}");
     }
     print "deleting old backups from ftp server\n";
     $fn = null;
     $mylogin = null;
     if (!$object->ftp_server) {
         return;
     }
     $fn = ftp_connect($object->ftp_server);
     $mylogin = ftp_login($fn, $object->rm_username, $object->rm_password);
     if (!$fn) {
         return;
     }
     $list = ftp_nlist($fn, $object->rm_directory);
     print "Total list of files in ftp server\n";
     print_r($list);
     $dellist = self::getDeleteList($object, $list);
     print "Deleting these files on remote server.\n";
     print_r($dellist);
     foreach ((array) $dellist as $k => $v) {
         $v = basename($v);
         if ($object->rm_directory) {
             $v = "{$object->rm_directory}/{$v}";
         }
         ftp_delete($fn, $v);
     }
     ftp_close($fn);
 }
예제 #14
0
function checkRestart()
{
    if (if_demo()) {
        return;
    }
    $res = lscandir_without_dot("__path_program_etc/.restart");
    if ($res === false) {
        dprint(".restart does not exist... Creating\n");
        lxfile_mkdir("__path_program_etc/.restart");
        lxfile_generic_chown("__path_program_etc/.restart", "lxlabs");
    }
    foreach ((array) $res as $r) {
        if (csb($r, "._restart_")) {
            $cmd = strfrom($r, "._restart_");
        }
        lunlink("__path_program_etc/.restart/{$r}");
        dprint("Restarting {$cmd}\n");
        // THe 3,4 etc are the tcp ports of this program, and it should be closed, else some programs will grab it.
        //exec("/etc/init.d/$cmd restart  </dev/null >/dev/null 2>&1 3</dev/null 4</dev/null 5</dev/null 6</dev/null &");
        switch ($cmd) {
            case 'lxcollectquota':
                exec_justdb_collectquota();
                break;
            case 'openvz_tc':
                exec_openvz_tc();
                break;
            default:
                exec_with_all_closed("/etc/init.d/{$cmd} restart");
                break;
        }
    }
}
예제 #15
0
function lxfile_dstat($dir, $duflag)
{
    $dir = expand_real_root($dir);
    $list = lscandir_without_dot($dir);
    $ret = null;
    foreach ($list as $l) {
        $stat = lstat("{$dir}/{$l}");
        get_file_type("{$dir}/{$l}", $stat);
        remove_unnecessary_stat($stat);
        if ($duflag && is_dir("{$dir}/{$l}") || $l === ".trash") {
            $stat['size'] = lxfile_dirsize("{$dir}/{$l}", true);
        } else {
            $stat['size'] = lxfile_size("{$dir}/{$l}");
        }
        $stat['name'] = "{$dir}/{$l}";
        $ret[] = $stat;
    }
    //dprintr($ret);
    return $ret;
}
예제 #16
0
 public function createTemplate()
 {
     $stem = explode("-", $this->main->ostemplate);
     if ($this->main->isWindows()) {
         $name = "{$stem[0]}-";
     } else {
         $name = "{$stem[0]}-{$stem[1]}-{$stem[2]}-";
     }
     $templatename = "{$name}{$this->main->newostemplate_name_f}";
     if ($this->main->isWindows()) {
         $tempfpath = "__path_program_home/xen/template/{$templatename}.img";
     } else {
         $tempfpath = "__path_program_home/xen/template/{$templatename}.tar.gz";
     }
     $this->stop();
     if ($this->main->isWindows()) {
         $partition = $this->getPartition();
         lxshell_return("ntfsfix", $partition);
         lxshell_return("ntfsclone", "--save-image", "--force", "-O", $tempfpath, $partition);
         $this->kpart_remove();
     } else {
         $list = lscandir_without_dot("{$this->main->configrootdir}/mnt");
         $ret = lxshell_return("tar", "-C", "{$this->main->configrootdir}/mnt", '--numeric-owner', "-czf", $tempfpath, $list);
     }
     $this->start();
     $filepass = cp_fileserv($tempfpath);
     $ret = array("__syncv___ostemplate_filepass" => $filepass, "__syncv___ostemplate_filename" => basename($tempfpath));
     return $ret;
 }
예제 #17
0
print_time("include");
include_once "htmllib/phplib/lib/lxclass.php";
include_once "htmllib/lib/commonfslib.php";
include_once "htmllib/lib/objectactionlib.php";
include_once "htmllib/lib/commandlinelib.php";
include_once "lib/sgbl.php";
include_once "lib/gbl.php";
include_once "htmllib/lib/lib.php";
include_once "htmllib/phplib/lxlib.php";
include_once "htmllib/phplib/common.inc";
include_once "htmllib/lib/remotelib.php";
include_once "htmllib/phplib/lib/lxdb.php";
include_once "lib/define.php";
include_once "lib/driver_define.php";
include_once "lib/sgbl.php";
include_once "lib/common.inc";
//include_once "htmllib/lib/xmlinclude.php";
// This is the program specific common lib. There is no need dump everything htmllib/lib/lib.php which has become too large.
include_once "lib/programlib.php";
if (lxfile_exists("../etc/classdefine")) {
    $list = lscandir_without_dot("../etc/classdefine");
    foreach ($list as $l) {
        if (cse($l, "phps")) {
            include_once "../etc/classdefine/{$l}";
        }
    }
}
if (WindowsOs()) {
    include_once "htmllib/lib/lxcomlib.php";
}
//print_time("include", "include");
예제 #18
0
파일: cronfix.php 프로젝트: soar-team/kloxo
<?php

include_once "htmllib/lib/include.php";
$path = "/var/spool/cron";
$list = lscandir_without_dot($path);
foreach ($list as $l) {
    lunlink("{$path}/{$l}");
}
initProgram('admin');
$login->loadAllObjects('cron');
$list = $login->getList('cron');
foreach ($list as $c) {
    $c->__parent_o = null;
    $w = $c->getParentO();
    $c->username = $w->username;
    $c->setUpdateSubaction('update');
    $c->was();
}
예제 #19
0
 static function initThisList($parent, $class)
 {
     // Load entire Session
     $result = null;
     $list = lscandir_without_dot("__path_program_root/session");
     foreach ($list as $l) {
         $pp = lfile_get_json_unserialize("__path_program_root/session/{$l}");
         if (!$pp) {
             lunlink("__path_program_root/session/{$l}");
             continue;
         }
         if (!$parent->isAdmin()) {
             //$result = $db->getRowsWhere("parent_clname = '" . $parent->getClName() . "'");
             if ($pp['parent_clname'] !== $parent->getClName()) {
                 continue;
             }
         }
         $result[] = $pp;
     }
     if ($result) {
         $parent->setListFromArray($parent->__masterserver, $parent->__readserver, 'ssessionlist', $result, true);
     }
     return null;
 }
예제 #20
0
 function updateform($subaction, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $progname = $sgbl->__var_program_name;
     switch ($subaction) {
         case "skin":
             // ACtually the skin_color list should be dependent on the skin_name,
             // but currently just reading the current skin directory itself.
             // So all the skins should have the same color sets, which is not very practical,
             // so this should be changed in the future.
             if (!$this->getParentO()->isLogin() || $this->isClass('sp_childspecialplay')) {
                 $vlist['specialplay_b-dont_show_disabled_permission'] = null;
             }
             $vlist['specialplay_b-enable_ajax'] = null;
             $vlist['specialplay_b-simple_skin'] = null;
             if ($this->specialplay_b->skin_name === 'feather') {
                 $vlist['specialplay_b-show_thin_header'] = null;
             }
             $vlist['specialplay_b-close_add_form'] = null;
             if (!$this->isAdmin()) {
                 $list = get_namelist_from_objectlist($login->getList('interface_template'));
                 $list = lx_array_merge(array(array("--{$progname}-default--"), $list));
             }
             //$vlist['specialplay_b-interface_template'] = array('s', $list);
             $vlist['specialplay_b-skin_name'] = array('s', lscandir_without_dot(getreal("/img/skin/{$progname}")));
             $vlist['specialplay_b-skin_color'] = array('s', lscandir_without_dot(getreal("/img/skin/{$progname}/" . $this->specialplay_b->skin_name)));
             // DT #799 - Scan also the dir for new iconsets.
             $vlist['specialplay_b-icon_name'] = array('s', lscandir_without_dot(getreal("/img/image")));
             $vlist['specialplay_b-language'] = array('A', $this->getLanguage());
             //$vlist['specialplay_b-login_page'] =array('s', $this->getParentO()->getLoginTo());
             //$vlist['specialplay_b-split_frame'] = null;
             //$vlist['specialplay_b-show_help'] =null;
             if ($this->getParentO()->isLte('reseller') && $sgbl->isKloxo()) {
                 $vlist['specialplay_b-customermode_flag'] = null;
             }
             //$vlist['specialplay_b-disable_quickaction'] = null;
             if (!$this->getParentO()->isLogin()) {
                 $vlist['specialplay_b-logo_image'] = null;
                 $vlist['specialplay_b-logo_image_loading'] = null;
             }
             /*
             	if ($sgbl->isKloxo()) {
             		if (!$this->getParentO()->isLogin()) {
             			$vlist['specialplay_b-disable_docroot'] = null;
             		}
             	}
             */
             //$vlist['specialplay_b_s_show_add_buttons'] =null;
             //$vlist['specialplay_b-lpanel_scrollbar'] = null;
             //$vlist['specialplay_b-resource_bottom'] =null;
             //$vlist['specialplay_b_s_show_brethren_list'] = array('s', array('off', 'top', 'left'));
             //$vlist['specialplay_b_s_lpanel_group_resource'] =null;
             //$vlist['specialplay_b_s_ultra_navig'] =null;
             //$vlist['specialplay_b-lpanel_depth'] = null;
             $vlist['__v_updateall_button'] = array();
             //$vlist['specialplay_b_s_per_page'] = null;
             return $vlist;
         case "upload_logo":
             if ($login->priv->isOn('logo_manage_flag')) {
                 //	$vlist['specialplay_b-logo_image'] =array('I', array("width" => 20, "height" => 20, "value" => $this->specialplay_b->logo_image));
                 // trick use 'null' for guarantee 100% size of img (not 100% size div container)
                 $vlist['specialplay_b-logo_image'] = array('I', array("width" => "null", "height" => "null", "value" => "/img/user-logo.png"));
                 $vlist['logo_image_f'] = null;
                 //	$vlist['specialplay_b-logo_image_loading'] =array('I', array("width" => 20, "height" => 20, "value" => $this->specialplay_b->logo_image_loading));
                 //	$vlist['logo_image_loading_f'] = null;
             }
             return $vlist;
         case "login_options":
             if ($login->isAdmin()) {
                 $gen = $login->getObject('general')->generalmisc_b;
                 $this->specialplay_b->disableipcheck = $gen->disableipcheck;
                 $vlist['specialplay_b-disableipcheck'] = null;
             }
             $vlist['specialplay_b-ssession_timeout'] = null;
             return $vlist;
         case "demo_status":
             $vlist['specialplay_b-demo_status'] = null;
             return $vlist;
     }
 }
예제 #21
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");
        }
    }
}
예제 #22
0
 function top_level_simple_backup()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $progname = $sgbl->__var_program_name;
     $dir = dirname($this->main->__var_bc_filename);
     $name = basename($this->main->__var_bc_filename);
     $firstname = strtil($name, "-");
     lxfile_mkdir($dir);
     $list = lscandir_without_dot($dir);
     $bc = $this->do_backup();
     $tmpdir = createTempDir("{$sgbl->__path_tmp}", "backupfile");
     lfile_put_contents("{$tmpdir}/{$progname}.file", $this->main->__var_bc_metafile);
     lfile_put_contents("{$tmpdir}/{$progname}.metadata", $this->main->__var_bc_metadata);
     $newarray = lx_array_merge(array($bc[1], array("{$tmpdir}/{$progname}.file", "{$tmpdir}/{$progname}.metadata")));
     if ($this->main->getZiptype() === 'zip') {
         lxshell_zip($bc[0], $this->main->__var_bc_filename, $newarray);
     } else {
         if ($this->main->getZiptype() === 'tar') {
             lxshell_tar($bc[0], $this->main->__var_bc_filename, $newarray);
         } else {
             lxshell_tgz($bc[0], $this->main->__var_bc_filename, $newarray);
         }
     }
     print_time("cpzip", "Copy and Zip");
     lxfile_tmp_rm_rec("{$tmpdir}");
     $this->do_backup_cleanup($bc);
 }
예제 #23
0
 function createThumbnail()
 {
     $this->throw_if_not_magick();
     $dir = $this->main->getFullPath();
     $list = lscandir_without_dot($dir);
     lxfile_mkdir("{$dir}/thumbs");
     $geom = "{$this->main->image_width}x{$this->main->image_height}";
     dprintr($list);
     foreach ($list as $l) {
         if (!coreFfile::is_image($l)) {
             continue;
         }
         $newf = "{$dir}/thumbs/th_{$l}";
         lxuser_return($this->main->__username_o, "convert", "-scale", $geom, "{$dir}/{$l}", $newf);
     }
 }
예제 #24
0
 static function rotateLog($processedir, $file)
 {
     $stat = stat($file);
     if ($stat['size'] >= 10 * 1024 * 1024) {
         lxfile_mv($file, getNotexistingFile($processedir, basename($file)));
         createRestartFile("syslog");
     }
     $list = lscandir_without_dot($processedir);
     foreach ($list as $k) {
         $file = "{$processedir}/{$k}";
         $stat = stat($file);
         if ($stat['mtime'] < time() - 10 * 24 * 3600) {
             dprint("deleting old log {$file}\n");
             lxfile_rm($file);
         }
     }
 }