function setMysqlOptimize($select, $database = null) { global $gbl, $sgbl, $login, $ghtml; log_cleanup("Mysql Optimization"); $database = $database ? $database : "_all_"; $pass = slave_get_db_pass(); if ($select === 'repair') { log_cleanup("- Repairing database"); if ($database === '_all_') { system("mysqlcheck --user=root --password=\"{$pass}\" --repair --all-databases"); } else { system("mysqlcheck --user=root --password=\"{$pass}\" --repair --databases {$dbname}"); } } else { if ($select === 'optimize') { log_cleanup("- Compacting database"); if ($database === '_all_') { system("mysqlcheck --user=root --password=\"{$pass}\" --optimize --all-databases"); } else { system("mysqlcheck --user=root --password=\"{$pass}\" --optimize --databases {$dbname}"); } } } log_cleanup("- MySQL Service restart"); $ret = lxshell_return("service", "mysqld", "restart"); if ($ret) { throw new lxexception('mysqld_restart_failed', 'parent'); } }
function setFixChownChmod($select) { global $gbl, $sgbl, $login, $ghtml; $login->loadAllObjects('client'); $list = $login->getList('client'); // --- still problem when switch to suphp use chmod 750 for userdir and then back to 770 // so, for compromise set /home/kloxo/httpd to 770 because less importance than /home/<client> $httpddirchmod = '770'; $userdirchmod = '750'; $phpfilechmod = '644'; $domdirchmod = '755'; // --- change because escape form suphp error // --- for /home/kloxo/httpd dirs (defaults pages) log_cleanup("Fix file permission problems for defaults pages (chown/chmod files)"); system("chown -R lxlabs:lxlabs /home/kloxo/httpd/"); log_cleanup("- chown lxlabs:lxlabs FOR INSIDE /home/kloxo/httpd/"); system("chown lxlabs:apache /home/kloxo/httpd/"); log_cleanup("- chown lxlabs:apache FOR /home/kloxo/httpd/"); system("find /home/kloxo/httpd/ -type f -name \"*.php*\" -exec chmod {$phpfilechmod} \\{\\} \\;"); log_cleanup("- chmod {$phpfilechmod} FOR *.php* INSIDE /home/kloxo/httpd/"); system("find /home/kloxo/httpd/ -type d -exec chmod {$domdirchmod} \\{\\} \\;"); log_cleanup("- chmod {$domdirchmod} FOR /home/kloxo/httpd/ AND INSIDE"); system("chmod {$httpddirchmod} /home/kloxo/httpd/"); log_cleanup("- chmod {$httpddirchmod} FOR /home/kloxo/httpd/"); // --- for domain dirs log_cleanup("Fix file permission problems for domains (chown/chmod files)"); foreach ($list as $c) { $clname = $c->getPathFromName('nname'); $cdir = "/home/{$clname}"; $dlist = $c->getList('domaina'); $ks = "kloxoscript"; system("chown {$clname}:apache {$cdir}/"); log_cleanup("- chown {$clname}:apache FOR {$cdir}/"); system("chmod {$userdirchmod} {$cdir}/"); log_cleanup("- chmod {$userdirchmod} FOR {$cdir}/"); system("chown -R {$clname}:{$clname} {$cdir}/{$ks}/"); log_cleanup("- chown {$clname}:{$clname} FOR INSIDE {$cdir}/{$ks}/"); system("chown {$clname}:apache {$cdir}/{$ks}/"); log_cleanup("- chown {$clname}:apache FOR {$cdir}/{$ks}/"); system("find {$cdir}/{$ks}/ -type f -name \"*.php*\" -exec chmod {$phpfilechmod} \\{\\} \\;"); log_cleanup("- chmod {$phpfilechmod} FOR *.php* INSIDE {$cdir}/{$ks}/"); system("find {$cdir}/{$ks}/ -type d -exec chmod {$domdirchmod} \\{\\} \\;"); log_cleanup("- chmod {$domdirchmod} FOR {$cdir}/{$ks}/ AND INSIDE"); foreach ((array) $dlist as $l) { $web = $l->nname; if ($select === "all" || $select === 'chown') { system("chown -R {$clname}:{$clname} {$cdir}/{$web}/"); log_cleanup("- chown {$clname}:{$clname} FOR INSIDE {$cdir}/{$web}/"); } if ($select === "all" || $select === 'chmod') { system("find {$cdir}/{$web}/ -type f -name \"*.php*\" -exec chmod {$phpfilechmod} \\{\\} \\;"); log_cleanup("- chmod {$phpfilechmod} FOR *.php* INSIDE {$cdir}/{$web}/"); system("find {$cdir}/{$web}/ -type d -exec chmod {$domdirchmod} \\{\\} \\;"); log_cleanup("- chmod {$domdirchmod} FOR {$cdir}/{$web}/ AND INSIDE"); } system("chown {$clname}:apache {$cdir}/{$web}/"); log_cleanup("- chown {$clname}:apache FOR {$cdir}/{$web}/"); } } }
function setFixUserlogoDomainPages() { global $gbl, $sgbl, $login, $ghtml; $login->loadAllObjects('client'); $list = $login->getList('client'); foreach ($list as $c) { $clname = $c->getPathFromName('nname'); $cdir = "/home/{$clname}"; $dlist = $c->getList('domaina'); foreach ((array) $dlist as $l) { $web = $l->nname; system("cp -rf /home/kloxo/httpd/user-logo.png {$cdir}/{$web}/images/logo.png"); log_cleanup("- User logo for domain pages moved to -> {$cdir}/{$web}/images/logo.png"); } } }
function setFixUserlogoDomainPages() { global $gbl, $sgbl, $login, $ghtml; $login->loadAllObjects('client'); $list = $login->getList('client'); foreach ($list as $c) { $clname = $c->getPathFromName('nname'); $cdir = "/home/{$clname}"; $dlist = $c->getList('domaina'); foreach ((array) $dlist as $l) { $web = $l->nname; // If there is no images directory so need to create that first if (!lxfile_exists("{$cdir}/{$web}/images")) { lxfile_mkdir("{$cdir}/{$web}/images"); } system("cp -rf /home/kloxo/httpd/user-logo.png {$cdir}/{$web}/images/logo.png"); log_cleanup("- User logo for domain pages moved to -> {$cdir}/{$web}/images/logo.png"); } } }
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"); }
function fixDataBaseIssues() { log_cleanup("Fix Database Issues"); log_cleanup("- Fix admin account database settings"); $sq = new Sqlite(null, 'domain'); $sq->rawQuery("update domain set priv_q_php_flag = 'on'"); $sq->rawQuery("update web set priv_q_php_flag = 'on'"); $sq->rawQuery("update client set priv_q_php_flag = 'on'"); $sq->rawQuery("update client set priv_q_addondomain_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_rubyrails_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_rubyfcgiprocess_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_mysqldb_usage = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_phpfcgi_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_phpfcgiprocess_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_subdomain_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_totaldisk_usage = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_php_manage_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_installapp_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_cron_minute_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_document_root_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_runstats_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_webhosting_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update ticket set parent_clname = 'client-admin' where subject = 'Welcome to Kloxo'"); $sq->rawQuery("update domain set dtype = 'maindomain' where dtype = 'domain'"); log_cleanup("- Set default database settings"); db_set_default('mmail', 'remotelocalflag', 'local'); db_set_default('mmail', 'syncserver', 'localhost'); db_set_default('dns', 'syncserver', 'localhost'); db_set_default('pserver', 'coma_psrole_a', ',web,dns,mmail,mysqldb,'); db_set_default('web', 'syncserver', 'localhost'); db_set_default('uuser', 'syncserver', 'localhost'); db_set_default('client', 'syncserver', 'localhost'); db_set_default('addondomain', 'mail_flag', 'on'); db_set_default('client', 'priv_q_can_change_limit_flag', 'on'); db_set_default('web', 'priv_q_installapp_flag', 'on'); db_set_default('client', 'priv_q_installapp_flag', 'on'); db_set_default('client', 'websyncserver', 'localhost'); db_set_default('client', 'mmailsyncserver', 'localhost'); db_set_default('client', 'mysqldbsyncserver', 'localhost'); db_set_default('client', 'priv_q_can_change_password_flag', 'on'); db_set_default('client', 'coma_dnssyncserver_list', ',localhost,'); db_set_default('domain', 'priv_q_installapp_flag', 'on'); db_set_default('domain', 'dtype', 'domain'); db_set_default('domain', 'priv_q_php_manage_flag', 'on'); db_set_default('web', 'priv_q_php_manage_flag', 'on'); db_set_default('client', 'priv_q_php_manage_flag', 'on'); db_set_default('client', 'priv_q_webhosting_flag', 'on'); db_set_default_variable_diskusage('client', 'priv_q_totaldisk_usage', 'priv_q_disk_usage'); db_set_default_variable_diskusage('domain', 'priv_q_totaldisk_usage', 'priv_q_disk_usage'); db_set_default_variable('web', 'docroot', 'nname'); db_set_default_variable('client', 'used_q_maindomain_num', 'used_q_domain_num'); db_set_default_variable('client', 'priv_q_maindomain_num', 'priv_q_domain_num'); db_set_default("servermail", "domainkey_flag", "on"); log_cleanup("- Fix resourceplan settings in database"); migrateResourceplan('domain'); $sq->rawQuery("update resourceplan set realname = nname where realname = ''"); $sq->rawQuery("update resourceplan set realname = nname where realname is null"); lxshell_php("../bin/common/fixresourceplan.php"); log_cleanup("- Alter some database tables to fit that of Kloxo"); // TODO: Check if this is still longer needed! $sq->rawQuery("alter table sslcert change text_ca_content text_ca_content longtext"); $sq->rawQuery("alter table sslcert change text_key_content text_key_content longtext"); $sq->rawQuery("alter table sslcert change text_csr_content text_csr_content longtext"); $sq->rawQuery("alter table sslcert change text_crt_content text_crt_content longtext"); $sq->rawQuery("alter table mailaccount change ser_forward_a ser_forward_a longtext"); $sq->rawQuery("alter table dns change ser_dns_record_a ser_dns_record_a longtext"); $sq->rawQuery("alter table installsoft change ser_installappmisc_b ser_installappmisc_b longtext"); $sq->rawQuery("alter table web change ser_redirect_a ser_redirect_a longtext"); log_cleanup("- Set default welcome text at Kloxo login page"); initDbLoginPre(); log_cleanup("- Remove default db password if exists"); critical_change_db_pass(); }
log_cleanup("Fixing Mail accounts"); foreach ($list as $c) { if ($client) { // if ($client !== $c->nname) { continue; } $ca = explode(",", $client); if (!in_array($c->nname, $ca)) { continue; } $server = 'all'; } if ($server !== 'all') { // if ($c->syncserver !== $server) { continue; } $sa = explode(",", $server); if (!in_array($c->syncserver, $sa)) { continue; } } $dlist = $c->getList('domaina'); foreach ($dlist as $l) { $mmail = $l->getObject('mmail'); $mclist = $mmail->getList('mailaccount'); foreach ($mclist as $mc) { $spam = $mc->getObject('spam'); $mc->setUpdateSubaction('full_update'); $spam->setUpdateSubaction('full_update'); $mc->was(); $spam->was(); } log_cleanup("- '{$mmail->nname}' ('{$c->nname}') at '{$mmail->syncserver}'"); } }
function setMysqlConvert($engine, $database, $table, $config) { global $gbl, $sgbl, $login, $ghtml; log_cleanup("Convert of MySQL engine"); $engine = strtolower($engine); $database = $database ? $database : '_all_'; $table = $table ? $table : '_all_'; $config = $config ? $config : 'yes'; $pass = slave_get_db_pass(); //--- the first - to 'disable' skip- and restart mysql system("sed -i 's/skip/\\;###123###skip/g' /etc/my.cnf"); $ret = lxshell_return("service", "mysqld", "restart"); if ($ret) { throw new lxexception('mysqld_restart_failed', 'parent'); } mysql_connect('localhost', 'root', $pass); log_cleanup("- Converting to " . $engine . " engine"); if ($database === '_all_') { $dbs = mysql_query('SHOW databases'); while ($db = mysql_fetch_array($dbs)) { log_cleanup("-- " . $db[0] . " database converted"); if ($db[0] === 'mysql') { } else { if ($db[0] === 'information_schema') { } else { mysql_select_db($db[0]); if ($table === '_all_') { $tbls = mysql_query('SHOW tables'); while ($tbl = mysql_fetch_array($tbls)) { log_cleanup("--- " . $tbl[0] . " table converted"); mysql_query("ALTER TABLE {$tbl[0]} ENGINE={$engine}"); } } else { mysql_query("ALTER TABLE {$table} ENGINE={$engine}"); log_cleanup("--- " . $table . " table converted"); } } } } } else { mysql_select_db($database); log_cleanup("-- " . $database . " database converted"); if ($table === '_all_') { $tbls = mysql_query('SHOW tables'); while ($tbl = mysql_fetch_array($tbls)) { log_cleanup("--- " . $tbl[0] . " table converted"); mysql_query("ALTER TABLE {$tbl[0]} ENGINE={$engine}"); } } else { mysql_query("ALTER TABLE {$table} ENGINE={$engine}"); log_cleanup("--- " . $table . " table"); } } //--- the second - back to 'original' config and restart mysql system("sed -i 's/\\;###123###skip/skip/g' /etc/my.cnf"); $ret = lxshell_return("service", "mysqld", "restart"); if ($ret) { throw new lxexception('mysqld_restart_failed', 'parent'); } if ($config === 'yes') { if ($database === '_all_') { $string = implode("", file("/etc/my.cnf")); $file = fopen("/etc/my.cnf", "w"); $string_array = explode("\n", $string); $string_collect = null; foreach ($string_array as $sa) { if (stristr($sa, 'skip-innodb') !== FALSE) { $string_collect .= ""; continue; } if (stristr($sa, 'default-storage-engine') !== FALSE) { $string_collect .= ""; continue; } $string_collect .= $sa . "\n"; } if ($engine === 'myisam') { $string_source = "[mysqld]\n"; $string_replace = "[mysqld]\nskip-innodb\ndefault-storage-engine=myisam\n"; log_cleanup("- Added \"skip-innodb and default-storage-engine=" . $engine . "\" in /etc/my.cnf"); } else { $string_source = "[mysqld]\n"; $string_replace = "[mysqld]\ndefault-storage-engine={$engine}\n"; log_cleanup("- Added \"default-storage-engine=" . $engine . "\" in /etc/my.cnf"); } $string_collect = str_replace($string_source, $string_replace, $string_collect); fwrite($file, $string_collect, strlen($string_collect)); } } log_cleanup("- Convert of MySQL to " . $engine . " engine finished"); log_cleanup("- MySQL Service restarted"); $ret = lxshell_return("service", "mysqld", "restart"); if ($ret) { throw new lxexception('mysqld_restart_failed', 'parent'); } }
function setPrepareKloxo() { log_cleanup("Prepare for Kloxo"); log_cleanup("- OS Create Kloxo init.d service file and copy core php.ini (lxphp)"); os_create_program_service(); log_cleanup("- OS Fix programroot path permissions"); os_fix_lxlabs_permission(); log_cleanup("- OS Restart Kloxo service"); os_restart_program(); }
function setApacheOptimize($select, $spare = null) { global $gbl, $sgbl, $login, $ghtml; log_cleanup("Apache optimize"); $status = shell_exec("/etc/init.d/httpd status"); if ($select === 'status') { log_cleanup("- Status: {$status}"); } elseif ($select === 'optimize') { //--- stristr for Case-insensitive if (stristr($status, 'running') !== FALSE) { log_cleanup("- Service stop"); $ret = lxshell_return("service", "httpd", "stop"); if ($ret) { throw new lxexception('httpd_stop_failed', 'parent'); } } lxshell_return("sync; echo 3 > /proc/sys/vm/drop_caches"); if (file_exists("/etc/httpd/conf.d/swtune.conf")) { //--- some vps include /etc/httpd/conf.d/swtune.conf log_cleanup("- Delete /etc/httpd/conf.d/swtune.conf if exist"); lunlink("/etc/httpd/conf.d/swtune.conf"); } $m = array(); // check memory -- $2=total, $3=used, $4=free, $5=shared, $6=buffers, $7=cached $m['total'] = (int) shell_exec("free -m | grep Mem: | awk '{print \$2}'"); $m['spare'] = $spare ? $spare : $m['total'] * 0.25; $m['apps'] = (int) shell_exec("free -m | grep buffers/cache: | awk '{print \$3}'"); /* $m['used'] = (int)shell_exec("free -m | grep Mem: | awk '{print $3}'"); $m['free'] = (int)shell_exec("free -m | grep Mem: | awk '{print $4}'"); $m['shared'] = (int)shell_exec("free -m | grep Mem: | awk '{print $5}'"); $m['buffers'] = (int)shell_exec("free -m | grep Mem: | awk '{print $6}'"); $m['cached'] = (int)shell_exec("free -m | grep Mem: | awk '{print $7}'"); $m['avail'] = $m['free'] + $m['shared'] + $m['buffers'] + $m['cached'] - $m['spare']; */ $m['avail'] = $m['total'] - $m['spare'] - $m['apps']; // $maxpar = (int)($m['avail'] / 25); // $minpar = (int)($maxpar / 2); $maxpar_p = (int) ($m['avail'] / 30) + 1; $minpar_p = (int) ($maxpar_p / 2); $maxpar_w = (int) ($m['avail'] / 35) + 1; $minpar_w = (int) ($maxpar_w / 2); // because on apache 2.2.x no appear 'overflow' memory so // no need ServerLimit = MaxClients = $maxpar_p for prefork/itk // no need MaxClients = ThreadsPerChild = $maxpar_p for worker/event $s = <<<EOF Timeout 150 KeepAlive On MaxKeepAliveRequests 100 KeepAliveTimeout 5 <IfModule prefork.c> \tStartServers 2 \tMinSpareServers {$minpar_p} \tMaxSpareServers {$maxpar_p} \tServerLimit 256 \tMaxClients 256 \tMaxRequestsPerChild 4000 \tMaxMemFree 2 </IfModule> <IfModule itk.c> \tStartServers 2 \tMinSpareServers {$minpar_p} \tMaxSpareServers {$maxpar_p} \tServerLimit 256 \tMaxClients 256 \tMaxRequestsPerChild 4000 \tMaxMemFree 2 </IfModule> <IfModule worker.c> \tStartServers 2 \tMaxClients 150 \tMinSpareThreads {$minpar_w} \tMaxSpareThreads {$maxpar_w} \tThreadsPerChild 25 \tMaxRequestsPerChild 0 \tThreadStackSize 8196 \tMaxMemFree 2 </IfModule> <IfModule event.c> \tStartServers 2 \tMaxClients 150 \tMinSpareThreads {$minpar_w} \tMaxSpareThreads {$maxpar_w} \tThreadsPerChild 25 \tMaxRequestsPerChild 0 \tThreadStackSize 8196 \tMaxMemFree 2 </IfModule> Include /home/apache/conf/exclusive/*.conf Include /home/apache/conf/defaults/*.conf Include /home/apache/conf/domains/*.conf Include /home/apache/conf/redirects/*.conf Include /home/apache/conf/webmails/*.conf Include /home/apache/conf/wildcards/*.conf ###version0-7### EOF; log_cleanup("- Calculate Apache:"); log_cleanup("-- threads limit (min/max -> {$minpar_w}/{$maxpar_w}) and servers limit (min/max -> {$minpar_p}/{$maxpar_p})"); log_cleanup("- Write to /etc/httpd/conf.d/~lxcenter.conf"); // $s=implode("", file("/etc/httpd/conf.d/~lxcenter.conf")); $f = fopen("/etc/httpd/conf.d/~lxcenter.conf", "w"); fwrite($f, $s, strlen($s)); log_cleanup("- Service start"); $ret = lxshell_return("service", "httpd", "start"); if ($ret) { throw new lxexception('httpd_start_failed', 'parent'); } } }
$pi = $s->getObject('phpini'); $pi->setUpdateSubaction('full_update'); $pi->was(); log_cleanup("- in '/etc' at '{$s->nname}'"); } foreach ($list as $c) { if ($client) { // if ($client !== $c->nname) { continue; } $ca = explode(",", $client); if (!in_array($c->nname, $ca)) { continue; } $server = 'all'; } if ($server !== 'all') { // if ($c->syncserver !== $server) { continue; } $sa = explode(",", $server); if (!in_array($c->syncserver, $sa)) { continue; } } $dlist = $c->getList('domaina'); foreach ((array) $dlist as $l) { $web = $l->getObject('web'); $php = $web->getObject('phpini'); $php->initPhpIni(); $php->setUpdateSubaction('full_update'); $php->was(); log_cleanup("- in '/home/httpd/{$web->nname}' ('{$c->nname}') at '{$web->syncserver}'"); } }
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'); } }
<?php include_once "htmllib/lib/include.php"; initProgram('admin'); $list = parse_opt($argv); $server = isset($list['server']) ? $list['server'] : 'localhost'; $client = isset($list['client']) ? $list['client'] : null; $login->loadAllObjects('client'); $list = $login->getList('client'); log_cleanup("Fixing cgi-bin path"); foreach ($list as $c) { if ($client) { // if ($client !== $c->nname) { continue; } $ca = explode(",", $client); if (!in_array($c->nname, $ca)) { continue; } $server = 'all'; } if ($server !== 'all') { // if ($c->syncserver !== $server) { continue; } $sa = explode(",", $server); if (!in_array($c->syncserver, $sa)) { continue; } } $dlist = $c->getList('domaina'); $cdir = "__path_customer_root/{$c->getPathFromName('nname')}"; foreach ($dlist as $l) { $web = $l->getObject('web'); lxfile_mv_rec("{$cdir}/cgi-bin/{$l->nname}", "{$cdir}/{$l->nname}/cgi-bin");