diff options
Diffstat (limited to 'packages/spamd.inc')
-rw-r--r-- | packages/spamd.inc | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/packages/spamd.inc b/packages/spamd.inc new file mode 100644 index 00000000..e734a583 --- /dev/null +++ b/packages/spamd.inc @@ -0,0 +1,68 @@ +<?php + +function sync_package_spamd() { + conf_mount_rw(); + config_lock(); + global $config; + $fd = fopen("/usr/local/etc/spamd.conf","w"); + /* all header */ + fwrite($fd, "# this file was automatically generated by the pfSense\n"); + fwrite($fd, "# package management system\n\n"); + fwrite($fd, "all:\\\n\t:whitelist"); + foreach($config['installedpackages']['spamd']['config'] as $spamd) { + fwrite($fd, ":" . rtrim($spamd['providername'])); + } + fwrite($fd, ":\n\n# begin of whitelist\n"); + fwrite($fd, "whitelist:\\\n"); + fwrite($fd, "\t:white:\\\n"); + fwrite($fd, "\t:file=/var/mail/whitelist.txt\n"); + /* loop through each item and write out its configuration */ + fwrite($fd, "\n# begin of user created entries\n"); + if($config['installedpackages']['spamd']['config'] != "") { + foreach($config['installedpackages']['spamd']['config'] as $spamd) { + fwrite($fd, rtrim($spamd['providername']) . ":\\\n"); + fwrite($fd, "\t:" . rtrim($spamd['providertype']) . ":\\\n"); + fwrite($fd, "\t:msg=\"" . rtrim($spamd['rejectmessage']) . "\":\\\n"); + fwrite($fd, "\t:method=" . rtrim($spamd['providermethod']) . ":\\\n"); + fwrite($fd, "\t:" . rtrim($spamd['providermethod']) . ":\\\n"); + fwrite($fd, "\t:file=" . rtrim($spamd['providerurl']) . ":\n\n"); + } + } + fclose($fd); + $fd = fopen("/var/mail/whitelist.txt","w"); + if($config['installedpackages']['spamdwhitelist']['config'] != "") + foreach($config['installedpackages']['spamdwhitelist']['config'] as $spamd) { + fwrite($fd, $spamd['ip'] . "\n"); + } + fclose($fd); + conf_mount_ro(); + config_unlock(); + restart_service("spamd"); +} + +function custom_php_install_command() { + system("touch /var/mail/whitelist.txt"); + system("/usr/local/libexec/spamd -G 25:4:864"); + system("/usr/libexec/spamlogd 2>/dev/null &"); + $start = "/usr/local/sbin/spamd-setup &\n" . + "/usr/local/libexec/spamd -G 25:4:864\n" . + "/usr/local/libexec/spamlogd &"; + $stop = "/usr/bin/killall spamd-setup\n" . + "/usr/local/libexec/spamd\n" . + "/usr/bin/killall spamlogd"; + write_rcfile(array( + "file" => "spamd.sh", + "start" => $start, + "stop" => $stop + ) + ); + start_service("spamd"); +} + +function custom_php_deinstall_command() { + unlink_if_exists("/usr/local/pkg/spamd.sh"); + unlink_if_exists("/usr/local/pkg/pf/spamd_rules.php"); + unlink_if_exists("/usr/local/www/spamd_rules.php"); +} + +?>
\ No newline at end of file |