diff options
-rw-r--r-- | packages/clamav.inc | 41 | ||||
-rw-r--r-- | packages/clamav.xml | 24 | ||||
-rw-r--r-- | packages/havp.inc | 107 | ||||
-rw-r--r-- | packages/havp.xml | 109 | ||||
-rw-r--r-- | packages/havp_blacklist.xml | 67 | ||||
-rw-r--r-- | packages/havp_whitelist.xml | 67 |
6 files changed, 415 insertions, 0 deletions
diff --git a/packages/clamav.inc b/packages/clamav.inc new file mode 100644 index 00000000..b63eb984 --- /dev/null +++ b/packages/clamav.inc @@ -0,0 +1,41 @@ +<?php +function sync_package_clamav() { + conf_mount_rw(); + config_lock(); + global $config; + $fd = fopen("/usr/local/etc/freshclam.conf","w"); + fwrite($fd, "DatabaseDirectory /var/db/clamav\n"); + fwrite($fd, "UpdateLogFile /var/log/clamav/freshclam.log\n"); + fwrite($fd, "DatabaseOwner clamav\n"); + fwrite($fd, "AllowSupplementaryGroups\n"); + fwrite($fd, "DatabaseMirror database.clamav.net\n"); + fclose($fd); + $cronjob = "*/120 * * * * root /usr/bin/nice -n20 /usr/local/bin/freshclam"; + add_text_to_file("/etc/crontab", $cronjob); + conf_mount_ro(); + config_unlock(); + mwexec("killall -HUP cron"); +} + +function clamav_install_command() { + global $config, $g; + mwexec ("mkdir -p /var/db/clamav"); + mwexec ("chown clamav:clamav /var/db/clamav/"); + mwexec ("chown clamav:clamav /var/log/clamav/"); + mwexec ("/usr/local/bin/freshclam"); + sync_package_clamav(); +} + +function clamav_deinstall_command() { + global $config, $g; + conf_mount_rw(); + unlink_if_exists("/usr/local/etc/rc.d/clamav.sh"); + unlink_if_exists("/var/db/clamav/daily.cvd"); + unlink_if_exists("/var/db/clamav/main.cvd"); + unlink_if_exists("/var/db/clamav"); + $cronjob = "*/120 * * * * root /usr/bin/nice -n20 /usr/local/bin/freshclam"; + #remove_text_to_file("/etc/crontab", $cronjob); + conf_mount_ro(); +} + +?> diff --git a/packages/clamav.xml b/packages/clamav.xml new file mode 100644 index 00000000..ee390a50 --- /dev/null +++ b/packages/clamav.xml @@ -0,0 +1,24 @@ +<packagegui> + <name>clamav</name> + <version>0.1</version> + <title>ClamAV: Settings</title> + <include_file>/usr/local/pkg/clamav.inc</include_file> + + <service> + <name>clamav</name> + <rcfile>/usr/local/etc/rc.d/clamav.sh</rcfile> + </service> + + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://agni.linuxense.com/packages/config/clamav.inc</item> + </additional_files_needed> + + <custom_php_install_command> clamav_install_command(); </custom_php_install_command> + <custom_php_deinstall_command> clamav_deinstall_command(); </custom_php_deinstall_command> + <custom_delete_php_command> sync_package_clamav(); </custom_delete_php_command> + <custom_php_resync_config_command> sync_package_clamav(); </custom_php_resync_config_command> + <custom_add_php_command> sync_package_clamav(); </custom_add_php_command> +</packagegui> + diff --git a/packages/havp.inc b/packages/havp.inc new file mode 100644 index 00000000..631db0e3 --- /dev/null +++ b/packages/havp.inc @@ -0,0 +1,107 @@ +<?php +function sync_package_havp() { + conf_mount_rw(); + config_lock(); + global $config, $g; + $fd = fopen("/etc/havp.config","w"); + fwrite($fd, "USER havp\n"); + fwrite($fd, "GROUP havp\n"); + fwrite($fd, "ACCESSLOG /var/log/havp/access.log\n"); + fwrite($fd, "ERRORLOG /var/log/havp/error.log\n"); + fwrite($fd, "DISPLAYINITIALMESSAGES false\n"); + fwrite($fd, "ENABLECLAMLIB true\n"); + fwrite($fd, "CLAMDBDIR /var/db/clamav/\n"); + fwrite($fd, "ENABLECLAMD false\n"); + fwrite($fd, "ENABLEFPROT false\n"); + fwrite($fd, "ENABLEAVG false\n"); + fwrite($fd, "ENABLEAVESERVER false\n"); + fwrite($fd, "ENABLESOPHIE false\n"); + fwrite($fd, "ENABLETROPHIE false\n"); + fwrite($fd, "ENABLENOD32 false\n"); + fwrite($fd, "ENABLEAVAST false\n"); + foreach($config['installedpackages']['havp']['config'] as $tmp) { + fwrite($fd,"SERVERNUMBER " . $tmp['servernumber'] . "\n"); + fwrite($fd,"MAXSERVERS " . $tmp['maxservers'] . "\n"); + fwrite($fd,"PORT " . $tmp['port'] . "\n"); + if ($tmp['bind_address'] <> "") + fwrite($fd,"BIND_ADDRESS " . $tmp['bind_address'] . " \n"); + if ($tmp['source_address'] <> "") + fwrite($fd,"SOURCE_ADDRESS " . $tmp['source_address'] . " \n"); + if ($tmp['transparent'] == "on"){ + fwrite($fd,"TRANSPARENT true\n"); + } + else { + fwrite($fd,"TRANSPARENT false\n"); + } + if ($tmp['range'] == "on"){ + fwrite($fd,"RANGE true\n"); + } + else { + fwrite($fd,"RANGE false\n"); + } + } + fclose($fd); + $start = "/usr/local/sbin/havp &\n"; + $stop = "/usr/bin/killall havp\n" . "sleep 2"; + write_rcfile(array( + "file" => "havp.sh", + "start" => $start, + "stop" => $stop + ) + ); + conf_mount_ro(); + config_unlock(); + unlink_if_exists("/usr/local/etc/havp/havp.config"); + mwexec("ln -sf /etc/havp.config /usr/local/etc/havp/havp.config"); + mwexec("/usr/local/etc/rc.d/havp.sh stop"); + mwexec("/usr/local/etc/rc.d/havp.sh start"); +} + +function havp_install_command() { + global $config, $g; + mwexec ("mkdir -p /var/log/havp/"); + mwexec ("mkdir -p /var/tmp/havp/"); + mwexec ("mkdir -p /var/run/havp/"); + mwexec ("chown havp:havp /var/log/havp"); + mwexec ("chown havp:havp /var/tmp/havp"); + mwexec ("chown havp:havp /var/run/havp"); + sync_package_havp(); +} + +function havp_deinstall_command() { + global $config, $g; + conf_mount_rw(); + unlink_if_exists("/usr/local/etc/rc.d/havp.sh"); + unlink_if_exists("/usr/local/etc/havp/havp.config"); + conf_mount_ro(); +} +function sync_package_havp_whitelist() { + global $config; + conf_mount_rw(); + config_lock(); + $fd = fopen("/usr/local/etc/havp/whitelist","w"); + if($config['installedpackages']['havpwhitelist']['config'] != "") + foreach($config['installedpackages']['havpwhitelist']['config'] as $tmp) { + fwrite($fd, $tmp['url'] . "\n"); + } + fclose($fd); + /* signal a reload of all files */ + conf_mount_ro(); + config_unlock(); +} + +function sync_package_havp_blacklist() { + global $config; + conf_mount_rw(); + config_lock(); + $fd = fopen("/usr/local/etc/havp/blacklist","w"); + if($config['installedpackages']['havpblacklist']['config'] != "") + foreach($config['installedpackages']['havpblacklist']['config'] as $tmp) { + fwrite($fd, $tmp['url'] . "\n"); + } + fclose($fd); + /* signal a reload of all files */ + conf_mount_ro(); + config_unlock(); +} +?>
\ No newline at end of file diff --git a/packages/havp.xml b/packages/havp.xml new file mode 100644 index 00000000..8f278a4a --- /dev/null +++ b/packages/havp.xml @@ -0,0 +1,109 @@ +<packagegui> + <name>havp</name> + <version>0.1</version> + <title>Havp: Settings</title> + <include_file>/usr/local/pkg/havp.inc</include_file> + + <menu> + <name>HAVP</name> + <section>Services</section> + <tooltiptext>Modify HAVP settings.</tooltiptext> + <url>/pkg_edit.php?xml=havp.xml&act=edit&id=0</url> + <configfile>havp.xml</configfile> + </menu> + + <service> + <name>havp</name> + <rcfile>/usr/local/etc/rc.d/havp.sh</rcfile> + </service> + + <tabs> + <tab> + <text>Settings</text> + <url>/pkg_edit.php?xml=havp.xml&act=edit&id=0</url> + <active/> + </tab> + <tab> + <text>Whitelist</text> + <url>/pkg.php?xml=havp_whitelist.xml</url> + </tab> + <tab> + <text>Blacklist</text> + <url>/pkg.php?xml=havp_blacklist.xml</url> + </tab> + </tabs> + + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://agni.linuxense.com/packages/config/havp.inc</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://agni.linuxense.com/packages/config/havp_whitelist.xml</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://agni.linuxense.com/packages/config/havp_blacklist.xml</item> + </additional_files_needed> + + <configpath>['installedpackages']['havp]['config']</configpath> + + <fields> + <field> + <fielddescr>Server Number</fielddescr> + <fieldname>servernumber</fieldname> + <description>Specify how many servers (child processes) are simultaneously listening on port PORT for a connection. Minimum value should be the peak requests-per-second expected + 5 for headroom.</description> + <type>input</type> + </field> + <field> + <fielddescr>Max Server Number</fielddescr> + <fieldname>maxservers</fieldname> + <description>This is the hard limit for concurrent requests processed.</description> + <type>input</type> + </field> + <field> + <fielddescr>Transparent?</fielddescr> + <fieldname>transparent</fieldname> + <description>Run HAVP as transparent Proxy?</description> + <type>checkbox</type> + <value>yes</value> + </field> + <field> + <fielddescr>Port</fielddescr> + <fieldname>port</fieldname> + <description>Port HAVP is listening on.</description> + <type>input</type> + <value>8080</value> + </field> + <field> + <fielddescr>Bind Address</fielddescr> + <fieldname>bind_address</fieldname> + <description>IP address that HAVP listens on. Leave it empty to bind all addresses.</description> + <type>input</type> + </field> + <field> + <fielddescr>Source Address</fielddescr> + <fieldname>source_address</fieldname> + <description>IP address used for sending outbound packets. Let it be undefined if you want OS to handle right address.</description> + <type>input</type> + </field> + <field> + <fielddescr>Range Requests</fielddescr> + <fieldname>range</fieldname> + <description> Allow HTTP Range Requests?</description> + <type>checkbox</type> + <value>yes</value> + </field> + </fields> + + <custom_php_install_command> havp_install_command(); </custom_php_install_command> + <custom_php_deinstall_command> havp_deinstall_command(); </custom_php_deinstall_command> + <custom_delete_php_command> sync_package_havp(); </custom_delete_php_command> + <custom_php_resync_config_command> sync_package_havp(); </custom_php_resync_config_command> + <custom_add_php_command> sync_package_havp(); </custom_add_php_command> + +</packagegui> + diff --git a/packages/havp_blacklist.xml b/packages/havp_blacklist.xml new file mode 100644 index 00000000..38388628 --- /dev/null +++ b/packages/havp_blacklist.xml @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="utf-8" ?> +<packagegui> + <name>havp-blacklist</name> + <version>0.1.0</version> + <title>Havp: Blacklist</title> + <include_file>/usr/local/pkg/havp.inc</include_file> + + <menu> + <name>HAVP Blacklist</name> + <tooltiptext></tooltiptext> + <section>Services</section> + <configfile>havp.xml</configfile> + </menu> + <tabs> + <tab> + <text>Settings</text> + <url>/pkg_edit.php?xml=havp.xml&act=edit&id=0</url> + </tab> + <tab> + <text>Whitelist</text> + <url>/pkg.php?xml=havp_whitelist.xml</url> + </tab> + <tab> + <text>Blacklist</text> + <url>/pkg.php?xml=havp_blacklist.xml</url> + <active/> + </tab> + </tabs> + + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://agni.linuxense.com/packages/config/havp.inc</item> + </additional_files_needed> + + <configpath>['installedpackages']['havpblacklist']['config']</configpath> + + <adddeleteeditpagefields> + <columnitem> + <fielddescr>Blocked URL</fielddescr> + <fieldname>url</fieldname> + </columnitem> + <columnitem> + <fielddescr>Description</fielddescr> + <fieldname>description</fieldname> + </columnitem> + </adddeleteeditpagefields> + + <fields> + <field> + <fielddescr>Blocked URL</fielddescr> + <fieldname>url</fieldname> + <description>Enter the URL to blacklist</description> + <type>input</type> + </field> + <field> + <fielddescr>Description</fielddescr> + <fieldname>description</fieldname> + <description>Enter the description for this url</description> + <type>input</type> + </field> + </fields> + + <custom_php_command_before_form>sync_package_havp_blacklist();</custom_php_command_before_form> + <custom_delete_php_command>sync_package_havp_blacklist();</custom_delete_php_command> + <custom_php_resync_config_command>sync_package_havp_blacklist();</custom_php_resync_config_command> +</packagegui> diff --git a/packages/havp_whitelist.xml b/packages/havp_whitelist.xml new file mode 100644 index 00000000..429d957e --- /dev/null +++ b/packages/havp_whitelist.xml @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="utf-8" ?> +<packagegui> + <name>havp-whitelist</name> + <version>0.1.0</version> + <title>HAVP: Whitelist</title> + <include_file>/usr/local/pkg/havp.inc</include_file> + + <menu> + <name>HAVP Whitelist</name> + <tooltiptext></tooltiptext> + <section>Services</section> + <configfile>havp.xml</configfile> + </menu> + <tabs> + <tab> + <text>Settings</text> + <url>/pkg_edit.php?xml=havp.xml&act=edit&id=0</url> + </tab> + <tab> + <text>Whitelist</text> + <url>/pkg.php?xml=havp_whitelist.xml</url> + <active/> + </tab> + <tab> + <text>Blacklist</text> + <url>/pkg.php?xml=havp_blacklist.xml</url> + </tab> + </tabs> + + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://agni.linuxense.com/packages/config/havp.inc</item> + </additional_files_needed> + + <configpath>['installedpackages']['havpwhitelist']['config']</configpath> + + <adddeleteeditpagefields> + <columnitem> + <fielddescr>Exempted URL</fielddescr> + <fieldname>url</fieldname> + </columnitem> + <columnitem> + <fielddescr>Description</fielddescr> + <fieldname>description</fieldname> + </columnitem> + </adddeleteeditpagefields> + + <fields> + <field> + <fielddescr>Exempted URL</fielddescr> + <fieldname>url</fieldname> + <description>Enter the URL to exempt from blacklisting</description> + <type>input</type> + </field> + <field> + <fielddescr>Description</fielddescr> + <fieldname>description</fieldname> + <description>Enter the description for this item</description> + <type>input</type> + </field> + </fields> + + <custom_php_command_before_form>sync_package_havp_whitelist();</custom_php_command_before_form> + <custom_delete_php_command>sync_package_havp_whitelist();</custom_delete_php_command> + <custom_php_resync_config_command>sync_package_havp_whitelist();</custom_php_resync_config_command> +</packagegui> |