From f53d3ef935aa7dcb78c4570941bccff959bb58bf Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 4 Sep 2015 18:17:38 +0200 Subject: syslog-ng - use install_cron_job() instead of reimplementing it --- config/syslog-ng/syslog-ng.inc | 65 ++++-------------------------------------- 1 file changed, 6 insertions(+), 59 deletions(-) (limited to 'config/syslog-ng') diff --git a/config/syslog-ng/syslog-ng.inc b/config/syslog-ng/syslog-ng.inc index 57a94f96..41fce416 100644 --- a/config/syslog-ng/syslog-ng.inc +++ b/config/syslog-ng/syslog-ng.inc @@ -58,14 +58,17 @@ function syslogng_install_command() { if (!file_exists("/usr/local/lib/syslog-ng")) { @symlink(SYSLOGNG_BASEDIR . "local/lib/syslog-ng", "/usr/local/lib/syslog-ng"); } - syslogng_install_cron(true); + $crontask = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "local/sbin/logrotate /usr/local/etc/logrotate.conf"; + install_cron_job("${crontask}", true, "0"); syslogng_resync(); } function syslogng_deinstall_command() { - if (is_link("/usr/local/lib/syslog-ng")) + if (is_link("/usr/local/lib/syslog-ng")) { unlink("/usr/local/lib/syslog-ng"); - syslogng_install_cron(false); + } + $crontask = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "local/sbin/logrotate /usr/local/etc/logrotate.conf"; + install_cron_job("${crontask}", false); unlink_if_exists("/usr/local/etc/logrotate.conf"); unlink_if_exists("/usr/local/etc/syslog-ng.conf"); filter_configure(); @@ -137,62 +140,6 @@ function syslogng_validate_advanced($post, &$input_errors) { } } -function syslogng_install_cron($should_install) { - global $config; - - if (platform_booting()) { - return; - } - - if (!$config['cron']['item']) { - return; - } - - $x=0; - $rotate_job_id=-1; - $rotate_is_installed = false; - - foreach ($config['cron']['item'] as $item) { - if (strstr($item['task_name'], "syslogng_rotate_logs")) { - $rotate_job_id = $x; - } - $x++; - } - $need_write = false; - switch ($should_install) { - case true: - if ($rotate_job_id < 0) { - $cron_item = array(); - $cron_item['task_name'] = "syslogng_rotate_logs"; - $cron_item['minute'] = "0"; - $cron_item['hour'] = "*"; - $cron_item['mday'] = "*"; - $cron_item['month'] = "*"; - $cron_item['wday'] = "*"; - $cron_item['who'] = "root"; - $cron_item['command'] = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "local/sbin/logrotate /usr/local/etc/logrotate.conf"; - $config['cron']['item'][] = $cron_item; - $need_write = true; - } - if ($need_write) { - parse_config(true); - write_config("Adding syslog-ng Cron Jobs"); - } - break; - case false: - if ($rotate_job_id >= 0) { - unset($config['cron']['item'][$rotate_job_id]); - $need_write = true; - } - if ($need_write) { - parse_config(true); - write_config("Removing syslog-ng Cron Jobs"); - } - break; - } - configure_cron(); -} - function syslogng_build_default_objects($settings) { $default_objects = array(); -- cgit v1.2.3