From 3dc5d11da5557869f6fdfb4937f26186b19cdfb4 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 14 Nov 2015 14:01:25 +0100 Subject: ntop - package fixes and cleanups - Split PHP code to an inc file - Make it possible to disable ntop without uninstalling - Add Keep Data/Settings feature - Fix flipped 'Allow merging interfaces' meaning - Add privileges configuration - Code style cleanups --- config/ntop2/ntop.xml | 162 ++++++++++++++++++++++---------------------------- 1 file changed, 71 insertions(+), 91 deletions(-) (limited to 'config') diff --git a/config/ntop2/ntop.xml b/config/ntop2/ntop.xml index 6ba86525..5aab1e53 100644 --- a/config/ntop2/ntop.xml +++ b/config/ntop2/ntop.xml @@ -1,28 +1,31 @@ - - + + ntop - 3.0 + 2.3.2 Diagnostics: ntop Settings - Change - pkg_edit.php?xml=ntop.xml&id=0 + /usr/local/pkg/ntop.inc + + /usr/local/pkg/ + https://packages.pfsense.org/packages/config/ntop2/ntop.inc + + + /etc/inc/priv/ + https://packages.pfsense.org/packages/config/ntop2/ntop.priv.inc + + pkg_edit.php?xml=ntop.xml ntop Settings - Set ntop settings such as password and port.
Diagnostics
- /pkg_edit.php?xml=ntop.xml&id=0 + /pkg_edit.php?xml=ntop.xml
ntop @@ -60,12 +70,12 @@ ntop ntop.sh ntop - NTOP bandwidth monitoring/graphing + NTOP Network Traffic Monitor - ntop Settings - /pkg_edit.php?xml=ntop.xml&id=0 + Settings + /pkg_edit.php?xml=ntop.xml @@ -74,16 +84,38 @@ + + Enable ntop + enable + Check this to enable ntop. + checkbox + + + Keep Data/Settings + keepdata + + + Note: If 'Keep Data/Settings' is disabled, all settings and data will be wiped on package uninstall/reinstall/upgrade! + ]]> + + checkbox + on + ntop Admin Password password - Enter the password for the NTOP Web GUI. Minimum 5 characters. + Enter the password for the NTOP Web GUI. Minimum 5 characters. password + true + 20 - ntop Admin Password AGAIN + Confirm ntop Admin Password passwordagain password + true + 20 Interface @@ -92,82 +124,30 @@ 3 lan true + loopback - Allow merging interfaces<br>(Def: Do not merge) - allowmerge + Disallow merging interfaces + disallowmerge + + + Use this option to keep traffic separate by interface. (Default: Disabled) + ]]> + checkbox - - "ntop.sh", - "start" => $start, - "stop" => "/usr/bin/killall ntop" - ) - ); - if (is_service_running("ntop")) { - stop_service("ntop"); - // Wait for ntop to shut down cleanly. - sleep(20); - } - if (empty($ntop_config['password'])) - $ntop_config['password'] = "admin"; - unlink_if_exists("/var/db/ntop/ntop_pw.db"); - exec("/usr/local/bin/ntop --set-admin-password={$ntop_config['password']}"); - sleep(2); - start_service("ntop"); - conf_mount_ro(); - } - ]]> - - - sync_package_ntop(); - + + ntop_php_install_command(); + + + ntop_php_deinstall_command(); + sync_package_ntop(); - - sync_package_ntop(); - - + ntop_validate_input($_POST, $input_errors); -- cgit v1.2.3 From 27e7bfafeff0e314ea39529fb00c48e695c1854d Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 14 Nov 2015 14:03:41 +0100 Subject: ntop - package fixes and cleanups - Split PHP code to an inc file - Make it possible to disable ntop without uninstalling - Add Keep Data/Settings feature - Remove graphs/data/configuration on uninstall if Keep Data/Settings is disabled - Fix flipped 'Allow merging interfaces' meaning - Do not restart ntop during boot - Add privileges configuration - Code style cleanups --- config/ntop2/ntop.inc | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 config/ntop2/ntop.inc (limited to 'config') diff --git a/config/ntop2/ntop.inc b/config/ntop2/ntop.inc new file mode 100644 index 00000000..7c846b87 --- /dev/null +++ b/config/ntop2/ntop.inc @@ -0,0 +1,157 @@ + "ntop.sh", "start" => $start, "stop" => "/usr/bin/killall ntop")); + + /* Set up admin password and (re)start services if not booting */ + if ((function_exists("platform_booting")) && (!platform_booting())) { + ntop_stop_service(); + ntop_set_password(); + start_service("ntop"); + } elseif (!($g['booting'])) { + ntop_stop_service(); + ntop_set_password(); + start_service("ntop"); + } + + conf_mount_ro(); +} + +function ntop_stop_service() { + if (is_service_running("ntop")) { + stop_service("ntop"); + // Wait for ntop to shut down cleanly. + for ($i = 0; $i <= 10; $i++) { + if (!is_process_running("ntop")) { + break; + } + sleep(2); + } + } +} + +function ntop_set_password() { + global $config; + + if (is_array($config['installedpackages']['ntop'])) { + $ntop_config = $config['installedpackages']['ntop']['config'][0]; + } else { + $ntop_config = array(); + } + $ntop_password = $ntop_config['password'] ?: "admin"; + unlink_if_exists("/var/db/ntop/ntop_pw.db"); + mwexec("/usr/local/bin/ntop --set-admin-password={$ntop_password}"); + sleep(2); +} + +function ntop_validate_input($post, &$input_errors) { + if (empty($post['password']) || empty($post['passwordagain'])) { + $input_errors[] = "You must provide (and confirm) ntop's password."; + } + + if ($post['password'] != $post['passwordagain']) { + $input_errors[] = "The provided passwords did not match."; + } +} + +?> -- cgit v1.2.3 From 42fa4cbd74d5582078a378c32f04ccde800c4251 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 14 Nov 2015 14:05:25 +0100 Subject: Add privileges configuration to ntop package --- config/ntop2/ntop.priv.inc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 config/ntop2/ntop.priv.inc (limited to 'config') diff --git a/config/ntop2/ntop.priv.inc b/config/ntop2/ntop.priv.inc new file mode 100644 index 00000000..e8c80977 --- /dev/null +++ b/config/ntop2/ntop.priv.inc @@ -0,0 +1,37 @@ + -- cgit v1.2.3 From 74d4ad537cb20f53a76c19ce63e49220e2af24c9 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 14 Nov 2015 15:10:10 +0100 Subject: Fix the merge ifaces logic for renamed option --- config/ntop2/ntop.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/ntop2/ntop.inc b/config/ntop2/ntop.inc index 7c846b87..da017eac 100644 --- a/config/ntop2/ntop.inc +++ b/config/ntop2/ntop.inc @@ -87,7 +87,7 @@ function sync_package_ntop() { /* Set up ntop interfaces */ $ifaces_final = ""; $first = 0; - $mergeifs = ($ntop_config['disallowmerge'] == "on") ? "" : "-M"; + $mergeifs = $ntop_config['disallowmerge'] == "on" ? "-M" : ""; foreach ($ntop_config['interface_array'] as $iface) { $if = convert_friendly_interface_to_real_interface_name($iface); -- cgit v1.2.3