1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #!/usr/bin/lua
- local uci = require 'luci.model.uci'.cursor()
- local util = require 'gluon.util'
- local fs = require('nixio.fs')
- local enabled = uci:get('autoupdater','settings','enabled')
- if uci:get('autoupdater-wifi-fallback', 'settings') then
- enabled = uci:get_bool('autoupdater-wifi-fallback', 'settings', 'enabled') and 1 or 0
- uci:delete('autoupdater-wifi-fallback', 'settings')
- end
- uci:section('autoupdater-wifi-fallback','autoupdater-wifi-fallback','settings',
- {
- enabled = enabled,
- }
- )
- uci:delete('wireless', 'fallback')
- uci:delete('network','fallback')
- uci:section('network', 'interface', 'fallback',
- {
- ifname = 'fallback',
- }
- )
- uci:save('autoupdater-wifi-fallback')
- uci:save('network')
- uci:save('wireless')
- uci:commit('autoupdater-wifi-fallback')
- uci:commit('network')
- uci:commit('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()
|