diff options
-rw-r--r-- | config/lightsquid/lightsquid.inc | 60 | ||||
-rw-r--r-- | config/ntop2/ntop.xml | 63 |
2 files changed, 75 insertions, 48 deletions
diff --git a/config/lightsquid/lightsquid.inc b/config/lightsquid/lightsquid.inc index ea9d408a..a062f401 100644 --- a/config/lightsquid/lightsquid.inc +++ b/config/lightsquid/lightsquid.inc @@ -91,25 +91,26 @@ define('LS_XML_SHEDULERTIME', 'lightsquid_refreshsheduler_time') define('LS_XML_SQUID_SHEDULERTIME', 'lightsquid_squidrotatelog_sheduler_time'); function lightsquid_install() { - update_log("lightsquid_install: started"); - // create lightsquid report catalog - if (!file_exists(LS_REPORTPATH)) { - update_log("lightsquid_install: Create report dir " . LS_REPORTPATH); - mwexec("mkdir -p " . LS_REPORTPATH); - } - - // install templates - $lstpl_file = "/var/tmp/lightsquid_tpl.tbz"; - if (file_exists($lstpl_file)) { - mwexec("tar zxvf $lstpl_file -C " . LS_TEMPLATEPATH); - update_log("lightsquid_install: Install templates from $lstpl_file"); - } - - # check perl - if (!file_exists("/usr/bin/perl")) - mwexec("ln -s /usr/local/bin/perl /usr/bin/perl"); - - update_log("lightsquid_install: stopped"); + update_log("lightsquid_install: started"); + + // create lightsquid report catalog + if (!file_exists(LS_REPORTPATH)) { + update_log("lightsquid_install: Create report dir " . LS_REPORTPATH); + mwexec("mkdir -p " . LS_REPORTPATH); + } + + // install templates + $lstpl_file = "/var/tmp/lightsquid_tpl.tbz"; + if (file_exists($lstpl_file)) { + mwexec("tar zxvf $lstpl_file -C " . LS_TEMPLATEPATH); + update_log("lightsquid_install: Install templates from $lstpl_file"); + } + + # check perl + if (!file_exists("/usr/bin/perl")) + mwexec("ln -s /usr/local/bin/perl /usr/bin/perl"); + + update_log("lightsquid_install: stopped"); } function lightsquid_deinstall() { @@ -136,6 +137,14 @@ function lightsquid_resync() { if (!file_exists("/usr/bin/perl")) mwexec("ln -s /usr/local/bin/perl /usr/bin/perl"); + // create lightsquid report catalog + if (!file_exists(LS_REPORTPATH)) { + update_log("lightsquid_install: Create report dir " . LS_REPORTPATH); + mwexec("mkdir -p " . LS_REPORTPATH); + } + + mwexec("/bin/chmod -R u+w /usr/local/etc/lightsquid"); + // debug $light_test = array(); if (($_POST['Submit'] === 'Save') or !isset($_POST['Submit'])) { @@ -374,6 +383,11 @@ function update_log($log) { function refresh_now() { $cmd = CRONTAB_LS_TEMPLATE . " today"; update_log("refresh_now: execute command '$cmd'"); + // create lightsquid report catalog + if (!file_exists(LS_REPORTPATH)) { + update_log("lightsquid_install: Create report dir " . LS_REPORTPATH); + mwexec("mkdir -p " . LS_REPORTPATH); + } mwexec_bg($cmd); } @@ -382,9 +396,15 @@ function refresh_full() { $log_name = LS_SQUIDLOG; update_log("refresh_full: start"); + // create lightsquid report catalog + if (!file_exists(LS_REPORTPATH)) { + update_log("lightsquid_install: Create report dir " . LS_REPORTPATH); + mwexec("mkdir -p " . LS_REPORTPATH); + } + // parse access.log update_log("refresh_full: execute command '$cmd'"); - mwexec_bg("$cmd $lg"); + mwexec_bg("$cmd $log_name"); // parse access.log.x for ($i=0; $i<100; $i++) { $lg = LS_SQUIDLOG . ".$i"; diff --git a/config/ntop2/ntop.xml b/config/ntop2/ntop.xml index 8ff4d8a1..6cd71d60 100644 --- a/config/ntop2/ntop.xml +++ b/config/ntop2/ntop.xml @@ -123,35 +123,32 @@ system("/bin/chmod -R 755 /var/db/ntop"); system("/usr/sbin/chown -R nobody:nobody /var/db/ntop"); system("/bin/cp -Rp /usr/local/lib/X11/fonts/webfonts/ /usr/local/lib/X11/fonts/TTF/"); - if($ntop_config['password'] and $ntop_config['passwordagain']) { - if($ntop_config['password'] == $ntop_config['passwordagain']) { - $first = 0; - $mergeifs = ($ntop_config['allowmerge'] == "on") ? "" : "-M"; - $alltraffic = ($ntop_config['alltraffic'] == "on") ? "" : "--ipv4"; - foreach($ntop_config['interface_array'] as $iface) { - $if = convert_friendly_interface_to_real_interface_name($iface); - if($if) { - if($first == 1) - $ifaces_final .= ","; - $ifaces_final .= $if; - $first = 1; - } - } - exec("/usr/local/bin/ntop --set-admin-password=" . $ntop_config['password'] . " &", $ntopout); - $start = "/usr/local/bin/ntop -i {$ifaces_final} -u root -d {$alltraffic} {$mergeifs} -x 8102 -X 8192 &"; - write_rcfile(array( - "file" => "ntop.sh", - "start" => $start, - "stop" => "/usr/bin/killall ntop" - ) - ); - restart_service("ntop"); - } else { - $input_errors[] = "The provided passwords did not match."; - } - } else { - $input_errors[] = "You must provide (and confirm) ntop's password."; + $first = 0; + $mergeifs = ($ntop_config['allowmerge'] == "on") ? "" : "-M"; + $alltraffic = ($ntop_config['alltraffic'] == "on") ? "" : "--ipv4"; + foreach($ntop_config['interface_array'] as $iface) { + $if = convert_friendly_interface_to_real_interface_name($iface); + if($if) { + if($first == 1) + $ifaces_final .= ","; + $ifaces_final .= $if; + $first = 1; + } } + $start = "/usr/local/bin/ntop -i {$ifaces_final} -u root -d {$alltraffic} {$mergeifs} -x 8102 -X 8192 &"; + write_rcfile(array( + "file" => "ntop.sh", + "start" => $start, + "stop" => "/usr/bin/killall ntop" + ) + ); + stop_service("ntop"); + if (empty($ntop_config['password'])) + $ntop_config['password'] = "admin"; + sleep(5); + unlink_if_exists("/var/db/ntop/ntop_pw.db"); + exec("/usr/local/bin/ntop --set-admin-password={$ntop_config['password']}); + start_service("ntop"); conf_mount_ro(); config_unlock(); } @@ -169,4 +166,14 @@ <custom_php_deinstall_command> exec("rm /usr/local/etc/rc.d/ntop*"); </custom_php_deinstall_command> + <custom_php_validation_command> + <![CDATA[ + if ($_POST) { + 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."; + } + ]]> + </custom_php_validation_command> </packagegui>
\ No newline at end of file |