12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #!/usr/bin/lua
- local uci = require('simple-uci').cursor()
- local fs = require 'nixio.fs'
- local enabled
- if uci:get('autoupdater-wifi-fallback', 'settings') then
- enabled = uci:get_bool('autoupdater-wifi-fallback', 'settings', 'enabled')
- uci:delete('autoupdater-wifi-fallback', 'settings')
- else
- enabled = uci:get_bool('autoupdater', 'settings', 'enabled')
- end
- uci:section('autoupdater-wifi-fallback', 'autoupdater-wifi-fallback', 'settings',{
- enabled = enabled,
- })
- uci:delete('wireless', 'fallback')
- uci:delete('network', 'fallback')
- uci:delete('network', 'fallback6')
- uci:section('network', 'interface', 'fallback',{
- proto = 'dhcp',
- peerdns = true,
- sourcefilter = false,
- })
- uci:section('network', 'interface', 'fallback6',{
- ifname = '@fallback',
- proto = 'dhcpv6',
- peerdns = true,
- sourcefilter = false,
- })
- uci:save('autoupdater-wifi-fallback')
- uci:save('network')
- uci:save('wireless')
- local minute = tonumber(fs.readfile('/usr/lib/micron.d/autoupdater'):match('^([0-9][0-9]?)%s'))
- minute = (minute + 10) % 60
- local f = io.open('/usr/lib/micron.d/autoupdater-wifi-fallback', 'w')
- f:write(string.format('%i * * * * /usr/sbin/autoupdater-wifi-fallback\n', minute))
- f:close()
|