diff --git a/cron/CHANGELOG b/cron/CHANGELOG
index 19d8c06e4..12aa10690 100644
--- a/cron/CHANGELOG
+++ b/cron/CHANGELOG
@@ -45,3 +45,5 @@ Added buttons to move cron jobs to the top and bottom of the list.
Added a page for manually editing cron jobs.
---- Changes since 1.900 ----
The next run time of each cron job can be displayed by enable a new config option.
+---- Changes since 1.980 ----
+Added buttons to stop and start crond on the main page.
diff --git a/cron/acl_security.pl b/cron/acl_security.pl
index acfb8d894..611739e28 100755
--- a/cron/acl_security.pl
+++ b/cron/acl_security.pl
@@ -56,6 +56,10 @@ print &ui_table_row($text{'acl_hourly'},
&ui_radio("hourly", $_[0]->{'hourly'},
[ [ 1, $text{'yes'} ], [ 0, $text{'no'} ],
[ 2, $text{'acl_hourlydef'} ] ]), 3);
+
+print &ui_table_row($text{'acl_stop'},
+ &ui_radio("stop", $_[0]->{'stop'},
+ [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]));
}
# acl_security_save(&options)
@@ -77,5 +81,6 @@ $_[0]->{'delete'} = $in{'delete'};
$_[0]->{'move'} = $in{'move'};
$_[0]->{'kill'} = $in{'kill'};
$_[0]->{'hourly'} = $in{'hourly'};
+$_[0]->{'stop'} = $in{'stop'};
}
diff --git a/cron/bootup.cgi b/cron/bootup.cgi
new file mode 100755
index 000000000..454998ebd
--- /dev/null
+++ b/cron/bootup.cgi
@@ -0,0 +1,17 @@
+#!/usr/local/bin/perl
+# Enable or disable crond at boot time
+
+require './cron-lib.pl';
+&ReadParse();
+&foreign_require("init");
+$access{'stop'} || &error($text{'bootup_ecannot'});
+$init = $config{'init_name'};
+if ($in{'boot'}) {
+ &init::enable_at_boot($init);
+ }
+else {
+ &init::disable_at_boot($init);
+ }
+&webmin_log($in{'boot'} ? "bootup" : "bootdown");
+&redirect("");
+
diff --git a/cron/config-debian-linux b/cron/config-debian-linux
index 77fe0708c..dda85b243 100644
--- a/cron/config-debian-linux
+++ b/cron/config-debian-linux
@@ -21,3 +21,4 @@ show_comment=0
hourly_only=0
max_jobs=100
show_next=0
+init_name=cron
diff --git a/cron/config-debian-linux-2.1-ALL b/cron/config-debian-linux-2.1-ALL
index a5b445ffd..035cd68b4 100644
--- a/cron/config-debian-linux-2.1-ALL
+++ b/cron/config-debian-linux-2.1-ALL
@@ -23,3 +23,4 @@ show_comment=0
hourly_only=0
max_jobs=100
show_next=0
+init_name=cron
diff --git a/cron/config-redhat-linux b/cron/config-redhat-linux
index 1bfcd0ffd..d284e2996 100644
--- a/cron/config-redhat-linux
+++ b/cron/config-redhat-linux
@@ -23,3 +23,4 @@ show_comment=0
hourly_only=0
max_jobs=100
show_next=0
+init_name=crond
diff --git a/cron/config.info b/cron/config.info
index d3f7551cc..e40075410 100644
--- a/cron/config.info
+++ b/cron/config.info
@@ -25,3 +25,4 @@ system_crontab=Path to Vixie-Cron system crontab file,0
single_file=Path to single user crontab file,0
cronfiles_dir=Path to extra cron files directory,3,None
run_parts=run-parts command,0
+init_name=Cron daemon bootup action name,3,None exists
diff --git a/cron/defaultacl b/cron/defaultacl
index 2104b66a0..524cb258a 100644
--- a/cron/defaultacl
+++ b/cron/defaultacl
@@ -8,3 +8,4 @@ delete=1
move=1
kill=1
hourly=2
+stop=1
diff --git a/cron/index.cgi b/cron/index.cgi
index f3f37979e..5f8492f13 100755
--- a/cron/index.cgi
+++ b/cron/index.cgi
@@ -286,5 +286,34 @@ else {
print &ui_links_row(\@crlinks);
}
+# If there is an init script that runs crond, show status
+&foreign_require("init");
+my $init = $config{'init_name'};
+my $atboot;
+if ($access{'stop'} && $init && ($atboot = &init::action_status($init))) {
+ print &ui_hr();
+ print &ui_buttons_start();
+
+ # Running now?
+ my $r = &init::status_action($init);
+ if ($r == 1) {
+ print &ui_buttons_row("stop.cgi", $text{'index_stop'},
+ $text{'index_stopdesc'});
+ }
+ elsif ($r == 0) {
+ print &ui_buttons_row("start.cgi", $text{'index_start'},
+ $text{'index_startdesc'});
+ }
+
+ # Start at boot?
+ print &ui_buttons_row("bootup.cgi", $text{'index_boot'},
+ $text{'index_bootdesc'}, undef,
+ &ui_radio("boot", $atboot == 2 ? 1 : 0,
+ [ [ 1, $text{'yes'} ],
+ [ 0, $text{'no'} ] ]));
+
+ print &ui_buttons_end();
+ }
+
&ui_print_footer("/", $text{'index'});
diff --git a/cron/lang/en b/cron/lang/en
index c135dd4d0..5fc6926e3 100644
--- a/cron/lang/en
+++ b/cron/lang/en
@@ -31,6 +31,12 @@ index_ok=Search
index_searchres=Cron jobs matching $1 ..
index_reset=Reset search.
index_econfigcheck=Cron jobs cannot be managed on your system, as the module configuration is not valid : $1
+index_stop=Stop Cron Daemon
+index_stopdesc=Shut down the crond background server process that runs scheduled cron jobs. This will prevent commands from executing at their specified times.
+index_start=Start Cron Daemon
+index_startdesc=Start up the crond background server process that runs scheduled cron jobs. This is required for commands to execute at their specified times.
+index_boot=Start Cron Daemon Boot?
+index_bootdesc=Change this setting to enable or disable starting the scheduled cron jobs daemon at system boot time.
edit_title=Edit Cron Job
create_title=Create Cron Job
@@ -128,6 +134,7 @@ acl_move=Can move Cron jobs?
acl_kill=Can terminate Cron jobs?
acl_hourly=Limit jobs to at most hourly?
acl_hourlydef=As set in Module Config
+acl_stop=Can stop and start the Cron daemon?
log_modify=Modified Cron job for $1
log_modify_l=Modified Cron job "$2" for $1
@@ -146,6 +153,10 @@ log_move=Moved Cron job for $1
log_crons_delete=Deleted $1 Cron jobs
log_crons_disable=Disabled $1 Cron jobs
log_crons_enable=Enabled $1 Cron jobs
+log_stop=Stopped cron daemon
+log_start=Started cron daemon
+log_bootup=Enabled cron daemon at boot
+log_bootdown=Disabled cron daemon at boot
ecopy=An error was detected in the new Cron configuration : $1 $2
@@ -195,4 +206,10 @@ manual_editing=Use the text box below to edit Cron jobs in $1. Be careful, as no
manual_efile=Selected file is not valid!
manual_ecannot=You are not allowed to manually edit cron jobs
+stop_err=Failed to stop daemon
+start_err=Failed to start daemon
+stop_ecannot=You are not allowed to stop the daemon
+start_ecannot=You are not allowed to start the daemon
+bootup_ecannot=You are not allowed to enable the daemon at boot
+
__norefs=1
diff --git a/cron/log_parser.pl b/cron/log_parser.pl
index 3c67c9371..02c5d467b 100755
--- a/cron/log_parser.pl
+++ b/cron/log_parser.pl
@@ -37,11 +37,8 @@ elsif ($action eq 'exec' || $action eq 'kill') {
"$object",
"".&html_escape($p->{'command'})."");
}
-elsif ($action eq 'allow') {
- return $text{'log_allow'};
- }
else {
- return undef;
+ return $text{'log_'.$action};
}
}
diff --git a/cron/negativeacl b/cron/negativeacl
new file mode 100644
index 000000000..fb6975934
--- /dev/null
+++ b/cron/negativeacl
@@ -0,0 +1 @@
+stop=0
diff --git a/cron/start.cgi b/cron/start.cgi
new file mode 100755
index 000000000..0dc8c2c41
--- /dev/null
+++ b/cron/start.cgi
@@ -0,0 +1,14 @@
+#!/usr/local/bin/perl
+# Start crond
+
+require './cron-lib.pl';
+&error_setup($text{'start_err'});
+$access{'stop'} || &error($text{'start_ecannot'});
+&foreign_require("init");
+my $init = $config{'init_name'};
+my ($ok, $err) = &init::start_action($init);
+&error($err) if (!$ok);
+&webmin_log("start");
+&redirect("");
+
+
diff --git a/cron/stop.cgi b/cron/stop.cgi
new file mode 100755
index 000000000..62d1b6e6a
--- /dev/null
+++ b/cron/stop.cgi
@@ -0,0 +1,14 @@
+#!/usr/local/bin/perl
+# Stop crond
+
+require './cron-lib.pl';
+&error_setup($text{'stop_err'});
+$access{'stop'} || &error($text{'stop_ecannot'});
+&foreign_require("init");
+my $init = $config{'init_name'};
+my ($ok, $err) = &init::stop_action($init);
+&error($err) if (!$ok);
+&webmin_log("stop");
+&redirect("");
+
+