mirror of
https://github.com/webmin/webmin.git
synced 2026-06-04 20:30:22 +01:00
Add UI option to control when update email is sent
https://github.com/webmin/webmin/issues/2726
This commit is contained in:
@@ -220,6 +220,13 @@ else {
|
||||
}
|
||||
print &ui_table_row($text{'index_email'}, $efield);
|
||||
|
||||
# When to send email
|
||||
print &ui_table_row($text{'index_ewhen'},
|
||||
&ui_radio("when", int($config{'sched_when'}),
|
||||
[ [ 0, $text{'index_ewhen0'} ],
|
||||
[ 1, $text{'index_ewhen1'} ],
|
||||
[ 2, $text{'index_ewhen2'} ] ]));
|
||||
|
||||
# Install or just notify?
|
||||
$action_ui = &ui_select("action", int($config{'sched_action'}),
|
||||
[ [ -1, $text{'index_action-1'} ],
|
||||
|
||||
@@ -19,6 +19,10 @@ index_schedd=day
|
||||
index_schedw=week
|
||||
index_email=Email updates report to
|
||||
index_email_def=Webmin default ($1)
|
||||
index_ewhen=Send email when
|
||||
index_ewhen0=Any update is installed
|
||||
index_ewhen1=Any update failed
|
||||
index_ewhen2=Never (but still install updates)
|
||||
index_action=Action when update needed
|
||||
index_action-1=Just notify for security updates
|
||||
index_action0=Just notify for any updates
|
||||
|
||||
@@ -6,6 +6,7 @@ require './package-updates-lib.pl';
|
||||
|
||||
&lock_file($module_config_file);
|
||||
$config{'sched_email'} = $in{'email_def'} ? '*' : $in{'email'};
|
||||
$config{'sched_when'} = $in{'when'};
|
||||
$config{'sched_action'} = $in{'action'};
|
||||
&save_module_config();
|
||||
&unlock_file($module_config_file);
|
||||
|
||||
@@ -33,6 +33,7 @@ else {
|
||||
}
|
||||
&start_update_progress([ map { $_->{'name'} } @todo ]);
|
||||
$icount = 0;
|
||||
$fcount = 0;
|
||||
foreach $t (@todo) {
|
||||
next if ($already{$t->{'update'}});
|
||||
my $umsg = $t->{'security'} ? "security update" : "update";
|
||||
@@ -57,6 +58,7 @@ foreach $t (@todo) {
|
||||
$body .= "However, this $umsg could not be installed! ".
|
||||
"Try the update manually\nusing the Package ".
|
||||
"Updates module.\n\n";
|
||||
$fcount++;
|
||||
}
|
||||
foreach $p (@$done) {
|
||||
$already{$p}++;
|
||||
@@ -89,7 +91,9 @@ if ($tellcount) {
|
||||
# Email the admin
|
||||
$emailto = $config{'sched_email'} eq '*' ? $gconfig{'webmin_email_to'}
|
||||
: $config{'sched_email'};
|
||||
if ($emailto && $body) {
|
||||
if ($emailto && $body &&
|
||||
($config{'sched_when'} == 0 ||
|
||||
$config{'sched_when'} == 1 && $fcount)) {
|
||||
&foreign_require("mailboxes", "mailboxes-lib.pl");
|
||||
my $from = &mailboxes::get_from_address();
|
||||
my $mail = { 'headers' =>
|
||||
|
||||
Reference in New Issue
Block a user