diff options
author | jim-p <jimp@pfsense.org> | 2010-08-09 16:12:52 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2010-08-09 16:14:29 -0400 |
commit | 85405c11a0ab41d26e5016b055b2f1188317c8f2 (patch) | |
tree | 068661bb6c8342a91ea4730fc04a9c532eb9e3db /etc/inc | |
parent | 0c77c314c441b9f1a9967a9bdc0ee6ad0a8fc90b (diff) | |
download | pfsense-85405c11a0ab41d26e5016b055b2f1188317c8f2.zip pfsense-85405c11a0ab41d26e5016b055b2f1188317c8f2.tar.gz |
Add the ability to set a periodic RRD and DHCP leases backup from Diagnostics > NanoBSD.
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/services.inc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 0c4c8de..de186d0 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -1305,4 +1305,46 @@ function upnp_start() { } } +function install_cron_job($command, $active=false, $minute="0", $hour="*", $monthday="*", $month="*", $weekday="*", $who="root") { + global $config, $g; + + $is_installed = false; + + if(!$config['cron']['item']) + return; + + $x=0; + foreach($config['cron']['item'] as $item) { + if(strstr($item['command'], $command)) { + $is_installed = true; + break; + } + $x++; + } + + if($active) { + $cron_item = array(); + $cron_item['minute'] = $minute; + $cron_item['hour'] = $hour; + $cron_item['mday'] = $monthday; + $cron_item['month'] = $month; + $cron_item['wday'] = $weekday; + $cron_item['who'] = $who; + $cron_item['command'] = $command; + if(!$is_installed) { + $config['cron']['item'][] = $cron_item; + write_config("Installed cron job for {$command}"); + } else { + $config['cron']['item'][$x] = $cron_item; + write_config("Updated cron job for {$command}"); + } + } else { + if(($is_installed == true) && ($x > 0)) { + unset($config['cron']['item'][$x]); + write_config("Remvoed cron job for {$command}"); + } + } + configure_cron(); +} + ?> |