mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Email option on completion
This commit is contained in:
@@ -9,3 +9,5 @@ Converted all user interface code to use the new Webmin UI library.
|
||||
When editing a job, only the actual command entered is shown by default - the full command can be displayed using a new link.
|
||||
---- Changes since 1.490 ----
|
||||
Added action logging for scheduled commands created and deleted using this module.
|
||||
---- Changes since 1.500 ----
|
||||
Added an option to send email on command completion.
|
||||
|
||||
@@ -24,7 +24,7 @@ $in{'cmd'} =~ /\S/ || &error($text{'create_ecmd'});
|
||||
-d $in{'dir'} || &error($text{'create_edir'});
|
||||
|
||||
# Create the job
|
||||
&create_atjob($in{'user'}, $date, $in{'cmd'}, $in{'dir'});
|
||||
&create_atjob($in{'user'}, $date, $in{'cmd'}, $in{'dir'}, $in{'mail'});
|
||||
&webmin_log("create", "job", $in{'user'}, \%in);
|
||||
&redirect("");
|
||||
|
||||
|
||||
@@ -26,13 +26,14 @@ closedir(DIR);
|
||||
return @rv;
|
||||
}
|
||||
|
||||
# create_atjob(user, time, commands, directory)
|
||||
# create_atjob(user, time, commands, directory, send-mail)
|
||||
sub create_atjob
|
||||
{
|
||||
local @tm = localtime($_[1]);
|
||||
local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
|
||||
$tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
|
||||
local $cmd = "cd ".quotemeta($_[3])." ; at $date";
|
||||
local $mailflag = $_[4] ? "-m" : "";
|
||||
local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
|
||||
local @uinfo = getpwnam($_[0]);
|
||||
if ($uinfo[2] != $<) {
|
||||
# Only SU if we are not already the user
|
||||
|
||||
@@ -100,6 +100,10 @@ print &ui_table_row($text{'index_dir'},
|
||||
print &ui_table_row($text{'index_cmd'},
|
||||
&ui_textarea("cmd", $in{'ext_cmd'}, 5, 50));
|
||||
|
||||
# Send email on completion
|
||||
print &ui_table_row($text{'index_mail'},
|
||||
&ui_yesno_radio("mail", 0));
|
||||
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'create'} ] ]);
|
||||
|
||||
|
||||
@@ -28,12 +28,13 @@ closedir(DIR);
|
||||
return @rv;
|
||||
}
|
||||
|
||||
# create_atjob(user, time, commands, directory)
|
||||
# create_atjob(user, time, commands, directory, send-mail)
|
||||
sub create_atjob
|
||||
{
|
||||
local @tm = localtime($_[1]);
|
||||
local $date = strftime "%H:%M %b %d", @tm;
|
||||
local $cmd = "cd ".quotemeta($_[3])." ; at $date";
|
||||
local $mailflag = $_[4] ? "-m" : "";
|
||||
local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
|
||||
local @uinfo = getpwnam($_[0]);
|
||||
if ($uinfo[2] != $<) {
|
||||
# Only SU if we are not already the user
|
||||
|
||||
@@ -4,6 +4,7 @@ index_user=Run as user
|
||||
index_date=Run on date
|
||||
index_time=Run at time
|
||||
index_cmd=Commands to execute
|
||||
index_mail=Send email on completion?
|
||||
index_id=Job ID
|
||||
index_exec=Run at
|
||||
index_created=Created on
|
||||
|
||||
@@ -27,13 +27,14 @@ closedir(DIR);
|
||||
return @rv;
|
||||
}
|
||||
|
||||
# create_atjob(user, time, commands, directory)
|
||||
# create_atjob(user, time, commands, directory, send-email)
|
||||
sub create_atjob
|
||||
{
|
||||
local @tm = localtime($_[1]);
|
||||
local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
|
||||
$tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
|
||||
local $cmd = "cd ".quotemeta($_[3])." ; at $date";
|
||||
local $mailflag = $_[4] ? "-m" : "";
|
||||
local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
|
||||
local @uinfo = getpwnam($_[0]);
|
||||
if ($uinfo[2] != $<) {
|
||||
# Only SU if we are not already the user
|
||||
|
||||
@@ -26,16 +26,17 @@ closedir(DIR);
|
||||
return @rv;
|
||||
}
|
||||
|
||||
# create_atjob(user, time, commands, directory)
|
||||
# create_atjob(user, time, commands, directory, send-email)
|
||||
sub create_atjob
|
||||
{
|
||||
local @tm = localtime($_[1]);
|
||||
local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
|
||||
$tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
|
||||
&open_execute_command(AT, "su \"$_[0]\" -c \"cd $_[3] ; at $date\" >/dev/null 2>&1", 0);
|
||||
local $mailflag = $_[4] ? "-m" : "";
|
||||
&open_execute_command(AT, "su \"$_[0]\" -c \"cd $_[3] ; at $mailflag $date\" >/dev/null 2>&1", 0);
|
||||
print AT $_[2];
|
||||
close(AT);
|
||||
&additional_log('exec', undef, "su \"$_[0]\" -c \"cd $_[3] ; at $date\"");
|
||||
&additional_log('exec', undef, "su \"$_[0]\" -c \"cd $_[3] ; at $mailflag $date\"");
|
||||
}
|
||||
|
||||
# delete_atjob(id)
|
||||
|
||||
@@ -29,12 +29,13 @@ closedir(DIR);
|
||||
return @rv;
|
||||
}
|
||||
|
||||
# create_atjob(user, time, commands, directory)
|
||||
# create_atjob(user, time, commands, directory, send-email)
|
||||
sub create_atjob
|
||||
{
|
||||
local @tm = localtime($_[1]);
|
||||
local $date = strftime "%H:%M %b %d", @tm;
|
||||
local $cmd = "cd ".quotemeta($_[3])." ; at $date";
|
||||
local $mailflag = $_[4] ? "-m" : "";
|
||||
local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
|
||||
local @uinfo = getpwnam($_[0]);
|
||||
if ($uinfo[2] != $<) {
|
||||
# Only SU if we are not already the user
|
||||
|
||||
Reference in New Issue
Block a user