Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ffbs
ffbs-packages
Commits
447490a0
Commit
447490a0
authored
May 30, 2021
by
chrissi^
Browse files
autoupdater-wifi-fallback: Make more verbose
parent
c1488f91
Changes
1
Hide whitespace changes
Inline
Side-by-side
gluon-ffbs-autoupdater-wifi-fallback/luasrc/usr/sbin/autoupdater-wifi-fallback
View file @
447490a0
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment