Example #1
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");
 }
 function writeAuthorizedKey($key)
 {
     if_demo_throw_exception('sshkey');
     $username = $this->main->username;
     $p = os_get_home_dir($username);
     if (!$p) {
         return;
     }
     lxfile_mkdir("{$p}/.ssh");
     $f = "{$p}/.ssh/authorized_keys";
     lfile_put_contents($f, $key);
     lxfile_unix_chown_rec("{$p}/.ssh", "{$username}:{$username}");
     lxfile_unix_chmod("{$p}/.ssh", "0700");
     lxfile_unix_chmod($f, "0700");
 }
Example #3
0
 function createDavSuexec()
 {
     $string = null;
     $uid = os_get_uid_from_user($this->main->__var_system_username);
     $gid = os_get_gid_from_user($this->main->__var_system_username);
     $string .= "#!/bin/sh\n";
     $string .= "export MUID={$uid}\n";
     $string .= "export GID={$gid}\n";
     $string .= " export PHPRC=/usr/local/lxlabs/ext/php/etc/php.ini\n";
     $string .= "export TARGET=<%program%>\n";
     $string .= "export NON_RESIDENT=1\n";
     $string .= "exec lxsuexec \$*\n";
     $st = str_replace("<%program%>", "/usr/local/lxlabs/ext/php/bin/php_cgi", $string);
     lfile_put_contents("__path_httpd_root/{$this->main->getParentName()}/davsuexec.sh", $st);
     lxfile_unix_chmod("__path_httpd_root/{$this->main->getParentName()}/davsuexec.sh", "0755");
 }
Example #4
0
 function createUser()
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!$sgbl->isKloxo()) {
         return;
     }
     $password = $this->main->password;
     $cmd = "useradd";
     $shell = fix_disabled("--Disabled--", $sgbl->__var_noaccess_shell);
     $username = $this->main->getPathFromName();
     if (is_numeric($username[0])) {
         $username = "******";
     }
     $username = os_create_system_user($username, $password, $this->main->nname, $shell, "__path_customer_root/{$this->main->getPathFromName()}/");
     lxfile_unix_chown("__path_customer_root/{$this->main->getPathFromName()}", "{$username}:apache");
     lxfile_unix_chmod("__path_customer_root/{$this->main->getPathFromName()}", "750");
     $this->main->username = $username;
     $this->setQuota();
     $ret = array("__syncv_username" => $username);
     return $ret;
 }
 static function readMailqueue()
 {
     lxfile_unix_chmod("__path_program_root/bin/misc/qmHandle", "0755");
     $res = lxshell_output("__path_program_root/bin/misc/qmHandle", "-l");
     $list = array('subject', 'to', 'from', 'date', 'size');
     //$res = lfile_get_contents("a.txt");
     $res = explode("\n", $res);
     //dprintr($res);
     $i = 0;
     foreach ($res as $r) {
         $r = trim($r);
         if (!$r) {
             $i++;
             continue;
         }
         if (is_numeric($r[0])) {
             list($nname, $s, $ss) = explode(" ", $r);
             $ret[$i]['nname'] = $nname;
             if (cse($ss, 'R)')) {
                 $ret[$i]['type'] = 'remote';
             } else {
                 $ret[$i]['type'] = 'local';
             }
             continue;
         }
         foreach ($list as $l) {
             $ul = ucfirst($l);
             if (csb($r, "{$ul}:")) {
                 $ret[$i][$l] = strfrom($r, "{$ul}:");
                 if ($l === 'size') {
                     $ret[$i][$l] = strtil($ret[$i][$l], " bytes");
                     $ret[$i][$l] = trim($ret[$i][$l]);
                 }
             }
         }
     }
     return $ret;
 }
Example #6
0
function setup_scpid($cont)
{
    global $global_dontlogshell;
    $global_dontlogshell = true;
    $home = os_get_home_dir("root");
    $file = "{$home}/.ssh/authorized_keys2";
    lxfile_mkdir("{$home}/.ssh");
    lxfile_unix_chmod("{$home}/.ssh", "0700");
    addLineIfNotExistInside($file, "\n{$cont}", '');
    lxfile_unix_chmod($file, "0700");
    $global_dontlogshell = false;
    return lfile_get_contents("/etc/ssh/ssh_host_rsa_key.pub");
}
Example #7
0
 function dbactionUpdate($subaction)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if_demo_throw_exception('ffile');
     $this->aux = new Ffile__common(null, null, $this->nname);
     $this->aux->main = $this->main;
     if ($this->main->isOn('readonly')) {
         throw new lxexception('file_manager_is_readonly', '');
     }
     $chownug = "{$this->main->__username_o}:{$this->main->__username_o}";
     switch ($subaction) {
         case "fancyedit":
         case "edit":
             lxuser_put_contents($chownug, $this->main->getFullPath(), $this->main->content);
             lxuser_return($chownug, "dos2unix", $this->main->getFullPath());
             lxuser_chmod($chownug, $this->main->getFullPath(), "0644");
             break;
         case "upload_s":
             $filename = $this->aux->uploadDirect();
             lxuser_chmod($chownug, $filename, "0644");
             lxfile_generic_chown($filename, $chownug);
             break;
         case "rename":
             $this->aux->reName();
             break;
         case "paste":
             $this->aux->filePaste();
             break;
         case "perm":
             $arg = null;
             $perm = $this->main->newperm;
             $perm = 0 . $perm;
             if ($this->main->isOn('recursive_f')) {
                 new_process_chmod_rec($this->main->__username_o, $this->main->fullpath, $perm);
             } else {
                 lxfile_unix_chmod($this->main->fullpath, "{$perm}");
             }
             break;
         case "newdir":
             $path = $this->aux->newDir();
             lxfile_unix_chown($path, $chownug);
             break;
         case "content":
             if ($this->main->is_image()) {
                 $this->aux->resizeImage();
             } else {
                 throw new lxexception('cannot_save_content', '');
             }
             break;
         case "thumbnail":
             $this->aux->createThumbnail();
             break;
         case "convert_image":
             $this->aux->convertImage();
             break;
         case "zip_file":
             $zipfile = $this->aux->zipFile();
             break;
         case "filedelete":
             $this->aux->moveAllToTrash();
             break;
         case "filerealdelete":
             $this->aux->fileRealDelete();
             break;
         case "restore_trash":
             $this->aux->restoreTrash();
             break;
         case "clear_trash":
             $this->aux->clearTrash();
             break;
         case "download_from_http":
             $fullpath = $this->aux->downloadFromHttp();
             lxfile_unix_chown($fullpath, $chownug);
             break;
         case "download_from_ftp":
             $fullpath = $this->aux->downloadFromFtp();
             lxfile_unix_chown($fullpath, $chownug);
             break;
         case "zipextract":
             $dir = $this->aux->zipExtract();
             break;
     }
 }
Example #8
0
function lxfile_generic_chmod($file, $mod)
{
    lxfile_unix_chmod($file, $mod);
}
Example #9
0
<?php

include_once "htmllib/lib/include.php";
initProgram('admin');
$login->loadAllObjects('client');
$list = $login->getList('client');
foreach ($list as $l) {
    lxfile_unix_chown("__path_customer_root/{$l->getPathFromName('nname')}", "{$l->username}:apache");
    lxfile_unix_chmod("__path_customer_root/{$l->getPathFromName('nname')}", "0750");
}
Example #10
0
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');
    }
}
Example #11
0
 static function switchProgramPre($old, $new)
 {
     // issue #589 - Change httpd config structure
     if ($new === 'apache') {
         lxfile_cp("/etc/sysconfig/httpd", "/etc/sysconfig/httpd.bck");
         $ret = lxshell_return("yum", "-y", "install", "httpd", "mod_ssl");
         if ($ret) {
             throw new lxexception('install_httpd_failed', 'parent');
         }
         lxfile_rm("/etc/sysconfig/httpd");
         lxfile_mv("/etc/sysconfig/httpd.bck", "/etc/sysconfig/httpd");
         lxshell_return("service", "lighttpd", "stop");
         lxshell_return("rpm", "-e", "--nodeps", "lighttpd");
         lunlink("/etc/init.d/lighttpd");
         lxshell_return("chkconfig", "httpd", "on");
     } else {
         $ret = lxshell_return("yum", "-y", "install", "lighttpd", "lighttpd-fastcgi");
         if ($ret) {
             throw new lxexception('install_lighttpd_failed', 'parent');
         }
         lxfile_unix_chmod("/etc/init.d/lighttpd", "0755");
         lxshell_return("service", "httpd", "stop");
         lxshell_return("rpm", "-e", "--nodeps", "httpd");
         lxshell_return("chkconfig", "lighttpd", "on");
     }
     if ($new === 'apache') {
         //		addLineIfNotExistInside("/etc/httpd/conf/httpd.conf", "Include /etc/httpd/conf/kloxo/kloxo.conf", "");
         lxshell_return("__path_php_path", "../bin/misc/installsuphp.php");
         //lxshell_return("__path_php_path", "../bin/fix/fixfrontpage.php");
     } else {
         lxfile_mkdir("/etc/lighttpd/");
         lxfile_mkdir("/etc/lighttpd/conf/kloxo");
         lxfile_cp("../file/lighttpd/lighttpd.conf", "/etc/lighttpd/lighttpd.conf");
         //		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/etc_init.d", "/etc/init.d/lighttpd");
         lxfile_unix_chmod("/etc/init.d/lighttpd", "0755");
         lxfile_mkdir("/home/kloxo/httpd/lighttpd");
         lxfile_unix_chown("/home/kloxo/httpd/lighttpd", "apache");
     }
 }
Example #12
0
function os_create_program_service()
{
    global $gbl, $sgbl, $login, $ghtml;
    $CoreInit = '__path_program_htmlbase/htmllib/filecore/hypervm.init.program';
    lxfile_cp($CoreInit, '/etc/init.d/hypervm');
    lxfile_unix_chmod('/etc/init.d/hypervm', '0755');
    $CorePHP = '__path_program_htmlbase/htmllib/filecore/php.ini';
    lxfile_cp($CorePHP, '__path_lxlabs_base/ext/php/etc/php.ini');
}
Example #13
0
 function fullUpdate()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $this->createConffile();
     $this->createSuexec();
     //	$this->updateMainConfFile();
     self::createSSlConf($this->main->__var_ipssllist, $this->main->__var_domainipaddress);
     //	self::createWebDefaultConfig();
     web::createstatsConf($this->main->nname, $this->main->stats_username, $this->main->stats_password);
     $log_path = "/home/httpd/{$this->main->nname}/stats";
     lxfile_unix_chown_rec($log_path, "{$this->main->username}:apache");
     lxfile_unix_chmod_rec($log_path, "770");
     $this->main->createPhpInfo();
     lxfile_unix_chown("__path_httpd_root/{$this->main->nname}", "{$this->main->username}:apache");
     lxfile_unix_chmod("__path_httpd_root/{$this->main->nname}", "0755");
     lxfile_unix_chmod("{$this->main->getFullDocRoot()}", "0755");
 }
Example #14
0
File: lib.php Project: zseand/kloxo
function updatecleanup()
{
    setPrepareKloxo();
    // Fixes #303 and #304
    installThirdparty();
    install_gd();
    install_bogofilter();
    setInitialPhpMyAdmin();
    setInitialAdminAccount();
    setInitialKloxoPhp();
    installWebmail();
    installAwstats();
    setRemoveOldDirs();
    setInitialBinary();
    log_cleanup("Remove lighttpd errorlog");
    log_cleanup("- Remove process");
    remove_lighttpd_error_log();
    log_cleanup("Fix the secure logfile");
    log_cleanup("- Fix process");
    call_with_flag("fix_secure_log");
    log_cleanup("Clean hosts.deny");
    log_cleanup("- Clean process");
    call_with_flag("remove_host_deny");
    log_cleanup("Turn off mouse daemon");
    log_cleanup("- Turn off process");
    system("chkconfig gpm off");
    if (lxfile_exists("phpinfo.php")) {
        log_cleanup("Remove phpinfo.php");
        log_cleanup("- Remove process");
        lxfile_rm("phpinfo.php");
    }
    setInitialBind();
    log_cleanup("Killing gettraffic system process");
    log_cleanup("- Killing process");
    lxshell_return("pkill", "-f", "gettraffic");
    setCheckPackages();
    copy_script();
    install_xcache();
    log_cleanup("Install Kloxo service");
    log_cleanup("- Install process");
    lxfile_unix_chmod("/etc/init.d/kloxo", "0755");
    system("chkconfig kloxo on");
    setJailshellSystem();
    log_cleanup("Set /home permission to 0755");
    log_cleanup("- Set process");
    lxfile_unix_chmod("/home", "0755");
    setExecuteCentos5Script();
    fix_rhn_sources_file();
    setInitialApacheConfig();
    setInitialPureftpConfig();
    setInstallMailserver();
    log_cleanup("Enable xinetd service");
    log_cleanup("- Enable process");
    call_with_flag("enable_xinetd");
    fix_suexec();
    if (!lxfile_exists("/usr/bin/php-cgi")) {
        log_cleanup("Initialize php-cgi binary");
        log_cleanup("- Initialize process");
        lxfile_cp("/usr/bin/php", "/usr/bin/php-cgi");
    }
    setSomePermissions();
    setInitialLighttpdConfig();
    setInitialNobodyScript();
    setSomeScript();
    log_cleanup("Install /etc/init.d/djbdns service file");
    log_cleanup("- Install process");
    lxfile_cp("../file/djbdns.init", "/etc/init.d/djbdns");
    removeOtherDrivers();
    log_cleanup("Remove cache dir");
    log_cleanup("- Remove process");
    lxfile_rm_rec("__path_program_root/cache");
    log_cleanup("Restart syslog service");
    log_cleanup("- Restart process");
    createRestartFile('syslog');
    log_cleanup("Initialize awstats dirdata");
    log_cleanup("- Initialize process");
    lxfile_mkdir("/home/kloxo/httpd/awstats/dirdata");
    setInitialLogrotate();
    installRoundCube();
    installHorde();
    installChooser();
    log_cleanup("Remove old lxlabs ssh key");
    log_cleanup("- Remove process");
    remove_ssh_self_host_key();
    setInitialServer();
    setDefaultPages();
    installInstallApp();
    setFreshClam();
    changeMailSoftlimit();
}
Example #15
0
function updatecleanup_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    $program = $sgbl->__var_program_name;
    $opt = parse_opt($argv);
    if ($opt['type'] === 'master') {
        initProgram('admin');
        $flg = "__path_program_start_vps_flag";
        if (!lxfile_exists($flg)) {
            set_login_skin_to_feather();
        }
    } else {
        $login = new Client(null, null, 'update');
    }
    log_cleanup("*** Executing Update (cleanup) - BEGIN ***");
    //
    // 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");
    }
    // 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");
    }
    //
    if (lxfile_exists(".svn")) {
        log_cleanup("- SVN Found... Exiting");
        exit;
    }
    if ($opt['type'] === 'master') {
        $sgbl->slave = false;
        if (!is_secondary_master()) {
            updateDatabaseProperly();
            fixDataBaseIssues();
            doUpdates();
            lxshell_return("__path_php_path", "../bin/common/driverload.php");
        }
        update_all_slave();
        cp_dbfile();
    } else {
        $sgbl->slave = true;
    }
    if (!is_secondary_master()) {
        updatecleanup();
    }
    if ($opt['type'] === 'master') {
        lxfile_touch("__path_program_start_vps_flag");
    }
    // issue #716 -- [beta] Unresolved dependency on Apache version
    // --- remove httpd-itk rpm (from webtatic.repo or others) because may conflict with
    // httpd 2.2.21 that include mpm itk beside mpm worker and event
    exec("rpm -q httpd-itk | grep -i 'not installed'", $out, $ret);
    // --- not work with !$ret
    if ($ret !== 0) {
        log_cleanup("Remove httpd-itk rpm package");
        log_cleanup("- Remove httpd-itk");
        exec("rpm -e httpd-itk --nodeps");
        exec("rpm -q httpd | grep -i 'not installed'", $out2, $ret2);
        if ($ret2 === 0) {
            log_cleanup("- Reinstall httpd");
            exec("yum reinstall httpd -y");
        }
    }
    // MR -- mysql not start after kloxo slave install
    log_cleanup("Preparing MySQL service");
    log_cleanup("- MySQL activated");
    exec("chkconfig mysqld on");
    log_cleanup("- MySQL restarted");
    exec("service mysqld restart");
    // MR -- importance for update from 6.1.6 or previous where change apache/lighttpd structure
    // or others for next version
    $slist = array("httpd*", "lighttpd*", "bind*", "djbdns*", "pure-ftpd*", "php*", "vpopmail", "courier-imap-toaster", "courier-authlib-toaster", "qmail", "safecat", "spamassassin", "bogofilter", "ezmlm-toaster", "autorespond-toaster", "clamav-toaster");
    setUpdateServices($slist);
    // MR -- use this trick for qmail non-daemontools based
    log_cleanup("Preparing some services again");
    log_cleanup("- courier-imap enabled and restart queue");
    exec("chkconfig courier-imap on");
    createRestartFile("courier-imap");
    log_cleanup("- qmail enabled and restart queue");
    exec("chkconfig qmail on");
    createRestartFile("qmail");
    $fixapps = array("dns", "web", "php", "mail", "ftpuser", "vpop");
    setUpdateConfigWithVersionCheck($fixapps, $opt['type']);
    // --- for anticipate change xinetd listing
    exec("service xinetd restart");
}
Example #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");
}
Example #17
0
 function fullUpdate()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $domname = $this->main->nname;
     $uname = $this->main->username;
     $hroot = $sgbl->__path_httpd_root;
     $droot = $this->main->getFullDocRoot();
     lxfile_mkdir("{$hroot}/{$domname}/webstats");
     $this->main->createPhpInfo();
     web::createstatsConf($domname, $this->main->stats_username, $this->main->stats_password);
     self::createSSlConf($this->main->__var_ipssllist, $this->main->__var_domainipaddress);
     $this->createConffile();
     // Removed recursive
     lxfile_unix_chown("{$droot}/", "{$uname}:{$uname}");
     lxfile_unix_chmod("{$droot}/", "0755");
     lxfile_unix_chmod("{$droot}", "0755");
     lxfile_unix_chown("{$hroot}/{$domname}", "{$uname}:apache");
 }
Example #18
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");
     }
 }
Example #19
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");
        }
    }
}
Example #20
0
        exit;
    }
}
lxshell_return("service", "lxadmin", "stop");
lxshell_return("chkconfig", "lxadmin", "off");
lxfile_rm("/etc/init.d/lxadmin");
lxfile_mkdir("/usr/local/lxlabs/kloxo");
chdir("/usr/local/lxlabs/kloxo/");
lxfile_rm("kloxo-current.zip");
system("wget http://download.lxcenter.org/download/kloxo/production/kloxo/kloxo-current.zip");
system("unzip -oq kloxo-current.zip");
lxfile_rm_rec("/usr/local/lxlabs/kloxo/etc/");
lxfile_cp_rec("/usr/local/lxlabs/lxadmin/etc/", "/usr/local/lxlabs/kloxo/etc/");
if (!$sgbl->is_this_slave()) {
    system("service mysqld stop");
    if (!lxfile_exists("/var/lib/mysql/kloxo/")) {
        lxfile_cp_rec("/var/lib/mysql/lxadmin4_2", "/var/lib/mysql/kloxo");
    }
    lxfile_unix_chown_rec("/var/lib/mysql/kloxo", "mysql:mysql");
    system("service mysqld start");
    sleep(10);
    chdir("/usr/local/lxlabs/lxadmin/httpdocs/");
    passthru("lphp.exe ../bin/kloxo-db.php");
}
lxfile_cp("/usr/local/lxlabs/kloxo/httpdocs/htmllib/filecore/init.program", "/etc/init.d/kloxo");
lxfile_cp("/usr/local/lxlabs/lxadmin/etc/conf/lxadmin.pass", "/usr/local/lxlabs/kloxo/etc/conf/kloxo.pass");
lxfile_unix_chmod("/etc/init.d/kloxo", "0755");
lxshell_return("chkconfig", "kloxo", "on");
chdir("/usr/local/lxlabs/kloxo/httpdocs/");
passthru("lphp.exe ../bin/kloxo-migrate.php");
print "\n\n\nMigration to Kloxo Succesful. Please reboot the server for everything to take effect.\n\n";