aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/spamd.inc68
-rw-r--r--packages/spamd.xml62
2 files changed, 73 insertions, 57 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 &amp;");
+ $start = "/usr/local/sbin/spamd-setup &amp;\n" .
+ "/usr/local/libexec/spamd -G 25:4:864\n" .
+ "/usr/local/libexec/spamlogd &amp;";
+ $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
diff --git a/packages/spamd.xml b/packages/spamd.xml
index 9dd6a9bd..7bab3961 100644
--- a/packages/spamd.xml
+++ b/packages/spamd.xml
@@ -106,67 +106,15 @@
</field>
</fields>
<custom_php_global_functions>
- 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");
- }
</custom_php_global_functions>
+ <include_file>spamd.inc</include_file>
<custom_php_resync_config_command>
- sync_package_spamd();
+ sync_package_spamd();
</custom_php_resync_config_command>
<custom_php_install_command>
- system("touch /var/mail/whitelist.txt 2>/dev/null");
- system("/usr/libexec/spamd-setup 2>/dev/null &amp;");
- system("/usr/libexec/spamlogd 2>/dev/null &amp;");
- $start = "/usr/local/sbin/spamd-setup &amp;\n" .
- "/usr/local/libexec/spamlogd &amp;";
- $stop = "/usr/bin/killall spamd-setup\n" .
- "/usr/bin/killall spamlogd";
- write_rcfile(array(
- "file" => "spamd.sh",
- "start" => $start,
- "stop" => $stop
- )
- );
- start_service("spamd");
+ custom_php_install_command();
</custom_php_install_command>
<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");
+ custom_php_deinstall_command();
</custom_php_deinstall_command>
-</packagegui>
+</packagegui> \ No newline at end of file