aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-01-28 00:51:32 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-01-28 00:51:32 +0000
commit8a33667263d3533e7d22aa0b1e18efce20e770bb (patch)
treebd1f9c94cb56052281bc67bcdbbecc3f39ae5a14
parentbb74bfcde96edab984827e11e6f47ef4606e28e3 (diff)
downloadpfsense-packages-8a33667263d3533e7d22aa0b1e18efce20e770bb.tar.gz
pfsense-packages-8a33667263d3533e7d22aa0b1e18efce20e770bb.tar.bz2
pfsense-packages-8a33667263d3533e7d22aa0b1e18efce20e770bb.zip
Whip spamd into shape for the NWO.
-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