aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/pfblockerng/geoipupdate.sh28
-rw-r--r--config/pfblockerng/pfblockerng.inc40
-rw-r--r--config/pfblockerng/pfblockerng.php40
-rw-r--r--config/tinc/tinc.inc2
-rw-r--r--config/vnstat2/vnstat2.inc96
-rw-r--r--config/vnstat2/vnstat2.xml2
-rw-r--r--config/vnstat2/www/vnstat2_img.php4
-rw-r--r--config/zabbix2/zabbix2.inc54
8 files changed, 167 insertions, 99 deletions
diff --git a/config/pfblockerng/geoipupdate.sh b/config/pfblockerng/geoipupdate.sh
index 4b8fbb63..302f81f5 100644
--- a/config/pfblockerng/geoipupdate.sh
+++ b/config/pfblockerng/geoipupdate.sh
@@ -23,19 +23,23 @@
# may be met by including the following in all advertising and documentation
# mentioning features of or use of this database.
-# Folder Locations
+mtype=$(/usr/bin/uname -m);
+
+# Application Locations
pathfetch=/usr/bin/fetch
pathtar=/usr/bin/tar
pathgunzip=/usr/bin/gunzip
-# File Locations
+# Folder Locations
pathdb=/var/db/pfblockerng
+pathpbi=/usr/pbi/pfblockerng-$mtype/share/GeoIP
pathlog=/var/log/pfblockerng
+
+# File Locations
errorlog=$pathlog/geoip.log
-pathgeoipdatgz=$pathdb/GeoIP.dat.gz
-pathgeoipdatgzv6=$pathdb/GeoIPv6.dat.gz
-pathgeoipdat=$pathdb/GeoIP.dat
-pathgeoipdatv6=$pathdb/GeoIPv6.dat
+geoipdat=/GeoIP.dat
+geoipdatv6=/GeoIPv6.dat
+
pathgeoipcc=$pathdb/country_continent.csv
pathgeoipcsv4=$pathdb/GeoIPCountryCSV.zip
pathgeoipcsvfinal4=$pathdb/GeoIPCountryWhois.csv
@@ -56,12 +60,12 @@ binaryupdate() {
echo " ** Downloading MaxMind GeoLite IPv4 Binary Database (For Reputation/Alerts Processes) **"; echo
URL="http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
-$pathfetch -v -o $pathgeoipdatgz -T 20 $URL
+$pathfetch -v -o $pathpbi$geoipdat.gz -T 20 $URL
if [ "$?" -eq "0" ]; then
- $pathgunzip -f $pathgeoipdatgz
+ $pathgunzip -f $pathpbi$geoipdat.gz
echo; echo " ( MaxMind IPv4 GeoIP.dat has been updated )"; echo
echo "Current Date/Timestamp:"
- /bin/ls -alh $pathgeoipdat
+ /bin/ls -alh $pathpbi$geoipdat
echo
else
echo; echo " => MaxMind IPv4 GeoIP.dat Update [ FAILED ]"; echo
@@ -72,12 +76,12 @@ fi
echo; echo " ** Downloading MaxMind GeoLite IPv6 Binary Database (For Reputation/Alerts Processes) **"; echo
URL="http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz"
-$pathfetch -v -o $pathgeoipdatgzv6 -T 20 $URL
+$pathfetch -v -o $pathpbi$geoipdatv6.gz -T 20 $URL
if [ "$?" -eq "0" ]; then
- $pathgunzip -f $pathgeoipdatgzv6
+ $pathgunzip -f $pathpbi$geoipdatv6.gz
echo; echo " ( MaxMind IPv6 GeoIPv6.dat has been updated )"; echo
echo "Current Date/Timestamp:"
- /bin/ls -alh $pathgeoipdatv6
+ /bin/ls -alh $pathpbi$geoipdatv6
echo
else
echo; echo " => MaxMind IPv6 GeoIPv6.dat Update [ FAILED ]"; echo
diff --git a/config/pfblockerng/pfblockerng.inc b/config/pfblockerng/pfblockerng.inc
index d612dbf1..0eb3ff43 100644
--- a/config/pfblockerng/pfblockerng.inc
+++ b/config/pfblockerng/pfblockerng.inc
@@ -350,13 +350,21 @@ function sync_package_pfblockerng($cron = "") {
}
log_error("[pfBlockerNG] Starting sync process.");
+ // Force Update - Set 'Save' variable when 'No Updates' found.
+ if ($cron == "noupdates") {
+ $pfb['save'] = TRUE;
+ }
+
# Start of pfBlockerNG Logging to 'pfblockerng.log'
if ($pfb['enable'] == "on" && !$pfb['save']) {
$log = " UPDATE PROCESS START [ NOW ]\n";
+ pfb_logger("{$log}","1");
} else {
- $log = "\n**Saving Configuration [ NOW ] ...\n";
+ if ($cron != "noupdates") {
+ $log = "\n**Saving Configuration [ NOW ] ...\n";
+ pfb_logger("{$log}","1");
+ }
}
- pfb_logger("{$log}","1");
# TBC if Required ! (Fetch Timeout in 2.2)
@@ -2341,9 +2349,6 @@ function pfblockerng_php_install_command() {
update_output_window(gettext("Downloading MaxMind Country Databases. This may take a minute..."));
exec("/bin/sh /usr/local/pkg/pfblockerng/geoipupdate.sh all >> {$pfb['geolog']} 2>&1");
- @rename("{$pfb['dbdir']}/GeoIP.dat", "{$pfb['ccdir']}/GeoIP.dat");
- @rename("{$pfb['dbdir']}/GeoIPv6.dat", "{$pfb['ccdir']}/GeoIPv6.dat");
-
update_output_window(gettext("MaxMind Country Database downloads completed..."));
update_output_window(gettext("Converting MaxMind Country Databases for pfBlockerNG. This may take a few minutes..."));
pfblockerng_uc_countries();
@@ -2564,18 +2569,19 @@ function pfblockerng_do_xmlrpc_sync($sync_to_ip, $port, $protocol, $username, $p
$xml = array();
// If User Disabled, remove 'General Tab Customizations' from Sync
if ($config['installedpackages']['pfblockerngsync']['config'][0]['syncinterfaces'] == "")
- $xml['pfblockerng'] = $config['installedpackages']['pfblockerng'];
- $xml['pfblockerngreputation'] = $config['installedpackages']['pfblockerngreputation'];
- $xml['pfblockernglistsv4'] = $config['installedpackages']['pfblockernglistsv4'];
- $xml['pfblockernglistsv6'] = $config['installedpackages']['pfblockernglistsv6'];
- $xml['pfblockerngtopspammers'] = $config['installedpackages']['pfblockerngtopspammers'];
- $xml['pfblockerngafrica'] = $config['installedpackages']['pfblockerngafrica'];
- $xml['pfblockerngantartica'] = $config['installedpackages']['pfblockerngantartica'];
- $xml['pfblockerngasia'] = $config['installedpackages']['pfblockerngasia'];
- $xml['pfblockerngeurope'] = $config['installedpackages']['pfblockerngeurope'];
- $xml['pfblockerngnorthamerica'] = $config['installedpackages']['pfblockerngnorthamerica'];
- $xml['pfblockerngoceania'] = $config['installedpackages']['pfblockerngoceania'];
- $xml['pfblockerngsouthamerica'] = $config['installedpackages']['pfblockerngsouthamerica'];
+ $xml['pfblockerng'] = $config['installedpackages']['pfblockerng'];
+ $xml['pfblockerngreputation'] = $config['installedpackages']['pfblockerngreputation'];
+ $xml['pfblockernglistsv4'] = $config['installedpackages']['pfblockernglistsv4'];
+ $xml['pfblockernglistsv6'] = $config['installedpackages']['pfblockernglistsv6'];
+ $xml['pfblockerngtopspammers'] = $config['installedpackages']['pfblockerngtopspammers'];
+ $xml['pfblockerngafrica'] = $config['installedpackages']['pfblockerngafrica'];
+ $xml['pfblockerngantartica'] = $config['installedpackages']['pfblockerngantartica'];
+ $xml['pfblockerngasia'] = $config['installedpackages']['pfblockerngasia'];
+ $xml['pfblockerngeurope'] = $config['installedpackages']['pfblockerngeurope'];
+ $xml['pfblockerngnorthamerica'] = $config['installedpackages']['pfblockerngnorthamerica'];
+ $xml['pfblockerngoceania'] = $config['installedpackages']['pfblockerngoceania'];
+ $xml['pfblockerngsouthamerica'] = $config['installedpackages']['pfblockerngsouthamerica'];
+ $xml['pfblockerngproxyandsatellite'] = $config['installedpackages']['pfblockerngproxyandsatellite'];
/* assemble xmlrpc payload */
$params = array(
diff --git a/config/pfblockerng/pfblockerng.php b/config/pfblockerng/pfblockerng.php
index 1db36334..0ca3aa7d 100644
--- a/config/pfblockerng/pfblockerng.php
+++ b/config/pfblockerng/pfblockerng.php
@@ -44,9 +44,13 @@ require_once("functions.inc");
require_once("pkg-utils.inc");
require_once("globals.inc");
require_once("services.inc");
-require_once("/usr/local/pkg/pfblockerng/pfblockerng.inc");
-pfb_global();
+// Call Include File and Collect updated Global Settings
+if (in_array($argv[1], array( 'update','dc','uc','gc','cron' ))) {
+ require_once("/usr/local/pkg/pfblockerng/pfblockerng.inc");
+ pfb_global();
+}
+
// IPv6 Range to CIDR function used courtesey from:
// https://github.com/stilez/pfsense-leases/blob/50cc0fa81dba5fe91bcddaea016c245d1b8479cc/etc/inc/util.inc
@@ -147,7 +151,7 @@ $uname = posix_uname();
if ($uname['machine'] == "amd64")
ini_set('memory_limit', '256M');
-function pfb_update_check($header_url, $list_url, $url_format) {
+function pfb_update_check($header_url, $list_url, $url_format, $pfbfolder) {
global $pfb;
$pfb['cron_update'] = FALSE;
@@ -230,6 +234,12 @@ if ($argv[1] == 'dc') {
}
pfblockerng_uc_countries();
pfblockerng_get_countries();
+
+ // Remove Original Maxmind Database Files
+ @unlink_if_exists("{$pfb['dbdir']}/GeoIPCountryCSV.zip");
+ @unlink_if_exists("{$pfb['dbdir']}/GeoIPCountryWhois.csv");
+ @unlink_if_exists("{$pfb['dbdir']}/GeoIPv6.csv");
+ @unlink_if_exists("{$pfb['dbdir']}/country_continent.csv");
}
if ($argv[1] == 'uc') {
@@ -408,13 +418,11 @@ if ($argv[1] == 'cron') {
if ($pfb['update_cron']) {
sync_package_pfblockerng("cron");
} else {
- $log = "\n No Updates required. \n\n";
+ sync_package_pfblockerng("noupdates");
+ $log = "\n No Updates required.\n CRON PROCESS ENDED\n UPDATE PROCESS ENDED\n";
pfb_logger("{$log}","1");
}
- $log = " CRON PROCESS ENDED [ NOW ]\n";
- pfb_logger("{$log}","1");
-
# Call Log Mgmt Function
// If Update GUI 'Manual view' is selected. Last output will be missed. So sleep for 5 secs.
sleep(5);
@@ -425,7 +433,6 @@ if ($argv[1] == 'cron') {
// Function to process the downloaded Maxmind Database and format into Continent txt files.
function pfblockerng_uc_countries() {
global $g,$pfb;
- pfb_global();
$maxmind_cont = "{$pfb['dbdir']}/country_continent.csv";
$maxmind_cc4 = "{$pfb['dbdir']}/GeoIPCountryWhois.csv";
@@ -584,7 +591,6 @@ function pfblockerng_uc_countries() {
// Function to process Continent txt files and create Country ISO files and to Generate GUI XML files.
function pfblockerng_get_countries() {
global $g,$pfb;
- pfb_global();
$files = array ( "Africa" => "{$pfb['ccdir']}/Africa_v4.txt",
"Asia" => "{$pfb['ccdir']}/Asia_v4.txt",
@@ -622,7 +628,9 @@ function pfblockerng_get_countries() {
if (preg_match("/#/",$line)) {
if ($pfb['complete']) {
${'coptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
- ${'roptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
+ // Only collect IPv4 for Reputation Tab
+ if ($type == "4")
+ $roptions4[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
// Save ISO data
@file_put_contents($pfb['ccdir'] . '/' . $isocode . '_v' . $type . '.txt', $xml_data, LOCK_EX);
@@ -646,7 +654,8 @@ function pfblockerng_get_countries() {
if ($keycount == $lastkey) {
if (preg_match("/Total Networks: 0/", $line)) { continue;} // Dont Display Countries with Null Data
${'coptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
- ${'roptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
+ if ($type == "4")
+ $roptions4[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
@file_put_contents($pfb['ccdir'] . '/' . $isocode . '_v' . $type . '.txt', $xml_data, LOCK_EX);
unset($total, $xml_data);
}
@@ -962,13 +971,12 @@ EOF;
// Sort Countries IPv4 Alphabetically and Build XML <option> Data for Reputation Tab (IPv6 not used by ET IQRisk)
- $type = "4";
- sort(${'roptions' . $type}, SORT_STRING);
- $eoa = count(${'roptions' . $type});
+ sort($roptions4, SORT_STRING);
+ $eoa = count($roptions4);
$count = 1;
$etoptions = "";
- foreach (${'roptions' . $type} as $option4) {
+ foreach ($roptions4 as $option4) {
if ($count == 1) { $et_options .= "\t" . '<option><name>' . $option4 . "\n"; $count++; continue; }
if ($eoa == $count) {
$et_options .= "\t\t\t\t" . '<option><name>' . $option4;
@@ -1470,6 +1478,6 @@ EOF;
pfb_logger("{$log}","3");
// Unset Arrays
- unset ($et_options, $xmlrep);
+ unset ($roptions4, $et_options, $xmlrep);
}
?> \ No newline at end of file
diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc
index bf4101d7..8b2b671c 100644
--- a/config/tinc/tinc.inc
+++ b/config/tinc/tinc.inc
@@ -1,5 +1,7 @@
<?php
+include_once('guiconfig.inc'); // needed for clear_log_file() during package installation while booting
+
function tinc_save() {
global $config;
conf_mount_rw();
diff --git a/config/vnstat2/vnstat2.inc b/config/vnstat2/vnstat2.inc
index 7418530f..f248083e 100644
--- a/config/vnstat2/vnstat2.inc
+++ b/config/vnstat2/vnstat2.inc
@@ -1,4 +1,5 @@
<?php
+require_once("util.inc");
function vnstat_install_deinstall() {
conf_mount_rw();
global $config;
@@ -113,18 +114,22 @@ EOF;
}
fwrite($hf2, $vnstat_conf_file);
fclose($hf2);
+ vnstat_link_config();
+ vnstat_create_nic_dbs();
}
function create_vnstati_image() {
conf_mount_rw();
global $config;
+ $vnstat_tmp = "/tmp/vnstat";
$iface = $_POST['vnstat_interface'];
$ifaces_final = convert_friendly_interface_to_real_interface_name($iface);
$config['installedpackages']['vnstat2']['config'][0]['vnstat_interface'] = $ifaces_final;
- exec("/usr/local/bin/vnstati -i ". $ifaces_final ." -vs -o /tmp/newpicture1.png");
- exec("/usr/local/bin/vnstati -i ". $ifaces_final ." -m -o /tmp/newpicture2.png");
- exec("/usr/local/bin/vnstati -i ". $ifaces_final ." -d -o /tmp/newpicture3.png");
- exec("/usr/local/bin/vnstati -i ". $ifaces_final ." -t -o /tmp/newpicture4.png");
+ @mkdir($vnstat_tmp);
+ exec("/usr/local/bin/vnstati -i ". escapeshellarg($ifaces_final) ." -vs -o {$vnstat_tmp}/newpicture1.png");
+ exec("/usr/local/bin/vnstati -i ". escapeshellarg($ifaces_final) ." -m -o {$vnstat_tmp}/newpicture2.png");
+ exec("/usr/local/bin/vnstati -i ". escapeshellarg($ifaces_final) ." -d -o {$vnstat_tmp}/newpicture3.png");
+ exec("/usr/local/bin/vnstati -i ". escapeshellarg($ifaces_final) ." -t -o {$vnstat_tmp}/newpicture4.png");
write_config();
conf_mount_ro();
}
@@ -139,50 +144,71 @@ function create_vnstat_output() {
conf_mount_ro();
}
+function vnstat_link_config() {
+// Check for pbi install and arch type then create symlinks
+ if (file_exists('/usr/pbi/vnstat-' . php_uname("m"))) {
+ $conf_path = "/usr/local/etc/vnstat.conf";
+ $pbi_conf_path = "/usr/pbi/vnstat-" . php_uname("m") . "/etc/vnstat.conf";
+ unlink_if_exists($pbi_conf_path);
+ symlink($conf_path, $pbi_conf_path);
+ }
+}
+
+function vnstat_create_nic_dbs() {
+ global $config;
+ conf_mount_rw();
+ $vnstat_db_prefix = "/conf/vnstat";
+ @mkdir($vnstat_db_prefix);
+
+ // Locate NICs and create associated databases
+ $array_of_real_nic_names = array();
+ $array_of_custom_nic_names = array();
+ $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
+ for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
+ $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
+ }
+ foreach ($ifdescrs as $ifdescr => $ifname) {
+ $real_nic_names = convert_friendly_interface_to_real_interface_name($ifdescr);
+ array_push($array_of_real_nic_names, $real_nic_names);
+ }
+ $vnstat_nic = array_map('basename', glob($vnstat_db_prefix . '/*', GLOB_ONLYDIR));
+
+ // Compare real NICs with NICs assigned to vnstat
+ $leftovers = array_diff($array_of_real_nic_names, $vnstat_nic);
+ // Create database for each NIC
+ foreach ($leftovers as $nic) {
+ exec("/usr/local/bin/vnstat -u -i ". escapeshellarg($nic));
+ }
+
+ conf_mount_ro();
+}
+
function vnstat_install_config() {
- global $config;
+ $vnstat_db_prefix = "/conf/vnstat";
conf_mount_rw();
// Create vnstat database dir where it also will work for nanobsd
-// exec("[ -d /var/db/vnstat ] && mv /var/db/vnstat /conf/vnstat");
- exec("[ -d /usr/local/pkg/vnstat2/vnstat ] && mv /usr/local/pkg/vnstat2/vnstat /conf/vnstat");
- exec("[ ! -d /conf/vnstat ] && mkdir /conf/vnstat");
-// Check for pbi install and arch type then create symlinks
- if (file_exists('/usr/pbi/vnstat-i386')) { exec("ln -s /usr/local/etc/vnstat.conf /usr/pbi/vnstat-i386/etc/vnstat.conf"); }
- if (file_exists('/usr/pbi/vnstat-amd64')) { exec("ln -s /usr/local/etc/vnstat.conf /usr/pbi/vnstat-amd64/etc/vnstat.conf"); }
+ if (is_dir("/usr/local/pkg/vnstat2/vnstat")) {
+ @rename("/usr/local/pkg/vnstat2/vnstat", $vnstat_db_prefix);
+ }
+ if (!is_dir($vnstat_db_prefix)) {
+ @mkdir($vnstat_db_prefix);
+ }
+ vnstat_link_config();
// Add MonthRotate value to config.xml and write /usr/local/etc/vnstat.conf
$no_monthrotate = $config['installedpackages']['vnstat2']['config'][0]['monthrotate'];
if ($no_monthrotate == ""){
$config['installedpackages']['vnstat2']['config'][0]['monthrotate'] = "1";
}
$no_vnstat_phpfrontend = $config['installedpackages']['vnstat2']['config'][0]['vnstat_phpfrontend'];
- if ($no_vnstat_phpfrontend == "on"){
- vnstat_php_frontend();
+ if ($no_vnstat_phpfrontend == "on"){
+ vnstat_php_frontend();
}
write_conf_f();
// Add cron job to config.xml
vnstat2_install_cron(true);
-// get system nic's and create a database for them
- $array_of_real_nic_names = array();
- $array_of_custom_nic_names = array();
- $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
- for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
- $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
- }
- foreach ($ifdescrs as $ifdescr => $ifname):
- $real_nic_names = convert_friendly_interface_to_real_interface_name($ifdescr);
- array_push($array_of_real_nic_names, $real_nic_names);
- endforeach;
- // Get already nic's assigned to vnstat
- exec("ls /conf/vnstat/ | grep -v '\.'", $vnstat_nic);
- // Compare real nic's with nic's assigned to vnstat
- $result = array_diff($array_of_real_nic_names, $vnstat_nic);
- // Create database for each nic
- foreach ($result as $result2)
- {
- exec("/usr/local/bin/vnstat -u -i ". $result2);
- }
- write_config();
- conf_mount_ro();
+ vnstat_create_nic_dbs();
+ write_config();
+ conf_mount_ro();
}
function vnstat_php_frontend(){
diff --git a/config/vnstat2/vnstat2.xml b/config/vnstat2/vnstat2.xml
index ab07f004..94b7cfc1 100644
--- a/config/vnstat2/vnstat2.xml
+++ b/config/vnstat2/vnstat2.xml
@@ -7,7 +7,7 @@
<requirements>Describe your package requirements here</requirements>
<faq>Currently there are no FAQ items provided.</faq>
<name>vnstat2</name>
- <version>1.0</version>
+ <version>11.2,3</version>
<title>Vnstat2</title>
<aftersaveredirect>/pkg_edit.php?xml=vnstat2.xml&amp;id=0</aftersaveredirect>
<include_file>/usr/local/pkg/vnstat2/vnstat2.inc</include_file>
diff --git a/config/vnstat2/www/vnstat2_img.php b/config/vnstat2/www/vnstat2_img.php
index 85644309..a83c3b06 100644
--- a/config/vnstat2/www/vnstat2_img.php
+++ b/config/vnstat2/www/vnstat2_img.php
@@ -1,6 +1,6 @@
<?php
require_once("guiconfig.inc");
-$image = $_GET['image'];
+$image = basename($_GET['image']);
header("Content-type: image/png");
-readfile("/tmp/$image");
+readfile("/tmp/vnstat/{$image}");
?>
diff --git a/config/zabbix2/zabbix2.inc b/config/zabbix2/zabbix2.inc
index 13713988..77f1d6e1 100644
--- a/config/zabbix2/zabbix2.inc
+++ b/config/zabbix2/zabbix2.inc
@@ -2,10 +2,10 @@
/* $Id$ */
/* ========================================================================== */
/*
- zabbix2-proxy.inc
+ zabbix2.inc
part of the Zabbix package for pfSense
Copyright (C) 2013 Danilo G. Baio
- Copyright (C) 2013 Marcello Coutinho
+ Copyright (C) 2013 Marcello Coutinho
All rights reserved.
*/
@@ -46,16 +46,18 @@ function php_deinstall_zabbix2_agent(){
global $config, $g;
conf_mount_rw();
- $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3);
+ $pfs_version = php_zabbix2_pfs_version();
+ $zabbix2_pkg_base = php_zabbix2_pkg_base($pfs_version);
+
if ($pfs_version > 2.0){
- define('ZABBIX_AGENT_BASE', '/usr/pbi/zabbix22-agent-' . php_uname("m"));
+ define('ZABBIX_AGENT_BASE', '/usr/pbi/' . $zabbix2_pkg_base . '-agent-' . php_uname("m"));
} else {
define('ZABBIX_AGENT_BASE', '/usr/local');
}
exec("/usr/bin/killall zabbix_agentd");
unlink_if_exists(ZABBIX_AGENT_BASE . "/etc/rc.d/zabbix2_agentd.sh");
- unlink_if_exists(ZABBIX_AGENT_BASE . "/etc/zabbix22/zabbix_agentd.conf");
+ unlink_if_exists(ZABBIX_AGENT_BASE . "/etc/" . $zabbix2_pkg_base . "/zabbix_agentd.conf");
unlink_if_exists("/var/log/zabbix2/zabbix2_agentd.log");
unlink_if_exists("/var/run/zabbix2/zabbix2_agentd.pid");
@@ -73,16 +75,18 @@ function php_deinstall_zabbix2_proxy(){
global $config, $g;
conf_mount_rw();
- $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3);
+ $pfs_version = php_zabbix2_pfs_version();
+ $zabbix2_pkg_base = php_zabbix2_pkg_base($pfs_version);
+
if ($pfs_version > 2.0){
- define('ZABBIX_PROXY_BASE', '/usr/pbi/zabbix22-proxy-' . php_uname("m"));
+ define('ZABBIX_PROXY_BASE', '/usr/pbi/' . $zabbix2_pkg_base . '-proxy-' . php_uname("m"));
} else {
define('ZABBIX_PROXY_BASE', '/usr/local');
}
exec("/usr/bin/killall zabbix_proxy");
unlink_if_exists(ZABBIX_PROXY_BASE . "/etc/rc.d/zabbix2_proxy.sh");
- unlink_if_exists(ZABBIX_PROXY_BASE . "/etc/zabbix22/zabbix_proxy.conf");
+ unlink_if_exists(ZABBIX_PROXY_BASE . "/etc/" . $zabbix2_pkg_base . "/zabbix_proxy.conf");
unlink_if_exists("/var/log/zabbix2/zabbix_proxy.log");
unlink_if_exists("/var/run/zabbix2/zabbix2_proxy.pid");
@@ -177,11 +181,12 @@ function sync_package_zabbix2(){
global $config, $g;
conf_mount_rw();
- #check pfsense version
- $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3);
+ $pfs_version = php_zabbix2_pfs_version();
+ $zabbix2_pkg_base = php_zabbix2_pkg_base($pfs_version);
+
if ($pfs_version > 2.0){
- define('ZABBIX_AGENT_BASE', '/usr/pbi/zabbix22-agent-' . php_uname("m"));
- define('ZABBIX_PROXY_BASE', '/usr/pbi/zabbix22-proxy-' . php_uname("m"));
+ define('ZABBIX_AGENT_BASE', '/usr/pbi/' . $zabbix2_pkg_base . '-agent-' . php_uname("m"));
+ define('ZABBIX_PROXY_BASE', '/usr/pbi/' . $zabbix2_pkg_base . '-proxy-' . php_uname("m"));
}
else {
define('ZABBIX_AGENT_BASE', '/usr/local');
@@ -210,7 +215,7 @@ ProxyMode={$Mode}
{$AdvancedParams}
EOF;
- file_put_contents(ZABBIX_PROXY_BASE . "/etc/zabbix22/zabbix_proxy.conf", strtr($zbproxy_conf_file, array("\r" => "")));
+ file_put_contents(ZABBIX_PROXY_BASE . "/etc/" . $zabbix2_pkg_base . "/zabbix_proxy.conf", strtr($zbproxy_conf_file, array("\r" => "")));
}
}
/* check zabbix agent settings*/
@@ -244,7 +249,7 @@ StartAgents={$StartAgents}
{$UserParams}
EOF;
- file_put_contents(ZABBIX_AGENT_BASE . "/etc/zabbix22/zabbix_agentd.conf", strtr($zbagent_conf_file, array("\r" => "")));
+ file_put_contents(ZABBIX_AGENT_BASE . "/etc/" . $zabbix2_pkg_base . "/zabbix_agentd.conf", strtr($zbagent_conf_file, array("\r" => "")));
}
}
$want_sysctls = array(
@@ -293,8 +298,8 @@ EOF;
/*check startup script files*/
/* create a few directories and ensure the sample files are in place */
- if (!is_dir(ZABBIX_PROXY_BASE . "/etc/zabbix22"))
- exec("/bin/mkdir -p " . ZABBIX_PROXY_BASE . "/etc/zabbix22");
+ if (!is_dir(ZABBIX_PROXY_BASE . "/etc/" . $zabbix2_pkg_base))
+ exec("/bin/mkdir -p " . ZABBIX_PROXY_BASE . "/etc/" . $zabbix2_pkg_base);
$dir_checks = <<< EOF
if [ ! -d /var/log/zabbix2 ]
@@ -371,4 +376,21 @@ EOF;
conf_mount_ro();
}
+
+function php_zabbix2_pfs_version(){
+ $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3);
+ return $pfs_version;
+}
+
+function php_zabbix2_pkg_base($pfs_version){
+ if ($pfs_version >= 2.2){
+ // pfSense 2.2 with zabbix 2.4
+ $zabbix2_pkg_base = "zabbix24";
+ }else{
+ // pfSense 2.1 with zabbix 2.2
+ $zabbix2_pkg_base = "zabbix22";
+ }
+ return $zabbix2_pkg_base;
+}
+
?>