From 370fb83cd17d2ae4bc1b52715f82aaf4f7a74c58 Mon Sep 17 00:00:00 2001 From: Colin Smith Date: Sun, 24 Jul 2005 19:11:21 +0000 Subject: Tweak sync_package_ntop, add service entry, etc. --- packages/ntop/ntop.xml | 111 ++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 56 deletions(-) diff --git a/packages/ntop/ntop.xml b/packages/ntop/ntop.xml index 66396d17..0a8fc5bd 100644 --- a/packages/ntop/ntop.xml +++ b/packages/ntop/ntop.xml @@ -1,6 +1,6 @@ - Diagnostics: NTop + Diagnostics: ntop Settings ntop 3.0 yes @@ -8,25 +8,31 @@ pkg_edit.php?xml=ntop.xml&id=0 - NTop Settings - Set NTop settings such as password and port. + ntop Settings + Set ntop settings such as password and port.
Diagnostics
/pkg_edit.php?xml=ntop.xml&id=0
- NTop + ntop Access ntop http://$myurl:3000
Diagnostics
+ ntop
+ + ntop + ntop.sh + ntop + - NTop Settings + ntop Settings /pkg_edit.php?xml=ntop.xml&id=0 - NTop + Access ntop http://$myurl:3000 @@ -34,13 +40,13 @@ the configuration database. --> - NTOP Admin Password + ntop Admin Password password Enter the password for the NTOP Web GUI. Minimum 5 characters. password - NTOP Admin Password AGAIN + ntop Admin Password AGAIN passwordagain password @@ -53,57 +59,50 @@ interfaces_selection + + function sync_package_ntop() { + conf_mount_rw(); + config_lock(); + global $config; + global $input_errors; + $ntop_config =& $config['installedpackages']['ntop']['config'][0]; + $if_final = ""; + if($ntop_config['password'] and $ntop_config['passwordagain']) { + if($ntop_config['password'] == $ntop_config['passwordagain']) { + $ifaces = $ntop_config['iface']; + $isfirst = 0; + $lan = $config['interfaces']['lan']['if']; + foreach($ifaces as $if) { + if($isfirst == 1) $if_final = ","; + $if_final .= convert_friendly_interface_to_real_interface_name($if); + $isfirst = 1; + } + if(!$if_final) { + $if_final = $lan; + } + system("/usr/local/bin/ntop --set-admin-password=" . $_POST['password'] . " &"); + $start = "/usr/local/bin/ntop -i " . $if_final . " -u root -d --ipv4 -M -x 8102 -X 8192 &"; + write_rcfile(array( + "file" => "ntop.sh", + "start" => $start, + "stop" => "/usr/bin/killall ntop" + ) + ); + restart_service_if_running("ntop"); + } else { + $input_errors[] = "The provided passwords did not match."; + } + } else { + $input_errors[] = "You must provide (and confirm) ntop's password."; + } + conf_mount_ro(); + config_unlock(); + } + - function sync_package_ntop() { - conf_mount_rw(); - config_lock(); - if($_POST == "") $_POST = $config['installedpackages']['ntop']['config']; - $if_final = ""; - if($_POST['password'] == $_POST['passwordagain']) { - $ifaces=$_POST['iface']; - $isfirst = 0; - $lan = $config['interfaces']['lan']['if']; - foreach($ifaces as $if) - { - if($isfirst == 1) $if_final .= ","; - $if_final .= convert_friendly_interface_to_real_interface_name($if); - $isfirst = 1; - } - if($if_final == "") { - $if_final = $lan; - } - exec("/usr/local/bin/ntop --set-admin-password=" . $_POST['password']); - mwexec("killall ntop 2>/dev/null"); - $fout = fopen("/usr/local/etc/rc.d/ntop.sh","w"); - fwrite($fout, "#!/bin/sh\n\n"); - fwrite($fout, "/usr/local/bin/ntop -i " . $if_final . " -u root -d --ipv4 -M -x 8192 -X 8192\n\n"); - fclose($fout); - conf_mount_ro(); - config_unlock(); - chmod("/usr/local/etc/rc.d/ntop.sh", 0555); - mwexec("killall ntop"); - exec("/usr/local/etc/rc.d/ntop.sh"); - } else { - echo "Passwords do not match!"; - exit; - } - } - sync_package_ntop(); - + sync_package_ntop(); sync_package_ntop(); - - mwexec("/usr/bin/killall ntop"); - - - $fout = fopen("/usr/local/etc/rc.d/ntop.sh","w"); - fwrite($fout, "#!/bin/sh\n\n"); - fwrite($fout, "# PACKAGE: NTop\n"); - fwrite($fout, "# EXECUTABLE: ntop\n"); - fwrite($fout, "/usr/local/bin/ntop -u root -d --ipv4 -M\n\n"); - fclose($fout); - chmod("/usr/local/etc/rc.d/ntop.sh", 0555); -
-- cgit v1.2.3