Commit 447490a0 authored by chrissi^'s avatar chrissi^
Browse files

autoupdater-wifi-fallback: Make more verbose

parent c1488f91
......@@ -32,14 +32,20 @@ end
local function preflight_check()
if not uci:get_bool(configname, 'settings', 'enabled') then
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "preflight: wifi-fallback not enabled"')
return false
end
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "preflight: wifi-fallback enabled"')
if not uci:get_bool('autoupdater', 'settings', 'enabled') then
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "preflight: autoupdater not enabled"')
return false
end
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "preflight: autoupdater enabled"')
if tonumber(autil.read_file('/proc/uptime'):match('^([^ ]+) ')) < min_uptime_secs then
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "preflight: uptime too short"')
return false
end
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "preflight: uptime long enough"')
return true
end
......@@ -48,6 +54,7 @@ local function connectivity_check()
-- connectivity check against updateserver
for _, host in ipairs(autil.get_update_hosts(branch_name)) do
if os.execute('ping -w2 -c1 ' .. host .. ' > /dev/null 2>&1') == 0 then
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "Connectivity Check: Success"')
return true
end
end
......@@ -103,7 +110,13 @@ if not uci:get('autoupdater', branch_name) then
os.exit(1)
end
if (force or preflight_check()) and not connectivity_check() then
pfc = preflight_check()
coc = connectivity_check()
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "args:force=' .. tostring(force) .. '"')
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "preflight_check()=' .. tostring(pfc) .. '"')
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "connectivity_check()=' .. tostring(coc) .. '"')
if (force or pfc) and not coc then
local offset = 2 * 3600
local unreachable_since = os.time()
if not uci:get('autoupdater-wifi-fallback', 'settings', 'unreachable_since') then
......@@ -128,6 +141,7 @@ if (force or preflight_check()) and not connectivity_check() then
revert_to_standard_mode()
end
else
io.popen('logger -s -t autoupdater-wifi-fallback -p local0.info "Nothing to do. Cleaning up."')
uci:delete(configname, 'settings', 'unreachable_since')
uci:delete(configname, 'settings', 'last_run')
uci:save(configname)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment