mirror of https://github.com/aredn/aredn.git
Lua stragglers (#274)
* Final bits of perl replaced by lua * Use iwinfo during first boot (api I was using fails this early) * Retry getting phy device (it can fail as the node is booting up)
This commit is contained in:
parent
922a74d574
commit
a0e7749b1e
|
@ -1,141 +1,108 @@
|
|||
#!/usr/bin/perl -w
|
||||
=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
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
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
|
||||
-- do the initial setup of the essential nvram variables
|
||||
-- node - node name
|
||||
-- mac2 - last 3 bytes of wifi mac address in the form ddd.ddd.ddd
|
||||
-- wifi_mac - full mac address of wireless card in the form hh:hh:hh:hh:hh:hh
|
||||
--
|
||||
-- intended to run every boot but it should only actually do anything
|
||||
-- on the first boot
|
||||
|
||||
# do the initial setup of the essential nvram variables
|
||||
# node - node name
|
||||
# mac2 - last 3 bytes of wifi mac address in the form ddd.ddd.ddd
|
||||
# wifi_mac - full mac address of wireless card in the form hh:hh:hh:hh:hh:hh
|
||||
#
|
||||
# intended to run every boot but it should only actually do anything
|
||||
# on the first boot
|
||||
require("aredn.utils")
|
||||
require("iwinfo")
|
||||
require("aredn.hardware")
|
||||
local aredn_info = require('aredn.info')
|
||||
|
||||
sub fail
|
||||
{
|
||||
open(ERR, ">>/tmp/nvram_errors");
|
||||
print ERR "@_\n";
|
||||
close(ERR);
|
||||
die "@_\n";
|
||||
}
|
||||
local wifi_mac = aredn_info.get_nvram("wifimac")
|
||||
local mac2 = aredn_info.get_nvram("mac2")
|
||||
local node = aredn_info.get_nvram("node")
|
||||
local dtdmac = aredn_info.get_nvram("dtdmac")
|
||||
|
||||
sub get_wlan2phy
|
||||
{
|
||||
my ($wlan) = $1;
|
||||
my ($phy) = "";
|
||||
return "phy0" unless $wlan;
|
||||
foreach(`iwinfo $wlan info`)
|
||||
{
|
||||
next unless /^.*PHY name:\s*([a-z0-4]+)/;
|
||||
$phy = $1;
|
||||
}
|
||||
return $phy;
|
||||
}
|
||||
local hardware_mac
|
||||
if wifi_mac == "" or mac2 == "" then
|
||||
local phy
|
||||
for i = 1,5
|
||||
do
|
||||
local f = io.popen("iwinfo " .. get_ifname("wifi") .. " info")
|
||||
if f then
|
||||
for line in f:lines()
|
||||
do
|
||||
phy = line:match("PHY name:%s*([a-z0-4]+)")
|
||||
if phy then
|
||||
break
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
end
|
||||
if phy then
|
||||
break
|
||||
end
|
||||
sleep(5);
|
||||
end
|
||||
for line in io.lines("/sys/class/ieee80211/" .. phy .. "/macaddress")
|
||||
do
|
||||
local m = line:match("(%w%w:%w%w:%w%w:%w%w:%w%w:%w%w)")
|
||||
if m then
|
||||
hardware_mac = m
|
||||
break
|
||||
end
|
||||
end
|
||||
if not hardware_mac then
|
||||
io.stderr:write("ERROR: hardware mac not found\n")
|
||||
os.exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
$commit = 0;
|
||||
$wifiif = `uci -q get network.wifi.ifname`;
|
||||
$phy = get_wlan2phy("$wifiif");
|
||||
if wifi_mac == "" then
|
||||
aredn_info.set_nvram("wifimac", hardware_mac)
|
||||
end
|
||||
|
||||
# Added new wifimac parm, the radio* wont startup without it, use the path location in wifi config
|
||||
# Actually it just needs some path to get to the radio.
|
||||
if mac2 == "" then
|
||||
local a, b, c = hardware_mac:match("%w%w:%w%w:%w%w:(%w%w):(%w%w):(%w%w)")
|
||||
mac2 = string.format("%d.%d.%d", tonumber(a, 16), tonumber(b, 16), tonumber(c, 16))
|
||||
aredn_info.set_nvram("mac2", mac2)
|
||||
end
|
||||
|
||||
chomp ($wifi_mac = `uci -c /etc/local/uci/ -q get hsmmmesh.settings.wifimac`);
|
||||
if node == "" then
|
||||
aredn_info.set_nvram("node", "NOCALL-" .. mac2:gsub("%.", "-"))
|
||||
end
|
||||
|
||||
if($wifi_mac eq "")
|
||||
{
|
||||
open(FILE, "/sys/class/ieee80211/${phy}/macaddress") or fail("ERROR: wireless mac not available");
|
||||
while(<FILE>)
|
||||
{
|
||||
next unless /(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/;
|
||||
$wifi_mac = $1;
|
||||
last;
|
||||
}
|
||||
close(FILE);
|
||||
fail("ERROR: wireless mac not found") if $wifi_mac eq "";
|
||||
system "uci -c /etc/local/uci/ set hsmmmesh.settings.wifimac=$wifi_mac";
|
||||
$commit = 1;
|
||||
}
|
||||
|
||||
|
||||
chomp ($mac2 = `uci -c /etc/local/uci/ -q get hsmmmesh.settings.mac2`);
|
||||
|
||||
if($mac2 eq "")
|
||||
{
|
||||
open(FILE, "/sys/class/ieee80211/${phy}/macaddress") or fail("ERROR: wireless mac not available");
|
||||
while(<FILE>)
|
||||
{
|
||||
next unless /\w\w:\w\w:\w\w:(\w\w):(\w\w):(\w\w)/;
|
||||
$mac2 = join ".", hex $1, hex $2, hex $3;
|
||||
last;
|
||||
}
|
||||
close(FILE);
|
||||
fail("ERROR: wireless mac not found") if $mac2 eq "";
|
||||
system "uci -c /etc/local/uci/ set hsmmmesh.settings.mac2=$mac2";
|
||||
$commit = 1;
|
||||
}
|
||||
|
||||
chomp ($node = `uci -c /etc/local/uci/ -q get hsmmmesh.settings.node`);
|
||||
|
||||
if($node eq "")
|
||||
{
|
||||
$mac2 =~ s/\./-/g;
|
||||
$node = "NOCALL-$mac2";
|
||||
system "uci -c /etc/local/uci/ set hsmmmesh.settings.node=NOCALL-$mac2";
|
||||
$commit = 1;
|
||||
}
|
||||
|
||||
chomp ($dtdmac = `uci -c /etc/local/uci/ -q get hsmmmesh.settings.dtdmac`);
|
||||
|
||||
if($dtdmac eq "")
|
||||
{
|
||||
# We should always have an eth0 interface on all nodes.
|
||||
# Not porting get_interface into this file at this time
|
||||
# as on a firstboot where nvram-setup runs the interfaces
|
||||
# should not be changed yet.
|
||||
open(FILE, "/sbin/ifconfig eth0 |") or fail("ERROR: eth0 mac not available");
|
||||
while(<FILE>)
|
||||
{
|
||||
next unless /\w\w:\w\w:\w\w:(\w\w):(\w\w):(\w\w)/;
|
||||
$dtdmac = join ".", hex $1, hex $2, hex $3;
|
||||
last;
|
||||
}
|
||||
close(FILE);
|
||||
system "uci -c /etc/local/uci/ set hsmmmesh.settings.dtdmac=$dtdmac";
|
||||
$commit = 1;
|
||||
}
|
||||
|
||||
|
||||
system "uci -c /etc/local/uci/ commit" if $commit;
|
||||
if dtdmac == "" then
|
||||
local a, b, c = aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("lan")):match("%w%w:%w%w:%w%w:(%w%w):(%w%w):(%w%w)")
|
||||
aredn_info.set_nvram("dtdmac", string.format("%d.%d.%d", tonumber(a, 16), tonumber(b, 16), tonumber(c, 16)))
|
||||
end
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
#!/usr/bin/perl -w
|
||||
=for comment
|
||||
|
||||
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
|
||||
Copyright (C) 2015 Conrad Lara
|
||||
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 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
# do the initial setup of the essential nvram variables
|
||||
# node - node name
|
||||
# mac2 - last 3 bytes of wifi mac address in the form ddd.ddd.ddd
|
||||
# wifi_mac - full mac address of wireless card in the form hh:hh:hh:hh:hh:hh
|
||||
#
|
||||
# intended to run every boot but it should only actually do anything
|
||||
# on the first boot
|
||||
|
||||
sub fail
|
||||
{
|
||||
open(ERR, ">>/tmp/nvram_errors");
|
||||
print ERR "@_\n";
|
||||
close(ERR);
|
||||
die "@_\n";
|
||||
}
|
||||
|
||||
sub get_wlan2phy
|
||||
{
|
||||
my ($wlan) = $1;
|
||||
my ($phy) = "";
|
||||
return "phy0" unless $wlan;
|
||||
foreach(`iwinfo $wlan info`)
|
||||
{
|
||||
next unless /^.*PHY name:\s*([a-z0-4]+)/;
|
||||
$phy = $1;
|
||||
}
|
||||
return $phy;
|
||||
}
|
||||
|
||||
$commit = 0;
|
||||
$wifiif = `uci -q get network.wifi.ifname`;
|
||||
$phy = get_wlan2phy("$wifiif");
|
||||
|
||||
# Added new wifimac parm, the radio* wont startup without it, use the path location in wifi config
|
||||
# Actually it just needs some path to get to the radio.
|
||||
|
||||
chomp ($wifi_mac = `uci -c /etc/local/uci/ -q get hsmmmesh.settings.wifimac`);
|
||||
|
||||
if($wifi_mac eq "")
|
||||
{
|
||||
open(FILE, "/sys/class/ieee80211/${phy}/macaddress") or fail("ERROR: wireless mac not available");
|
||||
while(<FILE>)
|
||||
{
|
||||
next unless /(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/;
|
||||
$wifi_mac = $1;
|
||||
last;
|
||||
}
|
||||
close(FILE);
|
||||
fail("ERROR: wireless mac not found") if $wifi_mac eq "";
|
||||
system "uci -c /etc/local/uci/ set hsmmmesh.settings.wifimac=$wifi_mac";
|
||||
$commit = 1;
|
||||
}
|
||||
|
||||
|
||||
chomp ($mac2 = `uci -c /etc/local/uci/ -q get hsmmmesh.settings.mac2`);
|
||||
|
||||
if($mac2 eq "")
|
||||
{
|
||||
open(FILE, "/sys/class/ieee80211/${phy}/macaddress") or fail("ERROR: wireless mac not available");
|
||||
while(<FILE>)
|
||||
{
|
||||
next unless /\w\w:\w\w:\w\w:(\w\w):(\w\w):(\w\w)/;
|
||||
$mac2 = join ".", hex $1, hex $2, hex $3;
|
||||
last;
|
||||
}
|
||||
close(FILE);
|
||||
fail("ERROR: wireless mac not found") if $mac2 eq "";
|
||||
system "uci -c /etc/local/uci/ set hsmmmesh.settings.mac2=$mac2";
|
||||
$commit = 1;
|
||||
}
|
||||
|
||||
chomp ($node = `uci -c /etc/local/uci/ -q get hsmmmesh.settings.node`);
|
||||
|
||||
if($node eq "")
|
||||
{
|
||||
$mac2 =~ s/\./-/g;
|
||||
$node = "NOCALL-$mac2";
|
||||
system "uci -c /etc/local/uci/ set hsmmmesh.settings.node=NOCALL-$mac2";
|
||||
$commit = 1;
|
||||
}
|
||||
|
||||
chomp ($dtdmac = `uci -c /etc/local/uci/ -q get hsmmmesh.settings.dtdmac`);
|
||||
|
||||
if($dtdmac eq "")
|
||||
{
|
||||
# We should always have an eth0 interface on all nodes.
|
||||
# Not porting get_interface into this file at this time
|
||||
# as on a firstboot where nvram-setup runs the interfaces
|
||||
# should not be changed yet.
|
||||
open(FILE, "/sbin/ifconfig eth0 |") or fail("ERROR: eth0 mac not available");
|
||||
while(<FILE>)
|
||||
{
|
||||
next unless /\w\w:\w\w:\w\w:(\w\w):(\w\w):(\w\w)/;
|
||||
$dtdmac = join ".", hex $1, hex $2, hex $3;
|
||||
last;
|
||||
}
|
||||
close(FILE);
|
||||
system "uci -c /etc/local/uci/ set hsmmmesh.settings.dtdmac=$dtdmac";
|
||||
$commit = 1;
|
||||
}
|
||||
|
||||
|
||||
system "uci -c /etc/local/uci/ commit" if $commit;
|
|
@ -1,50 +1,48 @@
|
|||
#!/usr/bin/perl -w
|
||||
=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
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
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
|
||||
if #arg ~= 1 then
|
||||
io.stderr:write("usage: setpasswd <password>\nthis sets both the system and website paswords\n")
|
||||
os.exit(-1)
|
||||
end
|
||||
|
||||
unless(defined ($pw = shift))
|
||||
{
|
||||
print STDERR "\nusage: setpasswd <password>\n";
|
||||
print STDERR "this sets both the system and website paswords\n\n";
|
||||
exit 1;
|
||||
}
|
||||
local pw = arg[1]:gsub("'", "\\'")
|
||||
local f = io.popen("{ echo '" .. pw .. "'; sleep 1; echo '" .. pw .. "'; } | passwd")
|
||||
f:read("*a")
|
||||
f:close()
|
||||
|
||||
$pw2 = $pw;
|
||||
$pw2 =~ s/'/'\\''/g;
|
||||
system "{ echo '$pw2'; sleep 1; echo '$pw2'; } | passwd > /dev/null\n";
|
||||
|
||||
print STDERR "passwords changed.\n";
|
||||
io.stderr:write("passwords changed.\n")
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/perl -w
|
||||
=for comment
|
||||
|
||||
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
|
||||
Copyright (C) 2015 Conrad Lara
|
||||
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 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
unless(defined ($pw = shift))
|
||||
{
|
||||
print STDERR "\nusage: setpasswd <password>\n";
|
||||
print STDERR "this sets both the system and website paswords\n\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
$pw2 = $pw;
|
||||
$pw2 =~ s/'/'\\''/g;
|
||||
system "{ echo '$pw2'; sleep 1; echo '$pw2'; } | passwd > /dev/null\n";
|
||||
|
||||
print STDERR "passwords changed.\n";
|
|
@ -1,335 +1,315 @@
|
|||
#!/usr/bin/perl -w
|
||||
=for comment
|
||||
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
|
||||
Copyright (C) 2015 Conrad Lara
|
||||
See Contributors file for additional contributors
|
||||
#!/usr/bin/lua
|
||||
--[[
|
||||
|
||||
Copyright (c) 2013 David Rivenburg et al. BroadBand-HamNet
|
||||
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
|
||||
Copyright (C) 2021 Tim Wilkinson
|
||||
Original Perl Copyright (c) 2015 Joe Ayers AE6XE
|
||||
Original Perl Copyright (c) 2013 David Rivenburg et al. BroadBand-HamNet
|
||||
See Contributors file for additional contributors
|
||||
|
||||
2015-04-01 AE6XE update to display neighbor nodes, replace vendor with mode
|
||||
2015-04-01 AE6XE update to display neighbor nodes, replace vendor with mode
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
--]]
|
||||
|
||||
sub usage
|
||||
{
|
||||
print "usage: wscan [-1abnor] [-i iface]\n";
|
||||
print " -1 run once and quit\n";
|
||||
print " -a average mode\n";
|
||||
print " -b batch mode\n";
|
||||
print " -n <num> number of times to scan\n";
|
||||
print " -o show only open access points\n";
|
||||
print " -r raw mode\n";
|
||||
print " -w produce html output\n";
|
||||
exit;
|
||||
}
|
||||
require("nixio")
|
||||
require("aredn.utils")
|
||||
require("aredn.hardware")
|
||||
aredn.info = require("aredn.info")
|
||||
|
||||
sub freq_to_chan
|
||||
{
|
||||
my ($freq) = @_;
|
||||
function usage()
|
||||
print("usage: wscan [-1abnor] [-i iface]")
|
||||
print(" -1 run once and quit")
|
||||
print(" -a average mode")
|
||||
print(" -b batch mode")
|
||||
print(" -n <num> number of times to scan")
|
||||
print(" -o show only open access points")
|
||||
print(" -r raw mode")
|
||||
os.exit()
|
||||
end
|
||||
|
||||
if ($freq < 256 )
|
||||
{
|
||||
return $freq;
|
||||
}
|
||||
elsif ($freq == 2484)
|
||||
{
|
||||
return "14";
|
||||
}
|
||||
elsif ($freq == 2407)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
elsif ($freq < 2484)
|
||||
{
|
||||
return ($freq-2407)/5;
|
||||
}
|
||||
elsif ($freq < 5000)
|
||||
{
|
||||
return $freq ; # stay in freq, no ch #s
|
||||
}
|
||||
elsif ($freq < 5380) # these are 5Ghz channels 75 and below
|
||||
{
|
||||
return ($freq-5000)/5 ;
|
||||
}
|
||||
elsif ($freq < 5500) # ch 76 to 99 can only be 3Ghz freq, no part 15 here
|
||||
{
|
||||
return ($freq-2000); # return 3ghz freq (5ghz boards with -2Ghz transverter)
|
||||
}
|
||||
elsif ($freq < 6000)
|
||||
{
|
||||
return ($freq-5000)/5;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $freq;
|
||||
}
|
||||
}
|
||||
function die(msg)
|
||||
print(msg)
|
||||
os.exit(1)
|
||||
end
|
||||
|
||||
sub pushAP
|
||||
{
|
||||
my($signal, $freq, $key, $ssid, $host, $mac, $mode) = @_;
|
||||
function freq_to_chan(freq)
|
||||
local chan = freq
|
||||
if chan < 256 then
|
||||
elseif chan == 2484 then
|
||||
return 14
|
||||
elseif chan == 2407 then
|
||||
return 0
|
||||
elseif chan < 2484 then
|
||||
return (chan - 2407) / 5
|
||||
elseif chan < 5000 then
|
||||
elseif chan < 5380 then
|
||||
return (chan - 5000) / 5
|
||||
elseif chan < 5500 then
|
||||
return chan - 2000
|
||||
elseif chan < 6000 then
|
||||
return (chan - 5000) / 5
|
||||
end
|
||||
return "?"
|
||||
end
|
||||
|
||||
return if $mac eq "";
|
||||
return if $openap and ($key ne "");
|
||||
-- load arp cache
|
||||
local arpcache = {}
|
||||
arptable(function(a)
|
||||
arpcache[a["HW address"]] = a["IP address"]
|
||||
end)
|
||||
|
||||
$chan=freq_to_chan($freq);
|
||||
|
||||
if($ssid eq "") { $ssid = "(hidden)" }
|
||||
if($chan eq "") { $chan = "?" }
|
||||
|
||||
if($key eq "") { $key = " " }
|
||||
else { $key = "*" }
|
||||
|
||||
if($avg)
|
||||
{
|
||||
$avgs{"$mac total"} += $signal;
|
||||
$avgs{"$mac num"} += 1;
|
||||
$aphash{$mac} = sprintf "% 3d %s %-32s\t%s\t%s\t%s\n",
|
||||
$chan, $key, $ssid, $host, $mac, $mode;
|
||||
}
|
||||
elsif($web)
|
||||
{
|
||||
push @list, sprintf "% 3d|%d|%s|%s|%s|%s|%s",
|
||||
$signal, $chan, $key, sprintf("&#x%*vX", '&#x',$ssid), $host, $mac, $mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
push @list, sprintf "% 3d %2d %s %-32s\t%s\t%s\t%s\n",
|
||||
$signal, $chan, $key, $ssid, $host, $mac, $mode;
|
||||
}
|
||||
}
|
||||
|
||||
###################################################
|
||||
|
||||
$avg = 0; # average mode
|
||||
$batch = 0; # batch mode
|
||||
$loops = 0; # number of times to run 0=inf
|
||||
$raw = 0; # raw mode
|
||||
$openap = 0; # show open ap's
|
||||
$iface = `uci -q get 'network.wifi.ifname'`; # wireless interface
|
||||
chomp $iface;
|
||||
|
||||
$iters = 0; # number of iterations
|
||||
%avgs = (); # average statistics
|
||||
%aphash = (); # list of ap's for avg mode
|
||||
|
||||
$mychan = `iwinfo $iface info | grep -i channel`;
|
||||
$mychan =~ /Channel:\s+(-*\d+)/;
|
||||
$mychan = ( ! defined $1 || ! int($1) || ! ($1 >= -4 && $1 <= 185) ) ? 0 : $1;
|
||||
|
||||
# ch 76 - 99 are 3ghz since no part 15 usage (5ghz board with -2ghz transverter)
|
||||
if ($mychan >= 76 and $mychan <= 99)
|
||||
{
|
||||
$mychan = ($mychan*5+3000);
|
||||
}
|
||||
|
||||
while(defined ($arg = shift))
|
||||
{
|
||||
if ($arg eq "-h") { usage() }
|
||||
elsif($arg eq "-1") { $loops = 1 }
|
||||
elsif($arg eq "-a") { $avg = 1 }
|
||||
elsif($arg eq "-b") { $batch = 1 }
|
||||
elsif($arg eq "-o") { $openap = 1 }
|
||||
elsif($arg eq "-r") { $raw = 1 }
|
||||
elsif($arg eq "-i") { $iface = shift }
|
||||
elsif($arg eq "-n") { $loops = shift }
|
||||
elsif($arg eq "-w") { $web = 1 }
|
||||
else { die "bad arg $arg\n" }
|
||||
}
|
||||
|
||||
die "bad interface" if not defined $iface;
|
||||
|
||||
if($raw)
|
||||
{
|
||||
system("iw dev $iface scan passive");
|
||||
system("iw dev $iface station dump");
|
||||
exit;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
$line = `egrep "['\\"].*-(5|10|20)-v[3456]" /etc/config/wireless | head -1`;
|
||||
$line =~ /['"](.*-(5|10|20)-v[3456])/;
|
||||
$myssid = $1;
|
||||
|
||||
open(FILE, "iw dev $iface scan passive 2>&1 |") or die "iw scan failed";
|
||||
$mac = "";
|
||||
$host = "N/A";
|
||||
$lastseen = 0;
|
||||
@list = ();
|
||||
|
||||
while($line = <FILE>)
|
||||
{
|
||||
if($line =~ /BSS\s+(([[:xdigit:]]{2}:){5}[[:xdigit:]]{2})/)
|
||||
{
|
||||
if ( $lastseen < 10000 ) { pushAP($signal, $chan, $key, $ssid, $host, $mac, $mode) }
|
||||
$mac = uc $1;
|
||||
|
||||
$mode = "AP";
|
||||
$ssid = "";
|
||||
$signal = 0;
|
||||
$chan = "";
|
||||
$key = "";
|
||||
$lastseen = 0;
|
||||
|
||||
}
|
||||
|
||||
if($line =~ /BSS(\s+)([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}.*joined/)
|
||||
{
|
||||
$mode = "My Ad-Hoc Network";
|
||||
$chan = $mychan;
|
||||
}
|
||||
if($line =~ /\bSSID: (.*)/) { $ssid = $1 }
|
||||
if($line =~ /\bSSID: unknown/) { $ssid = "unknown" }
|
||||
if($line =~ /\bcapability: (IBSS)/ and $mode eq "AP")
|
||||
{ $mode = "Foreign Ad-Hoc Network" }
|
||||
if($line =~ /\bfreq: (\d+)/) { $chan = $1 }
|
||||
if($line =~ /\bsignal: ([\d-]+)/) { $signal = $1 }
|
||||
if($line =~ /\bGroup cipher:(.+)/) { $key = $1 }
|
||||
if($line =~ /\blast seen: (\d+)/) { $lastseen = $1 }
|
||||
}
|
||||
|
||||
close(FILE);
|
||||
|
||||
if ( $lastseen < 10000 ) { pushAP($signal, $chan, $key, $ssid, $host, $mac, $mode) }
|
||||
sleep 1 if not scalar @list and $loops != 1;
|
||||
|
||||
$mac = "";
|
||||
$mode = "Connected Ad-Hoc Station";
|
||||
$signal = 0;
|
||||
$key = "";
|
||||
$lastseen = 0;
|
||||
++$iters;
|
||||
|
||||
open(FILE, "iw dev $iface station dump 2>&1 |") or die "iw failed";
|
||||
|
||||
while($line = <FILE>)
|
||||
{
|
||||
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 "<table class=sortable border=1 cellpadding=5>\n";
|
||||
print "<tr><th>Sig</th><th>Chan</th><th>Enc</th><th>SSID</th><th>Hostname</th><th>MAC/BSSID</th><th>802.11 Mode</th></tr>\n";
|
||||
}
|
||||
local hostcache = {}
|
||||
function mac_to_host(mac)
|
||||
if not mac then
|
||||
return "N/A"
|
||||
end
|
||||
local host = hostcache[mac]
|
||||
if host then
|
||||
return host
|
||||
end
|
||||
local ip = arpcache[mac]
|
||||
if ip then
|
||||
hostname = ip
|
||||
local f = io.popen("nslookup " .. ip)
|
||||
if f then
|
||||
for line in f:lines()
|
||||
do
|
||||
local m = line:match("name = (.*)%.local%.mesh")
|
||||
if m then
|
||||
f:close()
|
||||
hostcache[mac] = m
|
||||
return m
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
end
|
||||
else
|
||||
{
|
||||
#system "clear";
|
||||
printf "Sig Ch E SSID Hostname MAC/BSSID 802.11 Mode %6d\n", $iters;
|
||||
print "--- -- - -------------------------------- --------------------- ------------- ------------\n";
|
||||
}
|
||||
}
|
||||
hostcache[mac] = "N/A"
|
||||
return "N/A"
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
{
|
||||
local avg = false -- average mode
|
||||
local batch = false -- batch mode
|
||||
local loops = 0 -- number of times to run 0=inf
|
||||
local raw = false -- raw mode
|
||||
local openap = false -- show open ap's
|
||||
|
||||
# Match "AREDN"
|
||||
if ( $line =~ /AREDN/) { print "<tr class=\"wscan-row-node\">"}
|
||||
else { print "<tr>"}
|
||||
local iface = aredn.hardware.get_iface_name("wifi") -- wifi interface
|
||||
|
||||
my $i = 0;
|
||||
foreach $val (split /\|/, $line)
|
||||
{
|
||||
$val = " " unless $val =~ /\S/;
|
||||
if($i++ == 3) { print "<td>$val</td>" }
|
||||
else { print "<td align=center>$val</td>" }
|
||||
}
|
||||
print "<td> </td>" if $i < 7;
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</table>\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
open(FILE, "| sort -nr");
|
||||
print FILE @list;
|
||||
close(FILE);
|
||||
print "\n";
|
||||
}
|
||||
local iters = 0 -- number of iterations
|
||||
local avgs = {} -- average statistics
|
||||
|
||||
last if --$loops == 0;
|
||||
}
|
||||
local i = 1
|
||||
while i <= #arg
|
||||
do
|
||||
local a = arg[i]
|
||||
i = i + 1
|
||||
if a == "-h" then
|
||||
usage()
|
||||
elseif a == "-1" then
|
||||
loops = 1
|
||||
elseif a == "-a" then
|
||||
avg = true
|
||||
elseif a == "-b" then
|
||||
batch = true
|
||||
elseif a == "-o" then
|
||||
openap = true
|
||||
elseif a == "-r" then
|
||||
raw = true
|
||||
elseif a == "-i" then
|
||||
iface = arg[i]
|
||||
i = i + 1
|
||||
elseif a == "-n" then
|
||||
loops = tonumber(arg[i])
|
||||
i = i + 1
|
||||
else
|
||||
die("bad arg " .. a)
|
||||
end
|
||||
end
|
||||
|
||||
if not iface or iface == "" then
|
||||
die("bad interface")
|
||||
end
|
||||
|
||||
if raw then
|
||||
os.execute("iw dev " .. iface .. " scan passive")
|
||||
os.execute("iw dev " .. iface .. " station dump")
|
||||
os.exit()
|
||||
end
|
||||
|
||||
if loops == 0 then
|
||||
loops = math.huge
|
||||
end
|
||||
|
||||
local myssid = aredn.info.getSSID()
|
||||
local myfreq = tonumber(aredn.info.getFreq())
|
||||
|
||||
for _ = 1,loops
|
||||
do
|
||||
-- scan start
|
||||
local scanned = {}
|
||||
local f = io.popen("iw dev " .. iface .. " scan passive")
|
||||
if f then
|
||||
local scan
|
||||
for line in f:lines()
|
||||
do
|
||||
local m = line:match("^BSS ([%da-fA-F:]+)")
|
||||
if m then
|
||||
scan = {
|
||||
mac = m,
|
||||
mode = "AP",
|
||||
ssid = "",
|
||||
signal = 0,
|
||||
freq = 0,
|
||||
key = ""
|
||||
}
|
||||
scanned[#scanned + 1] = scan
|
||||
if line:match("joined") then
|
||||
scan.mode = "My Ad-Hoc Network"
|
||||
end
|
||||
end
|
||||
m = line:match("freq: (%d+)")
|
||||
if m then
|
||||
scan.freq = tonumber(m)
|
||||
end
|
||||
m = line:match("SSID: (.+)")
|
||||
if m then
|
||||
scan.ssid = m
|
||||
end
|
||||
m = line:match("signal: ([%d-]+)")
|
||||
if m then
|
||||
scan.signal = tonumber(m)
|
||||
end
|
||||
m = line:match("Group cipher: (.+)")
|
||||
if m then
|
||||
scan.key = m
|
||||
end
|
||||
if line:match("capability: IBSS") and scan.mode == "AP" then
|
||||
scan.mode = "Foreign Ad-Hoc Network"
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
end
|
||||
local f = io.popen("iw dev " .. iface .. " station dump")
|
||||
if f then
|
||||
local scan
|
||||
for line in f:lines()
|
||||
do
|
||||
local m = line:match("^Station ([%da-fA-F:]+) %(on " .. iface .. "%)")
|
||||
if m then
|
||||
scan = {
|
||||
mac = m,
|
||||
mode = "Connected Ad-Hoc Station",
|
||||
ssid = myssid,
|
||||
signal = 0,
|
||||
freq = myfreq,
|
||||
key = ""
|
||||
}
|
||||
scanned[#scanned + 1] = scan
|
||||
end
|
||||
m = line:match("signal avg:%s+([%d-]+)")
|
||||
if m and scan then
|
||||
scan.signal = tonumber(m)
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
end
|
||||
-- scan end
|
||||
|
||||
-- update running averages
|
||||
for _, scan in ipairs(scanned)
|
||||
do
|
||||
local v = avgs[scan.mac]
|
||||
if not v then
|
||||
v = { num = 1, total = scan.signal }
|
||||
avgs[scan.mac] = v
|
||||
else
|
||||
v.num = v.num + 1
|
||||
v.total = v.total + scan.signal
|
||||
end
|
||||
v.mac = scan.mac
|
||||
v.mode = scan.mode
|
||||
v.ssid = scan.ssid
|
||||
v.signal = scan.signal
|
||||
v.freq = scan.freq
|
||||
v.key = scan.key
|
||||
end
|
||||
|
||||
if #scanned == 0 and loops ~= 1 then
|
||||
nixio.nanosleep(1, 0)
|
||||
end
|
||||
|
||||
iters = iters + 1
|
||||
|
||||
-- create output
|
||||
local output = {}
|
||||
|
||||
if avg then
|
||||
for _, scan in pairs(avgs)
|
||||
do
|
||||
if scan.signal ~= 0 and (not openap or scan.key == "") then
|
||||
local chan = freq_to_chan(scan.freq)
|
||||
local ssid = scan.ssid == "" and "(hidden)" or scan.ssid
|
||||
local key = scan.key == "" and " " or "*"
|
||||
output[#output + 1] = string.format("%3d %3d %3d %s %-32s\t%s\t%s\t%s", math.floor((scan.total - scan.num + 1) / scan.num), math.floor(100 * scan.num / iters), chan, key, ssid, mac_to_host(scan.host), scan.mac:upper(), scan.mode)
|
||||
end
|
||||
end
|
||||
else
|
||||
for _, scan in ipairs(scanned)
|
||||
do
|
||||
if scan.signal ~= 0 and (not openap or scan.key == "") then
|
||||
local chan = freq_to_chan(scan.freq)
|
||||
local ssid = scan.ssid == "" and "(hidden)" or scan.ssid
|
||||
local key = scan.key == "" and " " or "*"
|
||||
output[#output + 1] = string.format("%3d %2d %s %-32s\t%s\t%s\t%s", scan.signal, chan, key, ssid, mac_to_host(scan.host), scan.mac:upper(), scan.mode)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(output, function(a,b) return a < b end)
|
||||
|
||||
if not batch then
|
||||
if avg then
|
||||
os.execute("clear")
|
||||
print(string.format("Sig Rel Ch E SSID Hostname MAC/BSSID 802.11 Mode %6d", iters))
|
||||
print("--- --- -- - -------------------------------- ----------------- ------------- -----------")
|
||||
else
|
||||
print(string.format("Sig Ch E SSID Hostname MAC/BSSID 802.11 Mode %6d", iters))
|
||||
print("--- -- - -------------------------------- --------------------- ------------- ------------")
|
||||
end
|
||||
end
|
||||
|
||||
for _, out in ipairs(output)
|
||||
do
|
||||
print(out)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,335 @@
|
|||
#!/usr/bin/perl -w
|
||||
=for comment
|
||||
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
|
||||
Copyright (C) 2015 Conrad Lara
|
||||
See Contributors file for additional contributors
|
||||
|
||||
Copyright (c) 2013 David Rivenburg et al. BroadBand-HamNet
|
||||
|
||||
2015-04-01 AE6XE update to display neighbor nodes, replace vendor with mode
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
sub usage
|
||||
{
|
||||
print "usage: wscan [-1abnor] [-i iface]\n";
|
||||
print " -1 run once and quit\n";
|
||||
print " -a average mode\n";
|
||||
print " -b batch mode\n";
|
||||
print " -n <num> number of times to scan\n";
|
||||
print " -o show only open access points\n";
|
||||
print " -r raw mode\n";
|
||||
print " -w produce html output\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
sub freq_to_chan
|
||||
{
|
||||
my ($freq) = @_;
|
||||
|
||||
if ($freq < 256 )
|
||||
{
|
||||
return $freq;
|
||||
}
|
||||
elsif ($freq == 2484)
|
||||
{
|
||||
return "14";
|
||||
}
|
||||
elsif ($freq == 2407)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
elsif ($freq < 2484)
|
||||
{
|
||||
return ($freq-2407)/5;
|
||||
}
|
||||
elsif ($freq < 5000)
|
||||
{
|
||||
return $freq ; # stay in freq, no ch #s
|
||||
}
|
||||
elsif ($freq < 5380) # these are 5Ghz channels 75 and below
|
||||
{
|
||||
return ($freq-5000)/5 ;
|
||||
}
|
||||
elsif ($freq < 5500) # ch 76 to 99 can only be 3Ghz freq, no part 15 here
|
||||
{
|
||||
return ($freq-2000); # return 3ghz freq (5ghz boards with -2Ghz transverter)
|
||||
}
|
||||
elsif ($freq < 6000)
|
||||
{
|
||||
return ($freq-5000)/5;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $freq;
|
||||
}
|
||||
}
|
||||
|
||||
sub pushAP
|
||||
{
|
||||
my($signal, $freq, $key, $ssid, $host, $mac, $mode) = @_;
|
||||
|
||||
return if $mac eq "";
|
||||
return if $openap and ($key ne "");
|
||||
|
||||
$chan=freq_to_chan($freq);
|
||||
|
||||
if($ssid eq "") { $ssid = "(hidden)" }
|
||||
if($chan eq "") { $chan = "?" }
|
||||
|
||||
if($key eq "") { $key = " " }
|
||||
else { $key = "*" }
|
||||
|
||||
if($avg)
|
||||
{
|
||||
$avgs{"$mac total"} += $signal;
|
||||
$avgs{"$mac num"} += 1;
|
||||
$aphash{$mac} = sprintf "% 3d %s %-32s\t%s\t%s\t%s\n",
|
||||
$chan, $key, $ssid, $host, $mac, $mode;
|
||||
}
|
||||
elsif($web)
|
||||
{
|
||||
push @list, sprintf "% 3d|%d|%s|%s|%s|%s|%s",
|
||||
$signal, $chan, $key, sprintf("&#x%*vX", '&#x',$ssid), $host, $mac, $mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
push @list, sprintf "% 3d %2d %s %-32s\t%s\t%s\t%s\n",
|
||||
$signal, $chan, $key, $ssid, $host, $mac, $mode;
|
||||
}
|
||||
}
|
||||
|
||||
###################################################
|
||||
|
||||
$avg = 0; # average mode
|
||||
$batch = 0; # batch mode
|
||||
$loops = 0; # number of times to run 0=inf
|
||||
$raw = 0; # raw mode
|
||||
$openap = 0; # show open ap's
|
||||
$iface = `uci -q get 'network.wifi.ifname'`; # wireless interface
|
||||
chomp $iface;
|
||||
|
||||
$iters = 0; # number of iterations
|
||||
%avgs = (); # average statistics
|
||||
%aphash = (); # list of ap's for avg mode
|
||||
|
||||
$mychan = `iwinfo $iface info | grep -i channel`;
|
||||
$mychan =~ /Channel:\s+(-*\d+)/;
|
||||
$mychan = ( ! defined $1 || ! int($1) || ! ($1 >= -4 && $1 <= 185) ) ? 0 : $1;
|
||||
|
||||
# ch 76 - 99 are 3ghz since no part 15 usage (5ghz board with -2ghz transverter)
|
||||
if ($mychan >= 76 and $mychan <= 99)
|
||||
{
|
||||
$mychan = ($mychan*5+3000);
|
||||
}
|
||||
|
||||
while(defined ($arg = shift))
|
||||
{
|
||||
if ($arg eq "-h") { usage() }
|
||||
elsif($arg eq "-1") { $loops = 1 }
|
||||
elsif($arg eq "-a") { $avg = 1 }
|
||||
elsif($arg eq "-b") { $batch = 1 }
|
||||
elsif($arg eq "-o") { $openap = 1 }
|
||||
elsif($arg eq "-r") { $raw = 1 }
|
||||
elsif($arg eq "-i") { $iface = shift }
|
||||
elsif($arg eq "-n") { $loops = shift }
|
||||
elsif($arg eq "-w") { $web = 1 }
|
||||
else { die "bad arg $arg\n" }
|
||||
}
|
||||
|
||||
die "bad interface" if not defined $iface;
|
||||
|
||||
if($raw)
|
||||
{
|
||||
system("iw dev $iface scan passive");
|
||||
system("iw dev $iface station dump");
|
||||
exit;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
$line = `egrep "['\\"].*-(5|10|20)-v[3456]" /etc/config/wireless | head -1`;
|
||||
$line =~ /['"](.*-(5|10|20)-v[3456])/;
|
||||
$myssid = $1;
|
||||
|
||||
open(FILE, "iw dev $iface scan passive 2>&1 |") or die "iw scan failed";
|
||||
$mac = "";
|
||||
$host = "N/A";
|
||||
$lastseen = 0;
|
||||
@list = ();
|
||||
|
||||
while($line = <FILE>)
|
||||
{
|
||||
if($line =~ /BSS\s+(([[:xdigit:]]{2}:){5}[[:xdigit:]]{2})/)
|
||||
{
|
||||
if ( $lastseen < 10000 ) { pushAP($signal, $chan, $key, $ssid, $host, $mac, $mode) }
|
||||
$mac = uc $1;
|
||||
|
||||
$mode = "AP";
|
||||
$ssid = "";
|
||||
$signal = 0;
|
||||
$chan = "";
|
||||
$key = "";
|
||||
$lastseen = 0;
|
||||
|
||||
}
|
||||
|
||||
if($line =~ /BSS(\s+)([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}.*joined/)
|
||||
{
|
||||
$mode = "My Ad-Hoc Network";
|
||||
$chan = $mychan;
|
||||
}
|
||||
if($line =~ /\bSSID: (.*)/) { $ssid = $1 }
|
||||
if($line =~ /\bSSID: unknown/) { $ssid = "unknown" }
|
||||
if($line =~ /\bcapability: (IBSS)/ and $mode eq "AP")
|
||||
{ $mode = "Foreign Ad-Hoc Network" }
|
||||
if($line =~ /\bfreq: (\d+)/) { $chan = $1 }
|
||||
if($line =~ /\bsignal: ([\d-]+)/) { $signal = $1 }
|
||||
if($line =~ /\bGroup cipher:(.+)/) { $key = $1 }
|
||||
if($line =~ /\blast seen: (\d+)/) { $lastseen = $1 }
|
||||
}
|
||||
|
||||
close(FILE);
|
||||
|
||||
if ( $lastseen < 10000 ) { pushAP($signal, $chan, $key, $ssid, $host, $mac, $mode) }
|
||||
sleep 1 if not scalar @list and $loops != 1;
|
||||
|
||||
$mac = "";
|
||||
$mode = "Connected Ad-Hoc Station";
|
||||
$signal = 0;
|
||||
$key = "";
|
||||
$lastseen = 0;
|
||||
++$iters;
|
||||
|
||||
open(FILE, "iw dev $iface station dump 2>&1 |") or die "iw failed";
|
||||
|
||||
while($line = <FILE>)
|
||||
{
|
||||
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 "<table class=sortable border=1 cellpadding=5>\n";
|
||||
print "<tr><th>Sig</th><th>Chan</th><th>Enc</th><th>SSID</th><th>Hostname</th><th>MAC/BSSID</th><th>802.11 Mode</th></tr>\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 "<tr class=\"wscan-row-node\">"}
|
||||
else { print "<tr>"}
|
||||
|
||||
my $i = 0;
|
||||
foreach $val (split /\|/, $line)
|
||||
{
|
||||
$val = " " unless $val =~ /\S/;
|
||||
if($i++ == 3) { print "<td>$val</td>" }
|
||||
else { print "<td align=center>$val</td>" }
|
||||
}
|
||||
print "<td> </td>" if $i < 7;
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</table>\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
open(FILE, "| sort -nr");
|
||||
print FILE @list;
|
||||
close(FILE);
|
||||
print "\n";
|
||||
}
|
||||
|
||||
last if --$loops == 0;
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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");
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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");
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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"
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
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 "<body><pre>\n";
|
||||
http_header()
|
||||
html.header(node .. " system information", false)
|
||||
html.print("<body><pre>")
|
||||
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("<font color=\"red\">!!!! UNSUPPORTED DEVICE !!!!</font>")
|
||||
html.print("boardid: " .. aredn.hardware.get_board_id())
|
||||
if aredn.hardware.supported() == 0 then
|
||||
html.print("<font color=\"red\">Device HAS BEEN TESTED AS UNSUPPORTED</font>")
|
||||
else
|
||||
html.print("<font color=\"red\">Device has not been tested. Please file a ticket with your experiences.</font>")
|
||||
end
|
||||
html.print("")
|
||||
end
|
||||
|
||||
if ( is_hardware_supported() !=1 ){
|
||||
print "<font color=\"red\">!!!! UNSUPPORTED DEVICE !!!!</font>\n";
|
||||
print "boardid: " , hardware_boardid() , "\n";
|
||||
if ( is_hardware_supported == 0 ) {
|
||||
print "<font color=\"red\">Device HAS BEEN TESTED AS UNSUPPORTED</font>\n";
|
||||
}
|
||||
else {
|
||||
print "<font color=\"red\">Device has not been tested. Please file a ticket with your experiences.</font>\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 "</pre>\n";
|
||||
|
||||
page_footer();
|
||||
print "</body>\n";
|
||||
print "</html>\n";
|
||||
html.print("</pre>")
|
||||
html.footer()
|
||||
html.print("</body></html>")
|
||||
http_footer()
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#!/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
|
||||
|
||||
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 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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;
|
||||
|
||||
http_header();
|
||||
html_header("$node system information", 1);
|
||||
print "<body><pre>\n";
|
||||
|
||||
print " node: ", nvram_get("node"), "\n";
|
||||
print "model: ", `/usr/local/bin/get_model`, "\n";
|
||||
|
||||
if ( is_hardware_supported() !=1 ){
|
||||
print "<font color=\"red\">!!!! UNSUPPORTED DEVICE !!!!</font>\n";
|
||||
print "boardid: " , hardware_boardid() , "\n";
|
||||
if ( is_hardware_supported == 0 ) {
|
||||
print "<font color=\"red\">Device HAS BEEN TESTED AS UNSUPPORTED</font>\n";
|
||||
}
|
||||
else {
|
||||
print "<font color=\"red\">Device has not been tested. Please file a ticket with your experiences.</font>\n";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
|
||||
foreach(`ifconfig -a`)
|
||||
{
|
||||
next unless /^(\S+) .*HWaddr (\S+)/;
|
||||
printf "%-6s %s\n", $1, $2;
|
||||
}
|
||||
|
||||
print "\n/proc/cpuinfo\n";
|
||||
system "cat /proc/cpuinfo";
|
||||
|
||||
print "\nnvram\n";
|
||||
system "uci -c /etc/local/uci show 2>&1";
|
||||
|
||||
print "</pre>\n";
|
||||
|
||||
page_footer();
|
||||
print "</body>\n";
|
||||
print "</html>\n";
|
Loading…
Reference in New Issue