aboutsummaryrefslogtreecommitdiffstats
path: root/config/ntopng
diff options
context:
space:
mode:
Diffstat (limited to 'config/ntopng')
-rw-r--r--config/ntopng/ntopng.xml53
1 files changed, 43 insertions, 10 deletions
diff --git a/config/ntopng/ntopng.xml b/config/ntopng/ntopng.xml
index 9382912a..225b3941 100644
--- a/config/ntopng/ntopng.xml
+++ b/config/ntopng/ntopng.xml
@@ -153,12 +153,18 @@
$ntopng_config =& $config['installedpackages']['ntopng']['config'][0];
$if_final = "";
$ifaces_final = "";
- system("/bin/mkdir -p /var/db/ntopng");
- system("/bin/mkdir -p /var/db/ntopng/rrd");
- system("/bin/mkdir -p /var/db/ntopng/rrd/graphics");
+ safe_mkdir("/var/db/ntopng/rrd/graphics", 0755, true);
system("/bin/chmod -R 755 /var/db/ntopng");
system("/usr/sbin/chown -R nobody:nobody /var/db/ntopng");
- system("/bin/cp -Rp /usr/local/lib/X11/fonts/webfonts/ /usr/local/lib/X11/fonts/TTF/");
+ $pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
+ if ($pf_version == "2.2") {
+ $fonts_path = "/usr/pbi/ntopng-" . php_uname("m") . "/local/lib/X11/fonts";
+ } else if ($pf_version == "2.1") {
+ $fonts_path = "/usr/pbi/ntopng-" . php_uname("m") . "/lib/X11/fonts";
+ } else {
+ $fonts_path = "/usr/local/lib/X11/fonts";
+ }
+ system("/bin/cp -Rp {$fonts_path}/webfonts/ {$fonts_path}/TTF/");
$first = 0;
foreach($ntopng_config['interface_array'] as $iface) {
$if = convert_friendly_interface_to_real_interface_name($iface);
@@ -206,13 +212,18 @@
}
$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
- if ($pf_version >= 2.2) {
+ if ($pf_version == "2.2") {
$redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/local/bin";
- } else {
+ } else if ($pf_version == "2.1") {
$redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/bin";
+ } else {
+ $redis_path = "/usr/local/bin";
}
- $start = "ldconfig -m /usr/pbi/ntopng-" . php_uname("m") . "/lib\n";
+ $start = "";
+ if ($pf_version == "2.1" || $pf_version == "2.2") {
+ $start .= "ldconfig -m /usr/pbi/ntopng-" . php_uname("m") . "/lib\n";
+ }
$start .= "\t{$redis_path}/redis-server --dir /var/db/ntopng/ --dbfilename ntopng.rdb &\n";
// TODO:
// Add support for --data-dir /somewhere, --httpdocs-dir /somewhereelse,
@@ -243,13 +254,35 @@
config_unlock();
}
function ntopng_update_geoip() {
- mwexec("/usr/pbi/ntopng-" . php_uname("m") . "/bin/ntopng-geoipupdate.sh");
+ $fetchcmd = "/usr/bin/fetch";
+ $geolite_city = "https://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz";
+ $geolite_city_v6 = "https://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz";
+ $geoip_asnum = "https://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz";
+ $geoip_asnum_v6 = "https://download.maxmind.com/download/geoip/database/asnum/GeoIPASNumv6.dat.gz";
+ $pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
+ if ($pf_version == "2.1" || $pf_version == "2.2") {
+ $output_dir = "/usr/pbi/ntopng-" . php_uname("m") . "/share/ntopng";
+ } else {
+ $output_dir = "/usr/local/share/ntopng";
+ }
+
+ mwexec("{$fetchcmd} -o {$output_dir} -T 5 {$geolite_city}");
+ mwexec("{$fetchcmd} -o {$output_dir} -T 5 {$geolite_city_v6}");
+ mwexec("{$fetchcmd} -o {$output_dir} -T 5 {$geoip_asnum}");
+ mwexec("{$fetchcmd} -o {$output_dir} -T 5 {$geoip_asnum_v6}");
+
ntopng_fixup_geoip();
restart_service("ntopng");
}
function ntopng_fixup_geoip() {
- $target_dir = "/usr/pbi/ntopng-" . php_uname("m") . "/local/share/ntopng/httpdocs/geoip";
- $source_dir = "/usr/pbi/ntopng-" . php_uname("m") . "/share/ntopng";
+ $pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
+ if ($pf_version == "2.1" || $pf_version == "2.2") {
+ $target_dir = "/usr/pbi/ntopng-" . php_uname("m") . "/local/share/ntopng/httpdocs/geoip";
+ $source_dir = "/usr/pbi/ntopng-" . php_uname("m") . "/share/ntopng";
+ } else {
+ $target_dir = "/usr/local/share/ntopng/httpdocs/geoip";
+ $source_dir = "/usr/local/share/ntopng";
+ }
foreach(glob("{$source_dir}/Geo*.dat*") as $geofile) {
/* Decompress if needed. */