mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Supporting add new logrotate config files to a directory
This commit is contained in:
@@ -5,3 +5,5 @@ Added a button on the Edit Log File page for forcing the immediate rotation of j
|
|||||||
Added a Module Config option for specifying a file to add new logrotate sections to.
|
Added a Module Config option for specifying a file to add new logrotate sections to.
|
||||||
---- Changes since 1.270 ----
|
---- Changes since 1.270 ----
|
||||||
Added checkboxes and a button for deleting multiple logs at once.
|
Added checkboxes and a button for deleting multiple logs at once.
|
||||||
|
---- Changes since 1.620 ----
|
||||||
|
The module config option for the new file to add logrotate sections to can now be a directory, like /etc/logrotate.d
|
||||||
|
|||||||
@@ -349,11 +349,16 @@ local $out = &backquote_logged("$config{'logrotate'} -f $temp 2>&1");
|
|||||||
return ($?, $out);
|
return ($?, $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
# get_add_file()
|
# get_add_file([filename])
|
||||||
# Returns the file to which new logrotate sections should be added
|
# Returns the file to which new logrotate sections should be added
|
||||||
sub get_add_file
|
sub get_add_file
|
||||||
{
|
{
|
||||||
if ($config{'add_file'}) {
|
local ($filename) = @_;
|
||||||
|
if ($config{'add_file'} && -d $config{'add_file'} && $filename) {
|
||||||
|
# Adding to a new file in a directory
|
||||||
|
return "$config{'add_file'}/$filename.conf";
|
||||||
|
}
|
||||||
|
elsif ($config{'add_file'} && !-d $config{'add_file'}) {
|
||||||
# Make sure file is valid
|
# Make sure file is valid
|
||||||
local ($conf, $lnum, $files) = &get_config();
|
local ($conf, $lnum, $files) = &get_config();
|
||||||
if (&indexof($config{'add_file'}, @$files) >= 0) {
|
if (&indexof($config{'add_file'}, @$files) >= 0) {
|
||||||
|
|||||||
@@ -6,14 +6,16 @@ require './logrotate-lib.pl';
|
|||||||
&ReadParse();
|
&ReadParse();
|
||||||
$parent = &get_config_parent();
|
$parent = &get_config_parent();
|
||||||
$conf = $parent->{'members'};
|
$conf = $parent->{'members'};
|
||||||
|
@files = split(/\s+/, $in{'file'});
|
||||||
if ($in{'global'}) {
|
if ($in{'global'}) {
|
||||||
# Editing the global options
|
# Editing the global options
|
||||||
$log = $parent;
|
$log = $parent;
|
||||||
}
|
}
|
||||||
elsif ($in{'new'}) {
|
elsif ($in{'new'}) {
|
||||||
# Adding a new section
|
# Adding a new section
|
||||||
|
$cfilename = $files[0] =~ /\/([^\/]+)$/ ? $1 : undef;
|
||||||
$log = { 'members' => [ ],
|
$log = { 'members' => [ ],
|
||||||
'file' => &get_add_file() };
|
'file' => &get_add_file($cfilename) };
|
||||||
$logfile = $in{'file'};
|
$logfile = $in{'file'};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -50,7 +52,6 @@ else {
|
|||||||
&lock_file($log->{'file'});
|
&lock_file($log->{'file'});
|
||||||
&error_setup($text{'save_err'});
|
&error_setup($text{'save_err'});
|
||||||
if (!$in{'global'}) {
|
if (!$in{'global'}) {
|
||||||
@files = split(/\s+/, $in{'file'});
|
|
||||||
foreach $f (@files) {
|
foreach $f (@files) {
|
||||||
$f =~ /^\/\S+$/ || &error($text{'save_efile'});
|
$f =~ /^\/\S+$/ || &error($text{'save_efile'});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user