--- a/usr/local/pkg/ntopng.inc +++ b/usr/local/pkg/ntopng.inc @@ -43,7 +43,7 @@ $ntopng_config = $config['installedpackages']['ntopng']['config'][0]; if ($ntopng_config['keepdata'] != "on") { if (is_dir("/var/db/ntopng/")) { - mwexec("rm -rf /var/db/ntopng/"); + exec("rm -rf /var/db/ntopng/"); } if (is_array($config['installedpackages']['ntopng'])) { unset($config['installedpackages']['ntopng']); @@ -200,7 +200,7 @@ $redis_started = false; if (!is_process_running("redis-server")) { - mwexec_bg("{$redis_path}/redis-server --bind 127.0.0.1 ::1 --dir /var/db/ntopng/ --dbfilename ntopng.rdb"); + exec_bg("{$redis_path}/redis-server --bind 127.0.0.1 ::1 --dir /var/db/ntopng/ --dbfilename ntopng.rdb"); for ($i = 0; $i <= 10; $i++) { if (is_process_running("redis-server")) { $redis_started = true; @@ -222,10 +222,10 @@ if (!empty($ntopng_config['redis_password'])) { $password = md5($ntopng_config['redis_password']); if (ntopng_redis_started()) { - mwexec("{$redis_path}/redis-cli SET ntopng.user.admin.password " . escapeshellarg($password)); + exec("{$redis_path}/redis-cli SET ntopng.user.admin.password " . escapeshellarg($password)); // Make sure the preferences menu is accessible (Bug #6999) - mwexec("{$redis_path}/redis-cli SET ntopng.user.admin.group administrator"); - mwexec("{$redis_path}/redis-cli save"); + exec("{$redis_path}/redis-cli SET ntopng.user.admin.group administrator"); + exec("{$redis_path}/redis-cli save"); } else { log_error(gettext("[ntopng] Cannot set admin password - redis-server is not running.")); } @@ -234,23 +234,19 @@ 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"); + exec("/bin/chmod -R 755 /var/db/ntopng"); + exec("/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"; + $geolite_city = "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz"; + $geoip_asnum = "https://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN.tar.gz"; $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}"); + + exec("{$fetchcmd} -o {$output_dir} -T 5 {$geolite_city}"); + exec("{$fetchcmd} -o {$output_dir} -T 5 {$geoip_asnum}"); ntopng_fixup_geoip(); @@ -271,16 +267,15 @@ safe_mkdir($target_dir, 0755); - foreach(glob("{$source_dir}/Geo*.dat*") as $geofile) { + foreach(glob("{$source_dir}/Geo*.tar.gz") 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)); + if (substr($geofile, -7, 7) == ".tar.gz") { + exec("tar -C {$source_dir} -f {$geofile} --strip 1 -xz '*.mmdb'"); } } /* Use a separate glob since the filenames could have changed since the last run */ - foreach(glob("{$source_dir}/Geo*.dat*") as $geofile) { + foreach(glob("{$source_dir}/Geo*.mmdb") as $geofile) { $target_file = $target_dir . '/' . basename($geofile); if (!file_exists($target_file)) { symlink($geofile, $target_file); @@ -295,7 +290,7 @@ if (ntopng_redis_started()) { /* Delete all the keys of all the existing Redis databases */ - mwexec("{$redis_path}/redis-cli flushall"); + exec("{$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(); @@ -303,7 +298,7 @@ /* 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/"); + exec("rm -rf /var/db/ntopng/"); log_error(gettext("[ntopng] Deleted ntopng traffic data and graphs.")); } else { log_error(gettext("[ntopng] Nothing to delete; /var/db/ntopng/ directory not found."));