)
+ {
+ if($line =~ /Station (\S+) \(on $iface\)/)
+ {
+ if ( $lastseen < 10000 ) { pushAP($signal, $mychan, $key, $myssid, $host, $mac, $mode) }
+
+ $lastseen = 0;
+ $mac = $1;
+ $ip = `grep $mac /proc/net/arp | egrep "^10.*\$" | tail -1`;
+ $mac = uc $mac;
+ if ( $ip ne "" )
+ {
+ $ip =~ s/[ \t].*$// ;
+ chomp($ip);
+ $host = $ip;
+ if( $ip ne "")
+ {
+ $reverse_ip=join ".",reverse(split /\./,$ip);
+ foreach(`nslookup $ip`)
+ {
+ last if ($host) = /^$reverse_ip\.in-addr\.arpa[ \t]+name[ \t]+=[ \t]+(\S+)\.local\.mesh/;
+ }
+ if ( $host eq "" ) { $host = $ip }
+ }
+ }
+ else { $host = "????" }
+ }
+
+ if($line =~ /signal avg:[ \t]+([-\d]+)/) { $signal = $1 }
+ if($line =~ /inactive time:\t(\d+) ms/) { $lastseen = $1 }
+ }
+
+ close(FILE);
+ if ( $lastseen < 10000 ) { pushAP($signal, $mychan, $key, $myssid, $host, $mac, $mode) }
+
+ sleep 1 if not scalar @list and $loops != 1;
+
+ if(not $batch)
+ {
+ if($avg)
+ {
+ system "clear";
+ printf "Sig Rel Ch E SSID Hostname MAC/BSSID 802.11 Mode %6d\n", $iters;
+ print "--- --- -- - -------------------------------- ----------------- ------------- -----------\n";
+ }
+ elsif($web)
+ {
+ print "\n";
+ print "Sig | Chan | Enc | SSID | Hostname | MAC/BSSID | 802.11 Mode |
\n";
+ }
+ else
+ {
+ #system "clear";
+ printf "Sig Ch E SSID Hostname MAC/BSSID 802.11 Mode %6d\n", $iters;
+ print "--- -- - -------------------------------- --------------------- ------------- ------------\n";
+ }
+ }
+
+ if($avg)
+ {
+ open(FILE, "| sort -nr");
+ foreach $mac (keys %aphash)
+ {
+ printf FILE "%3d %3d %s",
+ ($avgs{"$mac total"} - $avgs{"$mac num"} + 1)/$avgs{"$mac num"},
+ 100*$avgs{"$mac num"}/$iters,
+ $aphash{$mac};
+ }
+ close(FILE);
+ print "\n";
+ }
+ elsif($web)
+ {
+ foreach $line (sort { $b <=> $a } @list)
+ {
+
+ # Match "AREDN"
+ if ( $line =~ /AREDN/) { print ""}
+ else { print "
"}
+
+ my $i = 0;
+ foreach $val (split /\|/, $line)
+ {
+ $val = " " unless $val =~ /\S/;
+ if($i++ == 3) { print "$val | " }
+ else { print "$val | " }
+ }
+ print " | " if $i < 7;
+ print "
\n";
+ }
+ print "
\n";
+ exit;
+ }
+ else
+ {
+ open(FILE, "| sort -nr");
+ print FILE @list;
+ close(FILE);
+ print "\n";
+ }
+
+ last if --$loops == 0;
+}
diff --git a/files/www/cgi-bin/fwinfo b/files/www/cgi-bin/fwinfo
index 28a4f039..d60e275f 100755
--- a/files/www/cgi-bin/fwinfo
+++ b/files/www/cgi-bin/fwinfo
@@ -1,49 +1,53 @@
-#!/usr/bin/perl
-=for comment
+#!/usr/bin/lua
+--[[
- Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
- Copyright (C) 2015 Conrad Lara
- See Contributors file for additional contributors
+ Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
+ Copyright (C) 2021 Tim Wilkinson
+ Original Perl Copyright (C) 2015 Conrad Lara
+ See Contributors file for additional contributors
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation version 3 of the License.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation version 3 of the License.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
- Additional Terms:
+ Additional Terms:
- Additional use restrictions exist on the AREDN(TM) trademark and logo.
- See AREDNLicense.txt for more info.
+ Additional use restrictions exist on the AREDN(TM) trademark and logo.
+ See AREDNLicense.txt for more info.
- Attributions to the AREDN Project must be retained in the source code.
- If importing this code into a new or existing project attribution
- to the AREDN project must be added to the source code.
+ Attributions to the AREDN Project must be retained in the source code.
+ If importing this code into a new or existing project attribution
+ to the AREDN project must be added to the source code.
- You must not misrepresent the origin of the material contained within.
+ You must not misrepresent the origin of the material contained within.
- Modified versions must be modified to attribute to the original source
- and be marked in reasonable ways as differentiate it from the original
- version.
+ Modified versions must be modified to attribute to the original source
+ and be marked in reasonable ways as differentiate it from the original
+ version
-=cut
+--]]
-print "Content-type:text\r\n\r\n";
+require("aredn.utils")
-$ispermitencblock = `opkg list-installed blockknownencryption|wc -l`;
-chomp($ispermitencblock);
+print("Content-type:text\r")
+print("\r")
-if ($ispermitencblock){
- print "Encrypted Traffic: Blocked\n";
-} else {
- print "Encrypted Traffic: Allowed\n";
-}
+local ispermitencblock = capture("opkg list-installed blockknownencryption|wc -l"):chomp()
+
+if ispermitencblock ~= "0" then
+ print("Encrypted Traffic: Blocked")
+else
+ print("Encrypted Traffic: Allowed")
+end
+
+print("Active firewall rules:")
+print(capture("/usr/sbin/iptables -L"))
-print "Active firewall rules:\n";
-system ("/usr/sbin/iptables -L");
diff --git a/files/www/cgi-bin/fwinfo.pl b/files/www/cgi-bin/fwinfo.pl
new file mode 100755
index 00000000..28a4f039
--- /dev/null
+++ b/files/www/cgi-bin/fwinfo.pl
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+=for comment
+
+ Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
+ Copyright (C) 2015 Conrad Lara
+ See Contributors file for additional contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation version 3 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+ Additional Terms:
+
+ Additional use restrictions exist on the AREDN(TM) trademark and logo.
+ See AREDNLicense.txt for more info.
+
+ Attributions to the AREDN Project must be retained in the source code.
+ If importing this code into a new or existing project attribution
+ to the AREDN project must be added to the source code.
+
+ You must not misrepresent the origin of the material contained within.
+
+ Modified versions must be modified to attribute to the original source
+ and be marked in reasonable ways as differentiate it from the original
+ version.
+
+=cut
+
+print "Content-type:text\r\n\r\n";
+
+$ispermitencblock = `opkg list-installed blockknownencryption|wc -l`;
+chomp($ispermitencblock);
+
+if ($ispermitencblock){
+ print "Encrypted Traffic: Blocked\n";
+} else {
+ print "Encrypted Traffic: Allowed\n";
+}
+
+print "Active firewall rules:\n";
+system ("/usr/sbin/iptables -L");
diff --git a/files/www/cgi-bin/supporttool b/files/www/cgi-bin/supporttool
index ab75c1b6..efce8a9e 100755
--- a/files/www/cgi-bin/supporttool
+++ b/files/www/cgi-bin/supporttool
@@ -1,206 +1,192 @@
-#!/usr/bin/perl
-=for comment
+#!/usr/bin/lua
+--[[
- Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
- Copyright (C) 2015 Conrad Lara
- See Contributors file for additional contributors
+ Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
+ Copyright (C) 2021 Tim Wilkinson
+ Original Perl Copyright (C) 2015 Conrad Lara
+ See Contributors file for additional contributors
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation version 3 of the License.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation version 3 of the License.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
- Additional Terms:
+ Additional Terms:
- Additional use restrictions exist on the AREDN(TM) trademark and logo.
- See AREDNLicense.txt for more info.
+ Additional use restrictions exist on the AREDN(TM) trademark and logo.
+ See AREDNLicense.txt for more info.
- Attributions to the AREDN Project must be retained in the source code.
- If importing this code into a new or existing project attribution
- to the AREDN project must be added to the source code.
+ Attributions to the AREDN Project must be retained in the source code.
+ If importing this code into a new or existing project attribution
+ to the AREDN project must be added to the source code.
- You must not misrepresent the origin of the material contained within.
+ You must not misrepresent the origin of the material contained within.
- Modified versions must be modified to attribute to the original source
- and be marked in reasonable ways as differentiate it from the original
- version.
+ Modified versions must be modified to attribute to the original source
+ and be marked in reasonable ways as differentiate it from the original
+ version
-=cut
+--]]
-BEGIN {push @INC, '/www/cgi-bin'};
-use perlfunc;
-chomp (${wifiif}=`uci -q get 'network.wifi.ifname'`);
-$phy=get_wlan2phy("${wifiif}");
+require("nixio")
+require("aredn.utils")
+require("uci")
+require("iwinfo")
-@files = ( "/etc/config/",
- "/etc/config.mesh/",
- "/etc/local/",
- "/etc/mesh-release",
- "/tmp/etc/",
- "/var/run/hosts_olsr",
- "/tmp/rssi.dat",
- "/tmp/rssi.log",
- "/tmp/zombie.log",
- "/tmp/olsrd.log",
- "/tmp/manager.log",
- "/tmp/manager.log.0",
- "/tmp/AutoDistReset.log",
- "/sys/kernel/debug/ieee80211/phy0/ath9k/ack_to",
- "/sys/kernel/debug/ieee80211/phy1/ath9k/ack_to",
- "/etc/board.json"
- );
-
-@sensitive = ( "/etc/config/vtun",
- "/etc/config.mesh/vtun",
- "/etc/httpd.conf",
- );
+local wifiif = uci.cursor():get("network", "wifi", "ifname")
+local phy = iwinfo.nl80211.phyname(wifiif)
+local mfg = capture("/usr/local/bin/get_hardware_mfg"):chomp()
-
-@cmds = ( "cat /proc/cpuinfo",
- "cat /proc/meminfo",
- "df -k",
- "dmesg",
- "ifconfig",
- "iptables -t filter -L -v",
- "iptables -t nat -L -v",
- "iptables -t mangle -L -v",
- "ip route list",
- "ip route list table 29",
- "ip route list table 30",
- "ip route list table 31",
- "ip route list table main",
- "ip route list table default",
- "ip rule list",
- "iwinfo",
- "iwinfo ${wifiif} assoclist",
- "iw phy ${phy} info",
- "iw dev ${wifiif} info",
- "iw dev ${wifiif} scan",
- "iw dev ${wifiif} station dump",
- "logread",
- "md5sum /www/cgi-bin/*",
- "echo /all | nc 127.0.0.1 2006",
- "opkg list-installed",
- "ps -w",
- "/usr/local/bin/get_hardwaretype",
- "/usr/local/bin/get_boardid",
- "/usr/local/bin/get_model",
- "/usr/local/bin/get_hardware_mfg",
- );
-
-@cmds_ubnt = (
- "cat /dev/mtd0|grep 'U-Boot'|head -n1",
- );
-
-$FREE_SPACE_TMP=get_free_space("/tmp");
-
-$mfg = `/usr/local/bin/get_hardware_mfg`;
-chomp($mfg);
-
-if ($FREE_SPACE_TMP eq "N/A" || $FREE_SPACE_TMP <= 2*1024) {
- exit 1;
+local files = {
+ "/etc/config/",
+ "/etc/config.mesh/",
+ "/etc/local/",
+ "/etc/mesh-release",
+ "/tmp/etc/",
+ "/var/run/hosts_olsr",
+ "/tmp/rssi.dat",
+ "/tmp/rssi.log",
+ "/tmp/zombie.log",
+ "/tmp/olsrd.log",
+ "/tmp/manager.log",
+ "/tmp/manager.log.0",
+ "/tmp/AutoDistReset.log",
+ "/sys/kernel/debug/ieee80211/phy0/ath9k/ack_to",
+ "/sys/kernel/debug/ieee80211/phy1/ath9k/ack_to",
+ "/etc/board.json"
+}
+local sensitive = {
+ "/etc/config/vtun",
+ "/etc/config.mesh/vtun",
+ "/etc/httpd.conf"
+}
+local cmds = {
+ "cat /proc/cpuinfo",
+ "cat /proc/meminfo",
+ "df -k",
+ "dmesg",
+ "ifconfig",
+ "iptables -t filter -L -v",
+ "iptables -t nat -L -v",
+ "iptables -t mangle -L -v",
+ "ip route list",
+ "ip route list table 29",
+ "ip route list table 30",
+ "ip route list table 31",
+ "ip route list table main",
+ "ip route list table default",
+ "ip rule list",
+ "iwinfo",
+ "iwinfo " .. wifiif .. " assoclist",
+ "iw phy " .. phy .. " info",
+ "iw dev " .. wifiif .. " info",
+ "iw dev " .. wifiif .. " scan",
+ "iw dev " .. wifiif .. " station dump",
+ "logread",
+ "md5sum /www/cgi-bin/*",
+ "echo /all | nc 127.0.0.1 2006",
+ "opkg list-installed",
+ "ps -w",
+ "/usr/local/bin/get_hardwaretype",
+ "/usr/local/bin/get_boardid",
+ "/usr/local/bin/get_model",
+ "/usr/local/bin/get_hardware_mfg",
+}
+local cmds_ubnt = {
+ "cat /dev/mtd0|grep 'U-Boot'|head -n1"
}
-system ("rm", "-r", "-f", "/tmp/sd");
+-- need space for this
+local vfs = nixio.fs.statvfs("/tmp")
+local fspace = vfs.bfree * vfs.bsize / 1024
+if fspace < 2048 then
+ os.exit(1)
+end
-foreach $path (@files) {
+remove_all("/tmp/sd")
- next if (! -e $path and ! -d $path);
+for _, path in ipairs(files)
+do
+ if nixio.fs.stat(path) then
+ local m = path:match("^/(.*/).*/$")
+ if m then
+ os.execute("mkdir -p /tmp/sd/" .. m);
+ os.execute("cp -r -p " .. path .. " /tmp/sd/" .. m)
+ else
+ m = path:match("^/(.*/).*")
+ os.execute("mkdir -p /tmp/sd/" .. m);
+ os.execute("cp -r -p " .. path .. " /tmp/sd/" .. m)
+ end
+ end
+end
- if ( $path =~ /^\/(.*\/).*\/$/ ) {
- my $rpath = $1;
- system("mkdir", "-p", "/tmp/sd/$rpath");
- system("cp","-r","-p","$path","/tmp/sd/$rpath");
- } else {
- $path =~ /^(.*\/).*/;
- my $sourcepath = $1;
- system("mkdir", "-p", "/tmp/sd/$sourcepath");
- system("cp","-r","-p","$path","/tmp/sd/$path");
- }
+-- remove sensitive files
+for _, path in ipairs(sensitive)
+do
+ local m = path:match("^/(.*)")
+ if m then
+ remove_all("/tmp/sd/" .. m)
+ end
+end
-}
+-- remove passwords from config file
+os.execute("sed -i -e 's/ key.*$/ key ******/' /tmp/sd/etc/config/wireless")
+os.execute("sed -i -e 's/_key =.*$/_key =/' /tmp/sd/etc/config.mesh/_setup")
-#Remove sensitive files
-foreach $path (@sensitive) {
- if ( $path =~ /^\/(.*)/ ) {
- my $sourcepath = $1;
- system("rm", "-r", "-f", "/tmp/sd/$sourcepath");
- }
-}
+local f = io.open("/tmp/sd/data.txt", "w")
+if f then
+ for _, cmd in ipairs(cmds)
+ do
+ local p = io.popen(cmd)
+ if p then
+ f:write("========== " .. cmd .. " ==========\n")
+ f:write(p:read("*a"))
+ p:close()
+ end
+ end
-#Remove passwords from config files
-system ("cat /tmp/sd/etc/config/wireless | sed -e 's/ key.*\$/ key \*\*\*\*\*\*/' > /tmp/sd/etc/config/wireless.sav");
-unlink "rm /tmp/sd/etc/config/wireless";
-rename "/tmp/sd/etc/config/wireless.sav", "/tmp/sd/etc/config/wireless";
-system ("cat /tmp/sd/etc/config.mesh/_setup | sed -e 's/_key =.*\$/_key =/' > /tmp/sd/etc/config.mesh/_setup.sav");
-unlink "/tmp/sd/etc/config.mesh/_setup";
-rename "/tmp/sd/etc/config.mesh/_setup.sav", "/tmp/sd/etc/config.mesh/_setup";
+ if mfg == "Ubiquiti" then
+ for _, cmd in ipairs(cmds_ubnt)
+ do
+ local p = io.popen(cmd)
+ if p then
+ f:write("========== " .. cmd .. " (UBNT only) ==========\n")
+ f:write(p:read("*a"))
+ p:close()
+ end
+ end
+ end
+ f:close()
+end
-system("touch","/tmp/sd/data.txt");
-open (my $CMDS_OUT, '>', '/tmp/sd/data.txt') or die "Could not open dump file";
-foreach $cmd (@cmds) {
- print $CMDS_OUT "========== $cmd ==========\n";
- open(my $CMD_PIPE, "-|", $cmd ) or next;
- while (<$CMD_PIPE>) {
- print { $CMDS_OUT } $_;
- }
-}
+os.execute("tar -zcf /tmp/supportdata.tgz -C /tmp/sd ./")
+-- cleaup the temp files
+remove_all("/tmp/sd")
-if ( $mfg eq "Ubiquiti" ) {
- foreach $cmd (@cmds_ubnt) {
- print $CMDS_OUT "========== $cmd (UBNT only) ==========\n";
- open(my $CMD_PIPE, "-|", $cmd ) or next;
- while (<$CMD_PIPE>) {
- print { $CMDS_OUT } $_;
- }
- }
-}
+local nodename = capture("uname -n"):chomp()
+local tstamp = capture("date +%Y%m%d%H%M"):chomp()
-close ($CMDS_OUT);
-
-system("tar", "-zcf", "/tmp/supportdata.tgz", "-C", "/tmp/sd", "./");
-
-# Cleanup the temp files
-system ("rm", "-r", "-f", "/tmp/sd");
-
-$nodename=`uname -n`;
-chomp($nodename);
-$tstamp=`date +%Y%m%d%H%M`;
-chomp($tstamp);
-
-open(my $SDFH, '<', "/tmp/supportdata.tgz") or exit(1);
-binmode $SDFH;
-
-if (exists $ENV{GATEWAY_INTERFACE}) {
- print "Content-type: application/x-gzip\r\n";
- print "Content-Disposition: attachment; filename=supportdata-$nodename-$tstamp.tgz\r\n";
- print "\r\n";
-
- print while <$SDFH>;
- undef ($SDFH);
-
- unlink("/tmp/supportdata.tgz");
-
-} else {
- undef ($SDFH);
- unlink ("/tmp/supportdata-$nodename-$tstamp.tgz"); # Shouldn't exist but lets be sure
- system ("mv", "/tmp/supportdata.tgz", "/tmp/supportdata-$nodename-$tstamp.tgz");
- if ($? != 0) {
- print "Failed to rename the support data file.\n It may be present at /tmp/supportdata.tgz\n";
- exit(1);
- } else {
- print "File created: /tmp/supportdata-$nodename-$tstamp.tgz\n";
- print "Please copy this file and remove from the node\n";
- print "to free up resources.\n"
- }
-}
+if os.getenv("GATEWAY_INTERFACE") ~= "" then
+ local fn = "supportdata-" .. nodename .. "-" .. tstamp .. ".tgz"
+ print("Content-type: application/x-gzip\r")
+ print("Content-Disposition: attachment; filename=" .. fn .. "\r")
+ print("\r")
+ io.write(read_all("/tmp/supportdata.tgz"))
+else
+ local fn = "/tmp/supportdata-" .. nodename .. "-" .. tstamp .. ".tgz"
+ nixio.fs.remove(fn)
+ nixio.fs.rename("/tmp/supportdata.tgz", fn)
+ print("File created: " .. fn)
+ print("Please copy this file and remove from the node")
+ print("to free up resources.")
+end
diff --git a/files/www/cgi-bin/supporttool.pl b/files/www/cgi-bin/supporttool.pl
new file mode 100755
index 00000000..ab75c1b6
--- /dev/null
+++ b/files/www/cgi-bin/supporttool.pl
@@ -0,0 +1,206 @@
+#!/usr/bin/perl
+=for comment
+
+ Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
+ Copyright (C) 2015 Conrad Lara
+ See Contributors file for additional contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation version 3 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+ Additional Terms:
+
+ Additional use restrictions exist on the AREDN(TM) trademark and logo.
+ See AREDNLicense.txt for more info.
+
+ Attributions to the AREDN Project must be retained in the source code.
+ If importing this code into a new or existing project attribution
+ to the AREDN project must be added to the source code.
+
+ You must not misrepresent the origin of the material contained within.
+
+ Modified versions must be modified to attribute to the original source
+ and be marked in reasonable ways as differentiate it from the original
+ version.
+
+=cut
+
+BEGIN {push @INC, '/www/cgi-bin'};
+use perlfunc;
+chomp (${wifiif}=`uci -q get 'network.wifi.ifname'`);
+$phy=get_wlan2phy("${wifiif}");
+
+
+@files = ( "/etc/config/",
+ "/etc/config.mesh/",
+ "/etc/local/",
+ "/etc/mesh-release",
+ "/tmp/etc/",
+ "/var/run/hosts_olsr",
+ "/tmp/rssi.dat",
+ "/tmp/rssi.log",
+ "/tmp/zombie.log",
+ "/tmp/olsrd.log",
+ "/tmp/manager.log",
+ "/tmp/manager.log.0",
+ "/tmp/AutoDistReset.log",
+ "/sys/kernel/debug/ieee80211/phy0/ath9k/ack_to",
+ "/sys/kernel/debug/ieee80211/phy1/ath9k/ack_to",
+ "/etc/board.json"
+ );
+
+@sensitive = ( "/etc/config/vtun",
+ "/etc/config.mesh/vtun",
+ "/etc/httpd.conf",
+ );
+
+
+
+@cmds = ( "cat /proc/cpuinfo",
+ "cat /proc/meminfo",
+ "df -k",
+ "dmesg",
+ "ifconfig",
+ "iptables -t filter -L -v",
+ "iptables -t nat -L -v",
+ "iptables -t mangle -L -v",
+ "ip route list",
+ "ip route list table 29",
+ "ip route list table 30",
+ "ip route list table 31",
+ "ip route list table main",
+ "ip route list table default",
+ "ip rule list",
+ "iwinfo",
+ "iwinfo ${wifiif} assoclist",
+ "iw phy ${phy} info",
+ "iw dev ${wifiif} info",
+ "iw dev ${wifiif} scan",
+ "iw dev ${wifiif} station dump",
+ "logread",
+ "md5sum /www/cgi-bin/*",
+ "echo /all | nc 127.0.0.1 2006",
+ "opkg list-installed",
+ "ps -w",
+ "/usr/local/bin/get_hardwaretype",
+ "/usr/local/bin/get_boardid",
+ "/usr/local/bin/get_model",
+ "/usr/local/bin/get_hardware_mfg",
+ );
+
+@cmds_ubnt = (
+ "cat /dev/mtd0|grep 'U-Boot'|head -n1",
+ );
+
+$FREE_SPACE_TMP=get_free_space("/tmp");
+
+$mfg = `/usr/local/bin/get_hardware_mfg`;
+chomp($mfg);
+
+if ($FREE_SPACE_TMP eq "N/A" || $FREE_SPACE_TMP <= 2*1024) {
+ exit 1;
+}
+
+system ("rm", "-r", "-f", "/tmp/sd");
+
+foreach $path (@files) {
+
+ next if (! -e $path and ! -d $path);
+
+ if ( $path =~ /^\/(.*\/).*\/$/ ) {
+ my $rpath = $1;
+ system("mkdir", "-p", "/tmp/sd/$rpath");
+ system("cp","-r","-p","$path","/tmp/sd/$rpath");
+ } else {
+ $path =~ /^(.*\/).*/;
+ my $sourcepath = $1;
+ system("mkdir", "-p", "/tmp/sd/$sourcepath");
+ system("cp","-r","-p","$path","/tmp/sd/$path");
+ }
+
+}
+
+#Remove sensitive files
+foreach $path (@sensitive) {
+ if ( $path =~ /^\/(.*)/ ) {
+ my $sourcepath = $1;
+ system("rm", "-r", "-f", "/tmp/sd/$sourcepath");
+ }
+}
+
+#Remove passwords from config files
+system ("cat /tmp/sd/etc/config/wireless | sed -e 's/ key.*\$/ key \*\*\*\*\*\*/' > /tmp/sd/etc/config/wireless.sav");
+unlink "rm /tmp/sd/etc/config/wireless";
+rename "/tmp/sd/etc/config/wireless.sav", "/tmp/sd/etc/config/wireless";
+system ("cat /tmp/sd/etc/config.mesh/_setup | sed -e 's/_key =.*\$/_key =/' > /tmp/sd/etc/config.mesh/_setup.sav");
+unlink "/tmp/sd/etc/config.mesh/_setup";
+rename "/tmp/sd/etc/config.mesh/_setup.sav", "/tmp/sd/etc/config.mesh/_setup";
+
+
+system("touch","/tmp/sd/data.txt");
+open (my $CMDS_OUT, '>', '/tmp/sd/data.txt') or die "Could not open dump file";
+foreach $cmd (@cmds) {
+ print $CMDS_OUT "========== $cmd ==========\n";
+ open(my $CMD_PIPE, "-|", $cmd ) or next;
+ while (<$CMD_PIPE>) {
+ print { $CMDS_OUT } $_;
+ }
+}
+
+if ( $mfg eq "Ubiquiti" ) {
+ foreach $cmd (@cmds_ubnt) {
+ print $CMDS_OUT "========== $cmd (UBNT only) ==========\n";
+ open(my $CMD_PIPE, "-|", $cmd ) or next;
+ while (<$CMD_PIPE>) {
+ print { $CMDS_OUT } $_;
+ }
+ }
+}
+
+close ($CMDS_OUT);
+
+system("tar", "-zcf", "/tmp/supportdata.tgz", "-C", "/tmp/sd", "./");
+
+# Cleanup the temp files
+system ("rm", "-r", "-f", "/tmp/sd");
+
+$nodename=`uname -n`;
+chomp($nodename);
+$tstamp=`date +%Y%m%d%H%M`;
+chomp($tstamp);
+
+open(my $SDFH, '<', "/tmp/supportdata.tgz") or exit(1);
+binmode $SDFH;
+
+if (exists $ENV{GATEWAY_INTERFACE}) {
+ print "Content-type: application/x-gzip\r\n";
+ print "Content-Disposition: attachment; filename=supportdata-$nodename-$tstamp.tgz\r\n";
+ print "\r\n";
+
+ print while <$SDFH>;
+ undef ($SDFH);
+
+ unlink("/tmp/supportdata.tgz");
+
+} else {
+ undef ($SDFH);
+ unlink ("/tmp/supportdata-$nodename-$tstamp.tgz"); # Shouldn't exist but lets be sure
+ system ("mv", "/tmp/supportdata.tgz", "/tmp/supportdata-$nodename-$tstamp.tgz");
+ if ($? != 0) {
+ print "Failed to rename the support data file.\n It may be present at /tmp/supportdata.tgz\n";
+ exit(1);
+ } else {
+ print "File created: /tmp/supportdata-$nodename-$tstamp.tgz\n";
+ print "Please copy this file and remove from the node\n";
+ print "to free up resources.\n"
+ }
+}
diff --git a/files/www/cgi-bin/sysinfo b/files/www/cgi-bin/sysinfo
index cd0ffcd2..a20fbfbf 100755
--- a/files/www/cgi-bin/sysinfo
+++ b/files/www/cgi-bin/sysinfo
@@ -1,77 +1,89 @@
-#!/usr/bin/perl
-=for comment
+#!/usr/bin/lua
+--[[
- Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
- Copyright (C) 2015 Conrad Lara
- See Contributors file for additional contributors
+ Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
+ Copyright (C) 2021 Tim Wilkinson
+ Original Perl Copyright (C) 2015 Conrad Lara
+ Original Perl Copyright (c) 2013 David Rivenburg et al. BroadBand-HamNet
+ See Contributors file for additional contributors
- Copyright (c) 2013 David Rivenburg et al. BroadBand-HamNet
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation version 3 of the License.
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation version 3 of the License.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ Additional Terms:
- Additional Terms:
+ Additional use restrictions exist on the AREDN(TM) trademark and logo.
+ See AREDNLicense.txt for more info.
- Additional use restrictions exist on the AREDN(TM) trademark and logo.
- See AREDNLicense.txt for more info.
+ Attributions to the AREDN Project must be retained in the source code.
+ If importing this code into a new or existing project attribution
+ to the AREDN project must be added to the source code.
- Attributions to the AREDN Project must be retained in the source code.
- If importing this code into a new or existing project attribution
- to the AREDN project must be added to the source code.
+ You must not misrepresent the origin of the material contained within.
- You must not misrepresent the origin of the material contained within.
+ Modified versions must be modified to attribute to the original source
+ and be marked in reasonable ways as differentiate it from the original
+ version
- Modified versions must be modified to attribute to the original source
- and be marked in reasonable ways as differentiate it from the original
- version.
+--]]
-=cut
+require("aredn.http")
+require("aredn.hardware")
+local html = require("aredn.html")
+aredn.info = require("aredn.info")
-BEGIN {push @INC, '/www/cgi-bin'};
-use perlfunc;
+local node = aredn.info.get_nvram("node")
+if not node then
+ node = "NOCALL"
+end
-http_header();
-html_header("$node system information", 1);
-print "\n";
+http_header()
+html.header(node .. " system information", false)
+html.print("")
+html.print(" node: " .. node)
+html.print("model: " .. aredn.hardware.get_board_id())
+html.print("")
-print " node: ", nvram_get("node"), "\n";
-print "model: ", `/usr/local/bin/get_model`, "\n";
+if aredn.hardware.supported() ~= 1 then
+ html.print("!!!! UNSUPPORTED DEVICE !!!!")
+ html.print("boardid: " .. aredn.hardware.get_board_id())
+ if aredn.hardware.supported() == 0 then
+ html.print("Device HAS BEEN TESTED AS UNSUPPORTED")
+ else
+ html.print("Device has not been tested. Please file a ticket with your experiences.")
+ end
+ html.print("")
+end
-if ( is_hardware_supported() !=1 ){
- print "!!!! UNSUPPORTED DEVICE !!!!\n";
- print "boardid: " , hardware_boardid() , "\n";
- if ( is_hardware_supported == 0 ) {
- print "Device HAS BEEN TESTED AS UNSUPPORTED\n";
- }
- else {
- print "Device has not been tested. Please file a ticket with your experiences.\n";
- }
- print "\n";
-}
+local f = io.popen("ifconfig -a")
+if f then
+ for line in f:lines()
+ do
+ local a, b = line:match("^(%S+) .*HWaddr (%S+)")
+ if b then
+ html.print(string.format("%-6s %s", a, b))
+ end
+ end
+ f:close()
+end
-foreach(`ifconfig -a`)
-{
- next unless /^(\S+) .*HWaddr (\S+)/;
- printf "%-6s %s\n", $1, $2;
-}
+html.print("")
+html.print("/proc/cpuinfo")
+html.print(read_all("/proc/cpuinfo"))
-print "\n/proc/cpuinfo\n";
-system "cat /proc/cpuinfo";
+html.print("nvram")
+html.print(capture("uci -c /etc/local/uci show 2>&1"))
-print "\nnvram\n";
-system "uci -c /etc/local/uci show 2>&1";
-
-print "
\n";
-
-page_footer();
-print "\n";
-print "\n";
+html.print("
")
+html.footer()
+html.print("