From b6699850bbd3a629aad03804a7c80c0ac611fb74 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Mon, 25 Jan 2010 07:29:23 +0000 Subject: [PATCH] removing unneeded file install_configs.php; making $cronscriptDebug a setting in the database (no messing around in the files for debugging); removed unnecessary unset() in cron_init.php; setting of correct file-ownership of logfiles in apache and lighttpd crons; --- actions/admin/settings/120.system.php | 8 + install/froxlor.sql | 1 + .../updates/froxlor/0.9/update_0.9.inc.php | 22 ++- lib/cron_init.php | 5 +- lib/tables.inc.php | 2 +- lng/english.lng.php | 2 + lng/german.lng.php | 2 + scripts/cron_tasks.inc.http.10.apache.php | 12 +- scripts/cron_tasks.inc.http.20.lighttpd.php | 13 +- scripts/install_configs.php | 140 ------------------ 10 files changed, 53 insertions(+), 154 deletions(-) delete mode 100644 scripts/install_configs.php diff --git a/actions/admin/settings/120.system.php b/actions/admin/settings/120.system.php index ff227297..29994a9f 100644 --- a/actions/admin/settings/120.system.php +++ b/actions/admin/settings/120.system.php @@ -95,6 +95,14 @@ return array( 'type' => 'hidden', 'default' => 'www-data', ), + 'system_debug_cron' => array( + 'label' => $lng['serversettings']['cron']['debug'], + 'settinggroup' => 'system', + 'varname' => 'debug_cron', + 'type' => 'bool', + 'default' => false, + 'save_method' => 'storeSettingField', + ), ), ), ), diff --git a/install/froxlor.sql b/install/froxlor.sql index 76bbfd74..13affb12 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -549,6 +549,7 @@ INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) V INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (118, 'panel', 'frontend', 'froxlor'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (119, 'spf', 'use_spf', '0'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (120, 'spf', 'spf_entry', '@ IN TXT "v=spf1 a mx -all"'); +INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (121, 'system', 'debug_cron', '0'); # -------------------------------------------------------- diff --git a/install/updates/froxlor/0.9/update_0.9.inc.php b/install/updates/froxlor/0.9/update_0.9.inc.php index 56db3640..09770331 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -5,8 +5,8 @@ if($settings['panel']['frontend'] == 'froxlor' { $updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 0.9-r1 to 0.9-r2"); - $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (119, 'spf', 'use_spf', '0');"); - $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (120, 'spf', 'spf_entry', '@ IN TXT \"v=spf1 a mx -all\"');"); + $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('spf', 'use_spf', '0');"); + $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('spf', 'spf_entry', '@ IN TXT \"v=spf1 a mx -all\"');"); // Convert all data to UTF-8 to have a sane standard across all data $result = $db->query("SHOW TABLES"); @@ -64,3 +64,21 @@ if($settings['panel']['frontend'] == 'froxlor' $db->query($query); $settings['panel']['version'] = '0.9-r2'; } + +if($settings['panel']['frontend'] == 'froxlor' +&& $settings['panel']['version'] == '0.9-r2') +{ + $updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 0.9-r2 to 0.9-r3"); + + $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'debug_cron', '0');"); + + // set new version + + $query = 'UPDATE `%s` SET `value` = \'0.9-r3\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\''; + $query = sprintf($query, TABLE_PANEL_SETTINGS); + $db->query($query); + $settings['panel']['version'] = '0.9-r3'; +} + +?> + diff --git a/lib/cron_init.php b/lib/cron_init.php index 78689606..9fd9978e 100644 --- a/lib/cron_init.php +++ b/lib/cron_init.php @@ -23,7 +23,6 @@ if(@php_sapi_name() != 'cli' die('This script will only work in the shell.'); } -$cronscriptDebug = false; $lockdir = '/var/run/'; $lockFilename = 'froxlor_' . basename($_SERVER['PHP_SELF'], '.php') . '.lock-'; $lockfName = $lockFilename . getmypid(); @@ -158,8 +157,6 @@ if(isset($needrootdb) fwrite($debugHandler, 'Database-rootconnection established' . "\n"); }*/ -unset($sql['root_user'], $sql['root_password']); - if($db->link_id == 0) { /** @@ -199,6 +196,8 @@ if(!isset($settings['panel']['version']) fwrite($debugHandler, 'Froxlor Version and Database Version are correct' . "\n"); +$cronscriptDebug = ($settings['system']['debug_cron'] == '1') ? true : false; + $cronbasedir = makeCorrectDir($pathtophpfiles . '/scripts/'); $crondir = new DirectoryIterator($cronbasedir); $cronfilename = basename($_SERVER['PHP_SELF'], '.php'); diff --git a/lib/tables.inc.php b/lib/tables.inc.php index 89488c75..41345196 100644 --- a/lib/tables.inc.php +++ b/lib/tables.inc.php @@ -65,7 +65,7 @@ define('PACKAGE_ENABLED', 2); // VERSION INFO -$version = '0.9-r2'; +$version = '0.9-r3'; $dbversion = '2'; ?> diff --git a/lng/english.lng.php b/lng/english.lng.php index f24d5d9e..873d549c 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1253,5 +1253,7 @@ $lng['spf']['spf_entry'] = 'SPF entry for all domains'; $lng['panel']['dirsmissing'] = 'The given directory could not be found.'; $lng['panel']['toomanydirs'] = 'Too many subdirectories. Falling back to manual path-select.'; $lng['panel']['abort'] = 'Abort'; +$lng['serversettings']['cron']['debug']['title'] = 'Cronscript debugging'; +$lng['serversettings']['cron']['debug']['description'] = 'Activate to keep the lockfile after a cron-run for debugging.
Attention:Keeping the lockfile can cause the next scheduled cron not to run properly.'; ?> diff --git a/lng/german.lng.php b/lng/german.lng.php index 377d8444..12f2591e 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1233,5 +1233,7 @@ $lng['spf']['spf_entry'] = 'SPF Eintrag für alle Domains'; $lng['panel']['dirsmissing'] = 'Das angegebene Verzeichnis konnte nicht gefunden werden.'; $lng['panel']['toomanydirs'] = 'Zu viele Unterverzeichnisse. Weiche auf manuelle Verzeichniseingabe aus.'; $lng['panel']['abort'] = 'Abbrechen'; +$lng['serversettings']['cron']['debug']['title'] = 'Debuggen des Cronscripts'; +$lng['serversettings']['cron']['debug']['description'] = 'Wenn aktiviert, wird die Lockdatei nach dem Cronlauf zum Debuggen nicht gelöscht
Achtung:Eine alte Lockdatei kann weitere Cronjobs behindern und dafür sorgen, dass diese nicht vollständig ausgeführt werden.'; ?> diff --git a/scripts/cron_tasks.inc.http.10.apache.php b/scripts/cron_tasks.inc.http.10.apache.php index c9c5df1e..3d1b2646 100644 --- a/scripts/cron_tasks.inc.http.10.apache.php +++ b/scripts/cron_tasks.inc.http.10.apache.php @@ -363,9 +363,17 @@ class apache else { // The normal access/error - logging is enabled + $error_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-error.log'); + chown($error_log, $this->settings['system']['httpuser']); + chgrp($error_log, $this->settings['system']['httpgroup']); + + $access_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log'); + chown($access_log, $this->settings['system']['httpuser']); + chgrp($access_log, $this->settings['system']['httpgroup']); + + $logfiles_text.= ' ErrorLog "' . $error_log . "\"\n"; + $logfiles_text.= ' CustomLog "' . $access_log .'" combined' . "\n"; - $logfiles_text.= ' ErrorLog "' . $this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-error.log' . "\"\n"; - $logfiles_text.= ' CustomLog "' . $this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log" combined' . "\n"; } if($this->settings['system']['awstats_enabled'] == '1') diff --git a/scripts/cron_tasks.inc.http.20.lighttpd.php b/scripts/cron_tasks.inc.http.20.lighttpd.php index 9d601808..0f45391c 100644 --- a/scripts/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/cron_tasks.inc.http.20.lighttpd.php @@ -272,7 +272,7 @@ class lighttpd { // The normal access/error - logging is enabled - $filename = $this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-error.log'; + $filename = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-error.log'); if(!is_file($filename)) { @@ -280,12 +280,12 @@ class lighttpd fclose($ourFileHandle); } - chown($filename, $this->settings[system]['httpuser']); - chgrp($filename, $this->settings[system]['httpgroup']); + chown($filename, $this->settings['system']['httpuser']); + chgrp($filename, $this->settings['system']['httpgroup']); //access log - $filename = $this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log'; + $filename = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log'); if(!is_file($filename)) { @@ -294,8 +294,9 @@ class lighttpd } $logfiles_text.= ' accesslog.filename = "' . $filename . '"' . "\n"; - chown($filename, $this->settings[system]['httpuser']); - chgrp($filename, $this->settings[system]['httpgroup']); + + chown($filename, $this->settings['system']['httpuser']); + chgrp($filename, $this->settings['system']['httpgroup']); } return $logfiles_text; diff --git a/scripts/install_configs.php b/scripts/install_configs.php deleted file mode 100644 index 25f52c84..00000000 --- a/scripts/install_configs.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @license GPLv2 http://files.syscp.org/misc/COPYING.txt - * @package System - * @version $Id: install_configs.php 2698 2009-04-13 20:25:59Z flo $ - */ - -/** - * STARTING REDUNDANT CODE, WHICH IS SOME KINDA HEADER FOR EVERY CRON SCRIPT. - * When using this "header" you have to change $lockFilename for your needs. - * Don't forget to also copy the footer which closes database connections - * and the lockfile! - */ - -include (dirname(__FILE__) . '/../lib/cron_init.php'); - -/** - * END REDUNDANT CODE (CRONSCRIPT "HEADER") - */ - -require ($pathtophpfiles . '/lib/configfiles_index.inc.php'); -require ($pathtophpfiles . '/lib/userdata.inc.php'); - -$replace_arr = Array( - '' => $sql['user'], - '' => $sql['password'], - '' => $sql['db'], - '' => $sql['host'], - '' => $settings['system']['hostname'], - '' => $settings['system']['ipaddress'], - '' => $settings['system']['nameservers'], - '' => $settings['system']['vmail_homedir'], - '' => $settings['system']['vmail_uid'], - '' => $settings['system']['vmail_gid'], - '' => $settings['system']['awstats_path'], - '' => ($settings['system']['use_ssl'] == '1') ? 'imaps pop3s' : '' -); - -$cli_params = $_SERVER['argv']; -unset($cli_params[0]); - -if(isset($cli_params[1]) && $cli_params[1] != '' && isset($configfiles[$cli_params[1]])) -{ - $distribution = $cli_params[1]; - unset($cli_params[1]); -} -else -{ - echo 'No valid distribution specified!' . "\n"; -} - -foreach($cli_params as $cli_param) -{ - list($service, $daemon) = explode('=', $cli_param); - echo $service . ' ' . $daemon; - if(isset($configfiles[$distribution]['services'][$service]) && isset($configfiles[$distribution]['services'][$service]['daemons'][$daemon])) - { - foreach($configfiles[$distribution]['services'][$service]['daemons'][$daemon] as $action => $value) - { - if(substr($action, 0, 8) == 'commands') - { - if(is_array($value)) - { - echo '=== COMMANDS BEGIN ===' . "\n"; - foreach($value as $command) - { - echo '-- running ' . $command . "\n"; - if(in_array('reallydoit', $cli_params)) - { - passthru($command); - } - } - echo '==== COMMANDS END ====' . "\n"; - } - } - elseif(substr($action, 0, 5) == 'files') - { - if(is_array($value)) - { - echo '=== FILES BEGIN ===' . "\n"; - while(list($filename, $realname) = each($value)) - { - $file_content = file_get_contents('./templates/misc/configfiles/' . $distribution . '/' . $daemon . '/' . $filename); - $file_content = strtr($file_content, $replace_arr); - echo '-- filename: ' . $realname . "\n"; - echo '-- filecontent:' . "\n" . '---' . "\n"; - echo $file_content; - echo '---' . "\n"; - if(in_array('reallydoit', $cli_params)) - { - if(file_exists($realname)) - { - exec('mv ' . escapeshellarg($realname) . ' ' . escapeshellarg($realname) . '.orig'); - } - file_put_contents($realname, $file_content); - } - } - echo '==== FILES END ====' . "\n"; - } - } - } - - if(isset($configfiles[$distribution]['services'][$service]['daemons'][$daemon]['restart']) - && is_array($configfiles[$distribution]['services'][$service]['daemons'][$daemon]['restart'])) - { - echo '=== RESTART BEGIN ===' . "\n"; - foreach($configfiles[$distribution]['services'][$service]['daemons'][$daemon]['restart'] as $command) - { - echo '-- running ' . $command . "\n"; - if(in_array('reallydoit', $cli_params)) - { - passthru($command); - } - } - echo '==== RESTART END ====' . "\n"; - } - } -} - -/** - * STARTING CRONSCRIPT FOOTER - */ - -include ($pathtophpfiles . '/lib/cron_shutdown.php'); - -/** - * END CRONSCRIPT FOOTER - */ - -?> \ No newline at end of file