aboutsummaryrefslogtreecommitdiffstats
path: root/packages/spamd.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2008-04-17 22:15:49 +0000
committerScott Ullrich <sullrich@pfsense.org>2008-04-17 22:15:49 +0000
commit3baf067a2443c54fc069065fac97d125817946a2 (patch)
tree64b52b31f85581e3dd55763eacd4b87c30c6ba9f /packages/spamd.inc
parent615a4d47688b05ec5bbd2eda1e6b0c11900610cc (diff)
downloadpfsense-packages-3baf067a2443c54fc069065fac97d125817946a2.tar.gz
pfsense-packages-3baf067a2443c54fc069065fac97d125817946a2.tar.bz2
pfsense-packages-3baf067a2443c54fc069065fac97d125817946a2.zip
Convert crontab over to 1.2 style.
Diffstat (limited to 'packages/spamd.inc')
-rw-r--r--packages/spamd.inc45
1 files changed, 43 insertions, 2 deletions
diff --git a/packages/spamd.inc b/packages/spamd.inc
index 666f3d8f..d279bfc8 100644
--- a/packages/spamd.inc
+++ b/packages/spamd.inc
@@ -131,8 +131,7 @@ function sync_package_spamd() {
"stop" => $stop
)
);
- $cronjob = "*/120 * * * * root /usr/bin/nice -n20 /usr/local/sbin/spamd-setup";
- add_text_to_file("/etc/crontab", $cronjob);
+ spamd_install_cron(true);
conf_mount_ro();
config_unlock();
mwexec("killall -HUP cron");
@@ -200,8 +199,50 @@ function custom_php_deinstall_command() {
unlink_if_exists("/usr/local/pkg/pf/spamd_rules.php");
unlink_if_exists("/usr/local/www/spamd_rules.php");
unlink_if_exists("/usr/local/etc/rc.d/spamd.sh");
+ spamd_install_cron(false);
conf_mount_ro();
filter_configure();
}
+function spamd_install_cron($should_install) {
+ global $config, $g;
+ $is_installed = false;
+ if(!$config['cron']['item'])
+ return;
+ $x=0;
+ foreach($config['cron']['item'] as $item) {
+ if(strstr($item['command'], "spamd-setup")) {
+ $is_installed = true;
+ break;
+ }
+ $x++;
+ }
+ switch($should_install) {
+ case true:
+ if(!$is_installed) {
+ $cron_item = array();
+ $cron_item['minute'] = "*/120";
+ $cron_item['hour'] = "*";
+ $cron_item['mday'] = "*";
+ $cron_item['month'] = "*";
+ $cron_item['wday'] = "*";
+ $cron_item['who'] = "root";
+ $cron_item['command'] = "/usr/bin/nice -n20 /usr/local/sbin/spamd-setup";
+ $config['cron']['item'][] = $cron_item;
+ write_config("Installed SPAMD crontab entries.");
+ configure_cron();
+ }
+ break;
+ case false:
+ if($is_installed == true) {
+ if($x > 0) {
+ unset($config['cron']['item'][$x]);
+ write_config();
+ }
+ configure_cron();
+ }
+ break;
+ }
+}
+
?> \ No newline at end of file