summaryrefslogtreecommitdiffstats
path: root/etc/inc/services.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2007-01-29 04:09:12 +0000
committerScott Ullrich <sullrich@pfsense.org>2007-01-29 04:09:12 +0000
commit1071e028a5b7cd229cdcc30feacedb1e09069894 (patch)
tree940af601baa92648f100fdf808dc4e121ad0ab10 /etc/inc/services.inc
parentf2025e919e0cb7819db59e684c337f653aa6cc02 (diff)
downloadpfsense-1071e028a5b7cd229cdcc30feacedb1e09069894.zip
pfsense-1071e028a5b7cd229cdcc30feacedb1e09069894.tar.gz
Backport cron handling from HEAD.
Patches-submitted-by: DSH@
Diffstat (limited to 'etc/inc/services.inc')
-rw-r--r--etc/inc/services.inc48
1 files changed, 48 insertions, 0 deletions
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index 81252e1..0832212 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -1181,4 +1181,52 @@ EODAD;
conf_mount_ro();
}
+/* configure cron service */
+function configure_cron() {
+ global $g, $config;
+ if (!$g['booting'])
+ conf_mount_rw();
+ /* preserve existing crontab entries */
+ $crontab_contents = file_get_contents("/etc/crontab");
+ $crontab_contents_a = split("\n", $crontab_contents);
+
+ for ($i = 0; $i < count($crontab_contents_a); $i++) {
+ $item =& $crontab_contents_a[$i];
+ if (strpos($item, "# pfSense specific crontab entries") !== false) {
+ array_splice($crontab_contents_a, $i - 1);
+ break;
+ }
+ }
+ $crontab_contents = implode("\n", $crontab_contents_a) . "\n";
+
+
+ if (is_array($config['cron']['item'])) {
+ $crontab_contents .= "#\n";
+ $crontab_contents .= "# pfSense specific crontab entries\n";
+ $crontab_contents .= "# Created: " . date("F j, Y, g:i a") . "\n";
+ $crontab_contents .= "#\n";
+
+ foreach ($config['cron']['item'] as $item) {
+ $crontab_contents .= "\n{$item['minute']}\t";
+ $crontab_contents .= "{$item['hour']}\t";
+ $crontab_contents .= "{$item['mday']}\t";
+ $crontab_contents .= "{$item['month']}\t";
+ $crontab_contents .= "{$item['wday']}\t";
+ $crontab_contents .= "{$item['who']}\t";
+ $crontab_contents .= "{$item['command']}";
+ }
+
+ $crontab_contents .= "\n#\n";
+ $crontab_contents .= "# If possible do not add items to this file manually.\n";
+ $crontab_contents .= "# If you do so, this file must be terminated with a blank line (e.g. new line)\n";
+ $crontab_contents .= "#\n\n";
+ }
+
+ /* please maintain the newline at the end of file */
+ file_put_contents("/etc/crontab", $crontab_contents);
+
+ if (!$g['booting'])
+ conf_mount_ro();
+}
+
?>
OpenPOWER on IntegriCloud