gluon-legacy: convert the remaining legacy scripts to invariant scripts

This commit is contained in:
Matthias Schiffer 2015-01-23 05:51:13 +01:00
parent 5e0bad2f25
commit 0371b443d3
6 changed files with 88 additions and 82 deletions

View File

@ -0,0 +1,37 @@
#!/usr/bin/lua
local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig'
local uci = require('luci.model.uci').cursor()
if sysconfig.gluon_version == 'legacy' then
local secret
local enabled
for _, config in ipairs(site.legacy.fastd_configs) do
if not secret then
local s = uci:get_all('fastd', config)
if s then
secret = s.secret
enabled = s.enabled
end
end
uci:delete('fastd', config)
end
if secret then
uci:section('fastd', 'fastd', 'mesh_vpn',
{
secret = secret,
enabled = enabled,
}
)
end
uci:save('fastd')
uci:commit('fastd')
end

View File

@ -1,35 +0,0 @@
#!/usr/bin/lua
local site = require 'gluon.site_config'
local uci = require 'luci.model.uci'
local c = uci.cursor()
local secret
local enabled
for _, config in ipairs(site.legacy.fastd_configs) do
if not secret then
local s = c:get_all('fastd', config)
if s then
secret = s.secret
enabled = s.enabled
end
end
c:delete('fastd', config)
end
if secret then
c:section('fastd', 'fastd', 'mesh_vpn',
{
secret = secret,
enabled = enabled,
}
)
end
c:save('fastd')
c:commit('fastd')

View File

@ -0,0 +1,22 @@
#!/usr/bin/lua
local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig'
local uci = require('luci.model.uci').cursor()
if sysconfig.gluon_version == 'legacy' then
for _, config in ipairs(site.legacy.config_mode_configs) do
local old = uci:get_first(config, 'wizard', 'configured')
if old == '1' then
local setup_mode = uci:get_first('gluon-setup-mode', 'setup_mode')
uci:set('gluon-setup-mode', setup_mode, 'configured', '1')
uci:save('gluon-setup-mode')
uci:commit('gluon-setup-mode')
break
end
end
end

View File

@ -1,20 +0,0 @@
#!/usr/bin/lua
local site = require 'gluon.site_config'
local uci = require 'luci.model.uci'
local c = uci.cursor()
for _, config in ipairs(site.legacy.config_mode_configs) do
local old = c:get_first(config, 'wizard', 'configured')
if old == '1' then
local setup_mode = c:get_first('gluon-setup-mode', 'setup_mode')
c:set('gluon-setup-mode', setup_mode, 'configured', '1')
c:save('gluon-setup-mode')
c:commit('gluon-setup-mode')
break
end
end

View File

@ -0,0 +1,29 @@
#!/usr/bin/lua
local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig'
local uci = require('luci.model.uci').cursor()
if sysconfig.gluon_version == 'legacy' then
for _, config in ipairs(site.legacy.tc_configs) do
local s = uci:get_first(config, 'bandwidth')
if s then
old = uci:get_all(config, s)
uci:section('gluon-simple-tc', 'interface', 'mesh_vpn',
{
ifname = 'mesh-vpn',
enabled = old.enabled,
limit_ingress = old.downstream,
limit_egress = old.upstream,
}
)
uci:save('gluon-simple-tc')
uci:commit('gluon-simple-tc')
break
end
end
end

View File

@ -1,27 +0,0 @@
#!/usr/bin/lua
local site = require 'gluon.site_config'
local uci = require 'luci.model.uci'
local c = uci.cursor()
for _, config in ipairs(site.legacy.tc_configs) do
local s = c:get_first(config, 'bandwidth')
if s then
old = c:get_all(config, s)
c:section('gluon-simple-tc', 'interface', 'mesh_vpn',
{
ifname = 'mesh-vpn',
enabled = old.enabled,
limit_ingress = old.downstream,
limit_egress = old.upstream,
}
)
c:save('gluon-simple-tc')
c:commit('gluon-simple-tc')
break
end
end