From 296008c99ff8efc3de1d68c177d889004a095575 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 13 Sep 2015 23:58:24 +0200 Subject: ntopng - reworked package - Moved all PHP code to separate ntopng.inc - Add a button to wipe ntopng data - Add enable checkbox - Add checkbox to either keep or delete settings and data on uninstall/reinstall. - Some description cosmetics --- config/ntopng/ntopng.xml | 286 +++++++++++------------------------------------ 1 file changed, 66 insertions(+), 220 deletions(-) diff --git a/config/ntopng/ntopng.xml b/config/ntopng/ntopng.xml index 6c01515c..9416a693 100644 --- a/config/ntopng/ntopng.xml +++ b/config/ntopng/ntopng.xml @@ -9,7 +9,7 @@ /* ntopng.xml part of pfSense (https://www.pfSense.org/) - Copyright (C) 2014 ESF, LLC + Copyright (C) 2014-2015 ESF, LLC All rights reserved. */ /* ========================================================================== */ @@ -39,15 +39,19 @@ ]]> ntopng - 0.7.2 + 0.8.0 Diagnostics: ntopng Settings - Change + /usr/local/pkg/ntopng.inc + + /usr/local/pkg/ + https://packages.pfsense.org/packages/config/ntopng/ntopng.inc + pkg_edit.php?xml=ntopng.xml ntopng Settings Set ntopng settings such as password and port.
Diagnostics
- /pkg_edit.php?xml=ntopng.xml&id=0 + /pkg_edit.php?xml=ntopng.xml
ntopng @@ -60,12 +64,12 @@ ntopng ntopng.sh ntopng - ntopng bandwidth monitoring/graphing + ntopng Network Traffic Monitor ntopng Settings - /pkg_edit.php?xml=ntopng.xml&id=0 + /pkg_edit.php?xml=ntopng.xml @@ -74,33 +78,58 @@ + + Enable ntopng + enable + Check this to enable ntopng. + checkbox + + + Keep Data/Settings + keepdata + + + Note: If 'Keep Data' is disabled, all settings and data will be wiped on package uninstall/reinstall/upgrade! + ]]> + + checkbox + on + ntopng Admin Password - password - Enter the password for the ntopng GUI. Minimum 5 characters, defaults to admin. + redis_password + Enter the password for the ntopng GUI. Minimum 5 characters. password + true + 20 Confirm ntopng Admin Password - passwordagain + redis_passwordagain password + true + 20 Interface interface_array interfaces_selection 3 - lan + lan true + loopback DNS Mode dns_mode - Configures how name resolution is handled<br/><br/> - Additionally, GeoIP Data can provide location information about IP addresses.<br/> - This product includes GeoLite data created by MaxMind, available from <a href="http://www.maxmind.com">http://www.maxmind.com</a>.<br/> - <input type="submit" name="Submit" value="Update GeoIP Data"> +
+ Additionally, GeoIP Data can provide location information about IP addresses.
+ This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com

+ + ]]>
select 0 @@ -114,7 +143,12 @@ Local Networks local_networks - Configures how Local Networks are defined + + + (Default: Consider all RFC1918 networks local) + ]]> + select rfc1918 @@ -126,226 +160,38 @@ Historical Data Storage dump_flows - Enable historical data storage + + + WARNING: This feature consumes HUGE amount of disk space. + Also, browsing the historical data is VERY slow.
+ The historical interface is considered abandoned by upstream, + pending more usable replacement.

+ + WARNING: This will delete all ntopng graphs, traffic data and historical dump flows! + ]]> +
checkbox
Disable Alerts disable_alerts - Disables all alerts generated by ntopng, such as flooding notifications + Disables all alerts generated by ntopng, such as flooding notifications. checkbox
- - = 0) && ($ntopng_config['dns_mode'] <= 3)) { - $dns_mode = "--dns-mode " . escapeshellarg($ntopng_config['dns_mode']); - } - - // Local Networks > - switch ($ntopng_config['local_networks']) { - case "selected": - $nets = array(); - foreach ($ntopng_config['interface_array'] as $iface) { - if (is_ipaddr(get_interface_ip($iface))) { - $nets[] = gen_subnet(get_interface_ip($iface),get_interface_subnet($iface)) . '/' . get_interface_subnet($iface); - } - } - if (!empty($nets)) - $local_networks = "--local-networks " . escapeshellarg(implode(",", $nets)); - break; - case "lanonly": - if (is_ipaddr(get_interface_ip('lan'))) { - $local_networks = "--local-networks " . escapeshellarg(gen_subnet(get_interface_ip('lan'),get_interface_subnet('lan')) . '/' . get_interface_subnet('lan')); - } - break; - case "rfc1918": - default: - $local_networks = "--local-networks '192.168.0.0/16,172.16.0.0/12,10.0.0.0/8'"; - break; - } - - // Historical Data Storage, Dump expired flows - if ($ntopng_config['dump_flows'] >= on) { - $dump_flows = "-F"; - } - - // Disable alerts - if ($ntopng_config['disable_alerts'] >= on) { - $disable_alerts = "-H"; - } - - if ($pf_version == "2.2") { - $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/local/bin"; - } else if ($pf_version == "2.1") { - $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/bin"; - } else { - $redis_path = "/usr/local/bin"; - } - - $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, - // --dump-timeline (on/off) --http-port, --https-port - - $start .= "\t/usr/local/bin/ntopng -d /var/db/ntopng -G /var/run/ntopng.pid -s -e {$disable_alerts} {$dump_flows} {$ifaces} {$dns_mode} {$aggregations} {$local_networks} &"; - write_rcfile(array( - "file" => "ntopng.sh", - "start" => $start, - "stop" => "/usr/bin/killall ntopng redis-cli redis-server" - ) - ); - if (is_service_running("ntopng")) { - stop_service("ntopng"); - // Wait for ntopng to shut down cleanly. - sleep(20); - } - ntopng_fixup_geoip(); - start_service("ntopng"); - sleep(2); - - if (empty($ntopng_config['password'])) - $ntopng_config['password'] = "admin"; - $password = md5($ntopng_config['password']); - mwexec_bg("{$redis_path}/redis-cli SET user.admin.password " . escapeshellarg($password)); - mwexec_bg("{$redis_path}/redis-cli save"); - conf_mount_ro(); - } - function ntopng_update_geoip() { - $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() { - $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"; - } - - safe_mkdir($target_dir, 0755); - - foreach(glob("{$source_dir}/Geo*.dat*") as $geofile) { - /* Decompress if needed. */ - if (substr($geofile, -3, 3) == ".gz") { - // keep -f here, otherwise the files will not get updated - mwexec("/usr/bin/gzip -d -f " . escapeshellarg($geofile)); - } - } - - /* Use a separate glob since the filenames could have changed since the last run */ - foreach(glob("{$source_dir}/Geo*.dat*") as $geofile) { - $target_file = $target_dir . '/' . basename($geofile); - if (!file_exists($target_file)) { - symlink($geofile, $target_file); - } - } - } - ]]> - - - sync_package_ntopng(); - - sync_package_ntopng(); + ntopng_sync_package(); - + ntopng_sync_package(); - exec("rm /usr/local/etc/rc.d/ntopng*"); - $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); - if ($pf_version == "2.1" || $pf_version == "2.2") { - if (is_dir("/usr/local/share/ntopng/")) { - exec("rm -rf /usr/local/share/ntopng/"); - } - } + ntopng_php_deinstall_command(); - + ntopng_validate_input($_POST, $input_errors); -- cgit v1.2.3 From c0d7f98959303c8c5e294cbc40fa1ab62c30add4 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 14 Sep 2015 03:12:11 +0200 Subject: ntopng - reworked package - Moved all PHP code to separate ntopng.inc; should fix most of the whacky issues mentioned in Bug #4880 - Add wipe data feature - Add minimum password length check - Optionally wipe all traffic data, graphs and settings on uninstall if so configured --- config/ntopng/ntopng.inc | 371 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 371 insertions(+) create mode 100644 config/ntopng/ntopng.inc diff --git a/config/ntopng/ntopng.inc b/config/ntopng/ntopng.inc new file mode 100644 index 00000000..0f2fe52a --- /dev/null +++ b/config/ntopng/ntopng.inc @@ -0,0 +1,371 @@ += 0) && ($ntopng_config['dns_mode'] <= 3)) { + $dns_mode = "--dns-mode " . escapeshellarg($ntopng_config['dns_mode']); + } + + /* Local Networks */ + switch ($ntopng_config['local_networks']) { + case "selected": + $nets = array(); + foreach ($ntopng_config['interface_array'] as $iface) { + if (is_ipaddr(get_interface_ip($iface))) { + $nets[] = gen_subnet(get_interface_ip($iface), get_interface_subnet($iface)) . '/' . get_interface_subnet($iface); + } + } + if (!empty($nets)) { + $local_networks = "--local-networks " . escapeshellarg(implode(",", $nets)); + } + break; + case "lanonly": + if (is_ipaddr(get_interface_ip('lan'))) { + $local_networks = "--local-networks " . escapeshellarg(gen_subnet(get_interface_ip('lan'), get_interface_subnet('lan')) . '/' . get_interface_subnet('lan')); + } + break; + case "rfc1918": + default: + $local_networks = "--local-networks '192.168.0.0/16,172.16.0.0/12,10.0.0.0/8'"; + break; + } + + /* Historical Data Storage, Dump expired flows */ + if ($ntopng_config['dump_flows'] == "on") { + $dump_flows = "-F"; + } + + /* Disable alerts */ + if ($ntopng_config['disable_alerts'] == "on") { + $disable_alerts = "-H"; + } + + /* Create rc script */ + if ($pf_version == "2.2") { + $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/local/bin"; + } elseif ($pf_version == "2.1") { + $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/bin"; + } else { + $redis_path = "/usr/local/bin"; + } + + $start = ""; + $stop = ""; + 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, + // --dump-timeline (on/off) --http-port, --https-port + + $start .= "\t/usr/local/bin/ntopng -d /var/db/ntopng -G /var/run/ntopng.pid -s -e {$disable_alerts} {$dump_flows} {$ifaces} {$dns_mode} {$aggregations} {$local_networks} &\n"; + $stop .= "/usr/bin/killall ntopng redis-cli redis-server\n"; + write_rcfile(array("file" => "ntopng.sh", "start" => $start, "stop" => $stop)); + + /* Set up admin password */ + ntopng_set_redis_password(); + + /* Restart services if enabled and not booting */ + if ((function_exists("platform_booting")) && (!platform_booting())) { + ntopng_services_stop(); + if ($ntopng_config['enable'] == "on") { + start_service("ntopng"); + sleep(20); + } + } elseif ((!($g['booting'])) && (is_service_running("ntopng"))) { + ntopng_services_stop(); + if ($ntopng_config['enable'] == "on") { + start_service("ntopng"); + sleep(20); + } + } +} + +function ntopng_services_stop() { + if ((is_process_running("redis-server")) || (is_process_running("ntopng"))) { + stop_service("ntopng"); + } + for ($i = 0; $i <= 10; $i++) { + if ((!is_process_running("redis-server")) && (!is_process_running("ntopng"))) { + break; + } + sleep(2); + } +} + +function ntopng_redis_started() { + global $redis_path, $pf_version, $redis_started; + $redis_started = false; + $pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); + if ($pf_version == "2.2") { + $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/local/bin"; + } elseif ($pf_version == "2.1") { + $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/bin"; + } else { + $redis_path = "/usr/local/bin"; + } + if (!is_process_running("redis-server")) { + if ($pf_version == "2.1" || $pf_version == "2.2") { + mwexec("/sbin/ldconfig -m /usr/pbi/ntopng-" . php_uname("m") . "/lib"); + } + mwexec_bg("{$redis_path}/redis-server --dir /var/db/ntopng/ --dbfilename ntopng.rdb"); + for ($i = 0; $i <= 10; $i++) { + if (is_process_running("redis-server")) { + $redis_started = true; + break; + } + sleep(1); + } + } else { + $redis_started = true; + } + return $redis_started; +} + +function ntopng_set_redis_password() { + global $config, $ntopng_config, $redis_path; + $ntopng_config = $config['installedpackages']['ntopng']['config'][0]; + $pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); + if ($pf_version == "2.2") { + $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/local/bin"; + } elseif ($pf_version == "2.1") { + $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/bin"; + } else { + $redis_path = "/usr/local/bin"; + } + + if (!empty($ntopng_config['redis_password'])) { + $password = md5($ntopng_config['redis_password']); + if (ntopng_redis_started()) { + mwexec("{$redis_path}/redis-cli SET user.admin.password " . escapeshellarg($password)); + mwexec("{$redis_path}/redis-cli save"); + } else { + log_error(gettext("[ntopng] Cannot set admin password - redis-server is not running.")); + } + } +} + +function ntopng_create_datadir() { + safe_mkdir("/var/db/ntopng/rrd/graphics", 0755); + mwexec("/bin/chmod -R 755 /var/db/ntopng"); + mwexec("/usr/sbin/chown -R nobody:nobody /var/db/ntopng"); +} + +function ntopng_update_geoip() { + global $config; + $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(); + + $ntopng_config = $config['installedpackages']['ntopng']['config'][0]; + ntopng_services_stop(); + if ($ntopng_config['enable'] == "on") { + start_service("ntopng"); + } +} + +function ntopng_fixup_geoip() { + $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"; + } + + safe_mkdir($target_dir, 0755); + + foreach(glob("{$source_dir}/Geo*.dat*") as $geofile) { + /* Decompress if needed. */ + if (substr($geofile, -3, 3) == ".gz") { + // keep -f here, otherwise the files will not get updated + mwexec("/usr/bin/gzip -d -f " . escapeshellarg($geofile)); + } + } + + /* Use a separate glob since the filenames could have changed since the last run */ + foreach(glob("{$source_dir}/Geo*.dat*") as $geofile) { + $target_file = $target_dir . '/' . basename($geofile); + if (!file_exists($target_file)) { + symlink($geofile, $target_file); + } + } +} + +function ntopng_flush_historical_data() { + global $config, $ntopng_config, $redis_path; + $ntopng_config = $config['installedpackages']['ntopng']['config'][0]; + $pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); + if ($pf_version == "2.2") { + $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/local/bin"; + } elseif ($pf_version == "2.1") { + $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/bin"; + } else { + $redis_path = "/usr/local/bin"; + } + + if (ntopng_redis_started()) { + /* Delete all the keys of all the existing Redis databases */ + mwexec("{$redis_path}/redis-cli flushall"); + log_error(gettext("[ntopng] Flushed Redis DB.")); + /* Set admin password while redis-server is still running */ + ntopng_set_redis_password(); + log_error(gettext("[ntopng] Set admin password for Redis DB.")); + /* Stop services and delete all graphs, data and dump flows */ + ntopng_services_stop(); + if (is_dir("/var/db/ntopng/")) { + mwexec("rm -rf /var/db/ntopng/"); + log_error(gettext("[ntopng] Deleted ntopng historical traffic data and graphs.")); + } else { + log_error(gettext("[ntopng] Nothing to delete; /var/db/ntopng/ directory not found.")); + } + /* Re-create the required directory structure with proper permissions */ + ntopng_create_datadir(); + log_error(gettext("[ntopng] Re-created required data directory structure.")); + /* Resync settings and restart services if enabled */ + unset($_POST['Delete']); + ntopng_sync_package(); + log_error(gettext("[ntopng] Resynced ntopng settings.")); + } else { + $error = "Cannot delete historical data - redis-server is not running."; + log_error(gettext("[ntopng] {$error}")); + file_notice("ntopng", $error, "ntopng Delete Historical Data", ""); + } +} + +function ntopng_validate_input($post, &$input_errors) { + if (empty($_POST['redis_password']) || empty($_POST['redis_passwordagain'])) { + $input_errors[] = "You must provide (and confirm) ntopng's password."; + } + if ((strlen($_POST['redis_password']) < 5) || (strlen($_POST['redis_passwordagain']) < 5)) { + $input_errors[] = "Password must have at least 5 characters."; + } + if ($post['redis_password'] != $post['redis_passwordagain']) { + $input_errors[] = "The provided passwords did not match."; + } + if ($post['Submit'] == "Update GeoIP Data") { + ntopng_update_geoip(); + } + if ($post['Delete'] == "Delete (Historical) Data") { + ntopng_flush_historical_data(); + } +} + +?> -- cgit v1.2.3 From 45da04146fbb9633795fe3778fe72c7d509b5ed2 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 14 Sep 2015 03:14:07 +0200 Subject: Bump ntopng package version --- pkg_config.10.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 00c555ef..6eceaa45 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -299,7 +299,7 @@ databases/redis databases/gdbm net/GeoIP x11-fonts/font-util x11-fonts/webfonts graphics/graphviz net/ntopng - 0.7.2 + 0.8.0 ALPHA 2.2 https://packages.pfsense.org/packages/config/ntopng/ntopng.xml -- cgit v1.2.3 From 013a41134fec6f3993fcd05482bf1e7bf9cab4b3 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 14 Sep 2015 03:15:10 +0200 Subject: Bump ntopng package version --- pkg_config.8.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 52e43a28..9cd53084 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -368,7 +368,7 @@ databases/redis databases/gdbm net/GeoIP x11-fonts/font-util x11-fonts/webfonts graphics/graphviz net/ntopng - 1.1 v0.6 + 1.1 v0.8.0 ALPHA 2.1.4 https://packages.pfsense.org/packages/config/ntopng/ntopng.xml -- cgit v1.2.3 From e523e32740ded1228afbab058d1684419600162d Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 14 Sep 2015 03:15:58 +0200 Subject: Bump ntopng package version --- pkg_config.8.xml.amd64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 7b855836..348f9ef6 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -355,7 +355,7 @@ databases/redis databases/gdbm net/GeoIP x11-fonts/font-util x11-fonts/webfonts graphics/graphviz net/ntopng - 1.1 v0.6 + 1.1 v0.8.0 ALPHA 2.1.4 https://packages.pfsense.org/packages/config/ntopng/ntopng.xml -- cgit v1.2.3 From 0212a2be9c1951defa0087851188e0e3de0159bc Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 14 Sep 2015 03:23:51 +0200 Subject: ntopng.xml - nuke useless tag Remove depends_on_service tag. (If the idea was to only show the menu entry if the service is enabled, then it plain doesn't work, not implemented anywhere in the pfSense package code.) --- config/ntopng/ntopng.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/ntopng/ntopng.xml b/config/ntopng/ntopng.xml index 9416a693..f0dc182f 100644 --- a/config/ntopng/ntopng.xml +++ b/config/ntopng/ntopng.xml @@ -58,7 +58,6 @@ Access ntopng
Diagnostics
http://$myurl:3000 - ntopng
ntopng @@ -90,7 +89,7 @@ - Note: If 'Keep Data' is disabled, all settings and data will be wiped on package uninstall/reinstall/upgrade! + Note: If 'Keep Data/Settings' is disabled, all settings and data will be wiped on package uninstall/reinstall/upgrade! ]]> checkbox -- cgit v1.2.3 From 5ee6ff163bb39d1e1367c42c3626a4af7f7056de Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 14 Sep 2015 03:50:55 +0200 Subject: ntopng.xml - don't resync package twice on install Already done by install_package_xml() from pkg-utils.inc --- config/ntopng/ntopng.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/config/ntopng/ntopng.xml b/config/ntopng/ntopng.xml index f0dc182f..ee1a4d3e 100644 --- a/config/ntopng/ntopng.xml +++ b/config/ntopng/ntopng.xml @@ -185,7 +185,6 @@ ntopng_php_install_command(); ntopng_update_geoip(); - ntopng_sync_package(); ntopng_php_deinstall_command(); -- cgit v1.2.3 From a68395e1c0b7b3a8ecd2d41e7b604afa7f61c0a8 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 14 Sep 2015 03:53:56 +0200 Subject: ntopng.inc - remove pointless check already done elsewhere --- config/ntopng/ntopng.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/ntopng/ntopng.inc b/config/ntopng/ntopng.inc index 0f2fe52a..1f1c737a 100644 --- a/config/ntopng/ntopng.inc +++ b/config/ntopng/ntopng.inc @@ -173,7 +173,7 @@ function ntopng_sync_package() { start_service("ntopng"); sleep(20); } - } elseif ((!($g['booting'])) && (is_service_running("ntopng"))) { + } elseif (!($g['booting'])) { ntopng_services_stop(); if ($ntopng_config['enable'] == "on") { start_service("ntopng"); -- cgit v1.2.3 From 0a9a28c5d355b9737fb0657737ab5121594d8130 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 15 Sep 2015 00:03:56 +0200 Subject: Only (re)start ntopng after GeoIP update if not (re)installing the package Also, use $post consistently in topng_validate_input(). --- config/ntopng/ntopng.inc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/config/ntopng/ntopng.inc b/config/ntopng/ntopng.inc index 1f1c737a..27b484c1 100644 --- a/config/ntopng/ntopng.inc +++ b/config/ntopng/ntopng.inc @@ -173,7 +173,7 @@ function ntopng_sync_package() { start_service("ntopng"); sleep(20); } - } elseif (!($g['booting'])) { + } elseif (!($g['booting'])) { ntopng_services_stop(); if ($ntopng_config['enable'] == "on") { start_service("ntopng"); @@ -273,10 +273,13 @@ function ntopng_update_geoip() { ntopng_fixup_geoip(); - $ntopng_config = $config['installedpackages']['ntopng']['config'][0]; - ntopng_services_stop(); - if ($ntopng_config['enable'] == "on") { - start_service("ntopng"); + /* Do not (re)start services on package (re)install, only on manual GeoIP updates via the GUI */ + if ($_POST['Submit'] == "Update GeoIP Data") { + $ntopng_config = $config['installedpackages']['ntopng']['config'][0]; + ntopng_services_stop(); + if ($ntopng_config['enable'] == "on") { + start_service("ntopng"); + } } } @@ -351,10 +354,10 @@ function ntopng_flush_historical_data() { } function ntopng_validate_input($post, &$input_errors) { - if (empty($_POST['redis_password']) || empty($_POST['redis_passwordagain'])) { + if (empty($post['redis_password']) || empty($post['redis_passwordagain'])) { $input_errors[] = "You must provide (and confirm) ntopng's password."; } - if ((strlen($_POST['redis_password']) < 5) || (strlen($_POST['redis_passwordagain']) < 5)) { + if ((strlen($post['redis_password']) < 5) || (strlen($post['redis_passwordagain']) < 5)) { $input_errors[] = "Password must have at least 5 characters."; } if ($post['redis_password'] != $post['redis_passwordagain']) { -- cgit v1.2.3