Skip to content
Snippets Groups Projects
Commit bd941aad authored by Jan-Tarek Butt's avatar Jan-Tarek Butt
Browse files

change sequence of working and add update function

parent f8789776
No related branches found
No related tags found
No related merge requests found
...@@ -331,35 +331,38 @@ end ...@@ -331,35 +331,38 @@ end
local jhood = readhoodfile(file) local jhood = readhoodfile(file)
if jhood ~= nil then if jhood ~= nil then
local radios = get_wifi_devices() local radios = get_wifi_devices()
local geo = get_geolocation() if get_gw_range() then
if geo[1] ~= nil or geo[2] ~= nil then -- check if fastd running
local geo_hood = gethood_by_geo(jhood, geo) if ( uci:get('fastd', 'mesh_vpn', 'enabled') == '1' ) then
if geo_hood ~= nil then os.execute('/etc/init.d/fastd start')
local no_error = set_hoodconfig(geo_hood,radios) end
if no_error then local geo = get_geolocation()
io.stderr:write('Setting hood getting from position.\n') if geo[1] ~= nil or geo[2] ~= nil then
local geo_hood = gethood_by_geo(jhood, geo)
if geo_hood ~= nil then
local no_error = set_hoodconfig(geo_hood,radios)
if no_error then
io.stderr:write('Setting hood getting from position.\n')
exit()
end
io.stderr:write('Error while setting new hood getting by geoposition.\n')
exit() exit()
end end
io.stderr:write('Error while setting new hood getting by geoposition.\n') io.stderr:write('No hood has been defined for current position.\n')
exit() local defaultHood = get_default_hood(jhood)
end if defaultHood ~= nil then
io.stderr:write('No hood has been defined for current position.\n') local no_error = set_hoodconfig(defaultHood, radios)
local defaultHood = get_default_hood(jhood) if no_error then
if defaultHood ~= nil then io.stderr:write('Setting defaulthood.\n')
local no_error = set_hoodconfig(defaultHood, radios) exit()
if no_error then end
io.stderr:write('Setting defaulthood.\n') io.stderr:write('Error while setting defaulthood.\n')
exit() exit()
end end
io.stderr:write('Error while setting defaulthood.\n') io.stderr:write('No defaulthood has been defined.\n')
exit() exit()
end end
io.stderr:write('No defaulthood has been defined.\n') io.stderr:write('Router dont have a position.\n')
exit()
end
io.stderr:write('Router dont have a position.\n')
if get_gw_range() then
exit()
end end
if next(radios) then if next(radios) then
local scan_bssid = get_neigbour_bssid(radios) local scan_bssid = get_neigbour_bssid(radios)
...@@ -375,6 +378,29 @@ if jhood ~= nil then ...@@ -375,6 +378,29 @@ if jhood ~= nil then
exit() exit()
end end
io.stderr:write('No hood has been defined for scanned bssid.\n') io.stderr:write('No hood has been defined for scanned bssid.\n')
-- Stop fastd
os.execute('/etc/init.d/fastd stop')
-- Set BSSID without hood
local if_change = false
for index, radio in ipairs(radios) do
if not ( uci:get('wireless', 'ibss_' .. radio, 'bssid') == scan_bssid ) then
uci:section('wireless', 'wifi-iface', 'ibss_' .. radio,
{
bssid = scan_bssid
}
)
if_change = true
end
end
if if_change then
uci:save('wireless')
uci:commit('wireless')
os.execute('wifi')
end
-- Wait 15 seconds while meshing its creates
os.execute("sleep " .. tonumber(17))
-- run autoupdater in backround and exit hoodselector
os.execute('autoupdater -f &')
exit() exit()
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment