|
@@ -1,40 +1,37 @@
|
|
|
#!/usr/bin/lua
|
|
|
|
|
|
-debugdata = ""
|
|
|
+local debugdata = ''
|
|
|
PATH_DBG_REPORT='/tmp/debug-report.txt'
|
|
|
|
|
|
local nixio = require('nixio'), require('nixio.util')
|
|
|
-local util = require("luci.util")
|
|
|
-local fs = require("nixio.fs")
|
|
|
-local ltn12 = require 'luci.ltn12'
|
|
|
-local sys = require("luci.sys")
|
|
|
-local json = require("luci.jsonc")
|
|
|
-local platform_info = require("platform_info")
|
|
|
+local fs = require 'nixio.fs'
|
|
|
+local json = require('luci.jsonc')
|
|
|
+local uci = require('simple-uci').cursor()
|
|
|
+local pretty_hostname = require 'pretty_hostname'
|
|
|
+
|
|
|
local site = require 'gluon.site_config'
|
|
|
-local ip = require 'luci.ip'
|
|
|
-local uci = require('luci.model.uci').cursor()
|
|
|
+local sysconfig = require 'gluon.sysconfig'
|
|
|
+local platform = require 'gluon.platform'
|
|
|
+local util = require 'gluon.util'
|
|
|
|
|
|
-- some usefull functions
|
|
|
-local hostname = sys.hostname()
|
|
|
-local model = platform_info.get_model()
|
|
|
-local release = util.trim(fs.readfile("/lib/gluon/release") or "")
|
|
|
-local version = util.trim(fs.readfile("/lib/gluon/gluon-version") or "")
|
|
|
-local primary_mac = require('gluon.sysconfig').primary_mac
|
|
|
-
|
|
|
-local contact = uci:get_first('gluon-node-info', 'owner', 'contact', '')
|
|
|
-if contact == '' then
|
|
|
- contact = "none"
|
|
|
-end
|
|
|
+local hostname = pretty_hostname.get(uci)
|
|
|
+local primary_mac = sysconfig.primary_mac
|
|
|
+local model = platform.get_model()
|
|
|
+local version = util.trim(fs.readfile('/lib/gluon/gluon-version'))
|
|
|
+local release = util.trim(fs.readfile('/lib/gluon/release'))
|
|
|
+local contact = uci:get_first('gluon-node-info', 'owner', 'contact', 'none')
|
|
|
+
|
|
|
local autoupdater = uci:get('autoupdater', 'settings', 'branch')
|
|
|
-if uci:get_bool('autoupdater', 'settings', 'enabled') == false then
|
|
|
- autoupdater = "disabled (" .. autoupdater .. ")"
|
|
|
+if not uci:get_bool('autoupdater', 'settings', 'enabled') then
|
|
|
+ autoupdater = 'disabled (' .. autoupdater .. ')'
|
|
|
end
|
|
|
|
|
|
-local addresses = ""
|
|
|
+local addresses = ''
|
|
|
for line in io.lines('/proc/net/if_inet6') do
|
|
|
local matches = { line:match('^' .. string.rep('(%x%x%x%x)', 8) .. string.rep(' %x%x', 4) .. '%s+([^%s]+)$') }
|
|
|
- if matches[9] == 'local-node' then
|
|
|
- addresses = addresses .. " " .. ip.IPv6(string.format('%s:%s:%s:%s:%s:%s:%s:%s', unpack(matches))):string():lower() .. "\n"
|
|
|
+ if matches[9] == 'br-client' then
|
|
|
+ addresses = addresses .. ' ' .. string.format('%s:%s:%s:%s:%s:%s:%s:%s', unpack(matches)) .. '\n'
|
|
|
end
|
|
|
end
|
|
|
|
|
@@ -44,6 +41,9 @@ for k, v in data:gmatch('([^\n:]+):%s*(%d+) kB') do
|
|
|
fields[k] = tonumber(v)
|
|
|
end
|
|
|
|
|
|
+local pubkey = util.trim(io.popen('/etc/init.d/fastd show_key mesh_vpn'):read('*a'))
|
|
|
+if pubkey == '' then pubkey = 'none' end
|
|
|
+
|
|
|
local function location()
|
|
|
local text = 'none'
|
|
|
local locationid = uci:get_first('gluon-node-info', 'location')
|
|
@@ -109,10 +109,11 @@ if oldReport==nil then
|
|
|
debugdata = debugdata .. "Firmware: " .. release .. " / " .. version .. "\n"
|
|
|
debugdata = debugdata .. "MAC: " .. primary_mac .. "\n"
|
|
|
debugdata = debugdata .. "Contact: " .. contact .. "\n"
|
|
|
- debugdata = debugdata .. "Uptime: " .. util.trim(sys.exec("uptime | sed 's/^ \+//'")) .. "\n"
|
|
|
+ debugdata = debugdata .. "Uptime: " .. util.trim(io.popen("uptime | sed 's/^ \+//'"):read('*a')) .. '\n'
|
|
|
debugdata = debugdata .. "Autoupdater: " .. autoupdater .. "\n"
|
|
|
debugdata = debugdata .. "Location: " .. location() .. "\n"
|
|
|
debugdata = debugdata .. "IPs: " .. util.trim(addresses) .. "\n"
|
|
|
+ debugdata = debugdata .. 'Pubkey: ' .. pubkey .. '\n'
|
|
|
debugdata = debugdata .. "Memory: " .. string.format("%.1f %% used, %.1f %% free\n",(fields.MemTotal-fields.MemFree)/fields.MemTotal*100,fields.MemFree/fields.MemTotal*100)
|
|
|
|
|
|
debugdata = debugdata .. cmd("ps w")
|
|
@@ -137,8 +138,8 @@ if oldReport==nil then
|
|
|
|
|
|
-- get wireless status
|
|
|
debugdata = debugdata .. "---- BEGIN WIRELESS INFORMATION ----\n"
|
|
|
- local interfaces = util.split(util.trim(util.exec("iw dev | grep Interface | cut -d' ' -f2")))
|
|
|
- for _, ifname in ipairs(interfaces) do
|
|
|
+ local interfaces = io.popen("iw dev | grep Interface | cut -d' ' -f2"):read('*a')
|
|
|
+ for ifname in interfaces:gmatch('%S+') do
|
|
|
debugdata = debugdata .. cmd("iwinfo " .. ifname .. " info 2>&1")
|
|
|
if ifname:match('ibss') or ifname:match('mesh') then
|
|
|
debugdata = debugdata .. cmd("iwinfo " .. ifname .. " assoclist 2>&1")
|
|
@@ -154,13 +155,13 @@ if oldReport==nil then
|
|
|
|
|
|
-- get fastd status
|
|
|
debugdata = debugdata .. "---- BEGIN FASTD STATUS ----\n"
|
|
|
- if string.len(util.exec("ip -f inet address show dev br-wan | grep global")) >= 2 then
|
|
|
+ if string.len(io.popen("ip -f inet address show dev br-wan | grep global"):read('*a')) >= 2 then
|
|
|
debugdata = debugdata .. "IPv4 configured\n"
|
|
|
else
|
|
|
debugdata = debugdata .. "IPv4 not configured\n"
|
|
|
end
|
|
|
|
|
|
- if string.len(util.exec("ip -f inet6 address show dev br-wan | grep global")) >= 2 then
|
|
|
+ if string.len(io.popen("ip -f inet6 address show dev br-wan | grep global"):read('*a')) >= 2 then
|
|
|
debugdata = debugdata .. "IPv6 configured\n"
|
|
|
else
|
|
|
debugdata = debugdata .. "IPv6 not configured\n"
|
|
@@ -171,9 +172,16 @@ if oldReport==nil then
|
|
|
local fastd_sock = nixio.socket('unix', 'stream')
|
|
|
assert(fastd_sock:connect('/var/run/fastd.mesh_vpn.socket'))
|
|
|
|
|
|
- decoder = json.new()
|
|
|
- ltn12.pump.all(ltn12.source.file(fastd_sock), decoder:sink())
|
|
|
- return decoder:get()
|
|
|
+ local decoder = json.new()
|
|
|
+ local sink = decoder:sink()
|
|
|
+
|
|
|
+ while true do
|
|
|
+ local chunk = fastd_sock:read(2048)
|
|
|
+ if not chunk or chunk:len() == 0 then break end
|
|
|
+ sink(chunk)
|
|
|
+ end
|
|
|
+
|
|
|
+ return assert(decoder:get())
|
|
|
end
|
|
|
)
|
|
|
|
|
@@ -226,7 +234,6 @@ if localMode then
|
|
|
print(debugdata)
|
|
|
nixio.fs.unlink(PATH_DBG_REPORT)
|
|
|
else
|
|
|
- local nixio = require('nixio'), require('nixio.util')
|
|
|
print('-- My User has information that could... that could make this a free system again!')
|
|
|
local sent = 0
|
|
|
local reportname = nil
|