Merge pull request #94 from freifunk-gluon/simple_upgrade
Simplified upgrade process
This commit is contained in:
commit
89e14fccac
|
@ -1,67 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
UPGRADE_DIR=/lib/gluon/upgrade
|
||||
VERSION_DIR=/lib/gluon/version
|
||||
|
||||
|
||||
if [ -x /lib/gluon/legacy/legacy-upgrade ] && /lib/gluon/legacy/legacy-upgrade; then
|
||||
HAS_LEGACY=1
|
||||
else
|
||||
HAS_LEGACY=
|
||||
fi
|
||||
|
||||
mkdir -p "$VERSION_DIR"
|
||||
|
||||
|
||||
version_of() {
|
||||
opkg status "gluon-$1" | awk '/^Version: / { print $2 }'
|
||||
}
|
||||
|
||||
oldversion_of() {
|
||||
cat "$VERSION_DIR"/"$1" 2>/dev/null
|
||||
}
|
||||
|
||||
do_dir() {
|
||||
[ -d "$1" ] || return
|
||||
|
||||
local s
|
||||
for s in "$1"/*; do "$s"; done
|
||||
}
|
||||
|
||||
do_component() {
|
||||
local component="$1"
|
||||
local version="$(version_of "$component")"
|
||||
[ "$version" ] || continue
|
||||
|
||||
(
|
||||
cd "$component"
|
||||
|
||||
local oldversion="$(oldversion_of "$component")"
|
||||
if [ -z "$oldversion" ]; then
|
||||
if [ "$HAS_LEGACY" ]; then
|
||||
do_dir legacy
|
||||
else
|
||||
do_dir initial
|
||||
fi
|
||||
fi
|
||||
|
||||
do_dir invariant
|
||||
|
||||
echo "$version" > "$VERSION_DIR"/"$component"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
cd "$UPGRADE_DIR"
|
||||
|
||||
do_component core
|
||||
|
||||
for component in *; do
|
||||
[ "$component" != 'core' ] || continue
|
||||
do_component "$component"
|
||||
for script in /lib/gluon/upgrade/*; do
|
||||
"$script"
|
||||
done
|
||||
|
||||
if [ "$HAS_LEGACY" ]; then
|
||||
/lib/gluon/legacy/legacy-upgrade-late
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local fs = require 'luci.fs'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
|
||||
if fs.isfile('/lib/gluon/version/core') and not sysconfig.gluon_version then
|
||||
-- This isn't an initial upgrade, so set gluon_version
|
||||
sysconfig.gluon_version = ''
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local platform = require 'gluon.platform'
|
||||
|
||||
local fs = require 'luci.fs'
|
||||
local util = require 'luci.util'
|
||||
|
||||
|
||||
if not sysconfig.primary_mac then
|
||||
if platform.match('ar71xx', 'generic', {'tl-wdr3600', 'tl-wdr4300'}) then
|
||||
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
|
||||
else
|
||||
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress'))
|
||||
end
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local gluon_util = require 'gluon.util'
|
||||
local platform = require 'gluon.platform'
|
||||
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
|
||||
if not (sysconfig.lan_ifname or sysconfig.wan_ifname) then
|
||||
local function iface_exists(name)
|
||||
return (gluon_util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0)
|
||||
end
|
||||
|
||||
|
||||
local lan_ifname = uci:get('network', 'lan', 'ifname')
|
||||
local wan_ifname = uci:get('network', 'wan', 'ifname')
|
||||
|
||||
if platform.match('ar71xx', 'generic', {'cpe510', 'nanostation-m', 'nanostation-m-xw'}) then
|
||||
lan_ifname, wan_ifname = wan_ifname, lan_ifname
|
||||
end
|
||||
|
||||
if wan_ifname and iface_exists(wan_ifname) then
|
||||
sysconfig.wan_ifname = wan_ifname
|
||||
sysconfig.lan_ifname = lan_ifname
|
||||
else
|
||||
sysconfig.wan_ifname = lan_ifname
|
||||
end
|
||||
|
||||
|
||||
uci:delete('network', 'lan')
|
||||
uci:delete('network', 'wan')
|
||||
|
||||
uci:save('network')
|
||||
uci:commit('network')
|
||||
end
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
-- Initial
|
||||
if not sysconfig.gluon_version then
|
||||
local site = require 'gluon.site_config'
|
||||
local util = require 'gluon.util'
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
local system = uci:get_first('system', 'system')
|
||||
|
||||
uci:set('system', system, 'hostname', site.hostname_prefix .. '-' .. util.node_id())
|
||||
uci:set('system', system, 'timezone', site.timezone)
|
||||
|
||||
uci:save('system')
|
||||
uci:commit('system')
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
-- Initial
|
||||
if not sysconfig.gluon_version then
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
uci:delete_all('wireless', 'wifi-iface')
|
||||
uci:save('wireless')
|
||||
uci:commit('wireless')
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
local fs = require 'luci.fs'
|
||||
local util = require 'luci.util'
|
||||
|
||||
|
||||
-- Save the Gluon version in the sysconfig so we know which version we
|
||||
-- upgraded from after the next upgrade
|
||||
sysconfig.gluon_version = util.trim(fs.readfile('/lib/gluon/gluon-version'))
|
|
@ -1,38 +0,0 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local gluon_util = require 'gluon.util'
|
||||
local platform = require 'gluon.platform'
|
||||
|
||||
local fs = require 'luci.fs'
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
local util = require 'luci.util'
|
||||
|
||||
|
||||
if platform.match('ar71xx', 'generic', {'tl-wdr3600', 'tl-wdr4300'}) then
|
||||
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
|
||||
else
|
||||
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress'))
|
||||
end
|
||||
|
||||
|
||||
local function iface_exists(name)
|
||||
return (gluon_util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0)
|
||||
end
|
||||
|
||||
|
||||
local lan_ifname = uci:get('network', 'lan', 'ifname')
|
||||
local wan_ifname = uci:get('network', 'wan', 'ifname')
|
||||
|
||||
|
||||
if platform.match('ar71xx', 'generic', {'cpe510', 'nanostation-m', 'nanostation-m-xw'}) then
|
||||
lan_ifname, wan_ifname = wan_ifname, lan_ifname
|
||||
end
|
||||
|
||||
|
||||
if wan_ifname and iface_exists(wan_ifname) then
|
||||
sysconfig.wan_ifname = wan_ifname
|
||||
sysconfig.lan_ifname = lan_ifname
|
||||
else
|
||||
sysconfig.wan_ifname = lan_ifname
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
local util = require 'gluon.util'
|
||||
local uci = require 'luci.model.uci'
|
||||
|
||||
local c = uci.cursor()
|
||||
local system = c:get_first('system', 'system')
|
||||
|
||||
c:set('system', system, 'hostname', site.hostname_prefix .. '-' .. util.node_id())
|
||||
c:set('system', system, 'timezone', site.timezone)
|
||||
|
||||
c:save('system')
|
||||
c:commit('system')
|
|
@ -1,9 +0,0 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
uci:delete('network', 'lan')
|
||||
uci:delete('network', 'wan')
|
||||
|
||||
uci:save('network')
|
||||
uci:commit('network')
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
uci:delete_all('wireless', 'wifi-iface')
|
||||
uci:save('wireless')
|
||||
uci:commit('wireless')
|
|
@ -1,3 +1 @@
|
|||
/lib/gluon/version/
|
||||
|
||||
/lib/gluon/core/sysconfig/
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
|
||||
local ret = 1
|
||||
|
||||
for _, file in ipairs(site.legacy.version_files) do
|
||||
if os.remove(file) then
|
||||
ret = 0
|
||||
end
|
||||
end
|
||||
|
||||
os.exit(ret)
|
|
@ -1,8 +0,0 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
|
||||
|
||||
for _, file in ipairs(site.legacy.old_files) do
|
||||
os.remove(file)
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
for _, file in ipairs(site.legacy.version_files) do
|
||||
if os.remove(file) then
|
||||
-- Set version being upgraded from to 'legacy'
|
||||
sysconfig.gluon_version = 'legacy'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local gluon_util = require 'gluon.util'
|
||||
local platform = require 'gluon.platform'
|
||||
local site = require 'gluon.site_config'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
local util = require 'luci.util'
|
||||
|
||||
|
||||
if sysconfig.gluon_version == 'legacy' then
|
||||
local function iface_exists(name)
|
||||
return (gluon_util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0)
|
||||
end
|
||||
|
||||
local function remove_bat0(iface)
|
||||
return util.trim(string.gsub(' ' .. iface .. ' ', ' bat0 ', ' '))
|
||||
end
|
||||
|
||||
|
||||
local lan_ifname = remove_bat0(uci:get('network', site.legacy.mesh_ifname, 'ifname'))
|
||||
local wan_ifname = uci:get('network', 'wan', 'ifname')
|
||||
|
||||
if wan_ifname and iface_exists(wan_ifname) then
|
||||
sysconfig.wan_ifname = wan_ifname
|
||||
sysconfig.lan_ifname = lan_ifname
|
||||
else
|
||||
sysconfig.wan_ifname = lan_ifname
|
||||
end
|
||||
|
||||
|
||||
uci:delete('network', site.legacy.mesh_ifname)
|
||||
uci:delete('network', 'wan')
|
||||
|
||||
uci:save('network')
|
||||
uci:commit('network')
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#!/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
|
||||
function delete_legacy_iface(iface)
|
||||
for _, wifi in pairs(site.legacy.wifi_names) do
|
||||
if wifi == iface['.name'] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
uci:delete_all('wireless', 'wifi-iface', delete_legacy_iface)
|
||||
|
||||
uci:save('wireless')
|
||||
uci:commit('wireless')
|
||||
end
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
|
||||
if sysconfig.gluon_version == 'legacy' then
|
||||
for _, file in ipairs(site.legacy.old_files) do
|
||||
os.remove(file)
|
||||
end
|
||||
end
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local gluon_util = require 'gluon.util'
|
||||
local platform = require 'gluon.platform'
|
||||
|
||||
local fs = require 'luci.fs'
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
local util = require 'luci.util'
|
||||
|
||||
|
||||
if platform.match('ar71xx', 'generic', {'tl-wdr3600', 'tl-wdr4300'}) then
|
||||
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
|
||||
else
|
||||
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress'))
|
||||
end
|
||||
|
||||
|
||||
local function iface_exists(name)
|
||||
return (gluon_util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0)
|
||||
end
|
||||
|
||||
local function remove_bat0(iface)
|
||||
return util.trim(string.gsub(' ' .. iface .. ' ', ' bat0 ', ' '))
|
||||
end
|
||||
|
||||
|
||||
local lan_ifname = remove_bat0(uci:get('network', site.legacy.mesh_ifname, 'ifname'))
|
||||
local wan_ifname = uci:get('network', 'wan', 'ifname')
|
||||
|
||||
|
||||
if wan_ifname and iface_exists(wan_ifname) then
|
||||
sysconfig.wan_ifname = wan_ifname
|
||||
sysconfig.lan_ifname = lan_ifname
|
||||
else
|
||||
sysconfig.wan_ifname = lan_ifname
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
local uci = require 'luci.model.uci'
|
||||
|
||||
|
||||
local c = uci.cursor()
|
||||
|
||||
|
||||
function delete_legacy_iface(iface)
|
||||
for _, wifi in pairs(site.legacy.wifi_names) do
|
||||
if wifi == iface['.name'] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
c:delete_all('wireless', 'wifi-iface', delete_legacy_iface)
|
||||
|
||||
c:save('wireless')
|
||||
c:commit('wireless')
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
has_root_pwd() {
|
||||
local pwd=$([ -f "$1" ] && cat "$1")
|
||||
pwd="${pwd#*root:}"
|
||||
pwd="${pwd%%:*}"
|
||||
|
||||
test -n "${pwd#[\!x]}"
|
||||
}
|
||||
|
||||
|
||||
has_root_pwd /etc/passwd || has_root_pwd /etc/shadow || passwd -l root
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
local uci = require 'luci.model.uci'
|
||||
|
||||
local c = uci.cursor()
|
||||
|
||||
|
||||
local s = c:get_all('network', site.legacy.mesh_ifname)
|
||||
c:delete('network', site.legacy.mesh_ifname)
|
||||
|
||||
s.auto = nil
|
||||
s.accept_ra = nil
|
||||
s.defaultroute = nil
|
||||
s.proto = 'dhcpv6'
|
||||
s.reqprefix = 'no'
|
||||
|
||||
c:section('network', 'interface', 'client', s)
|
||||
|
||||
c:save('network')
|
||||
c:commit('network')
|
|
@ -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')
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
has_root_pwd() {
|
||||
local pwd
|
||||
|
||||
pwd=$([ -f "$1" ] && cat "$1")
|
||||
pwd="${pwd#*root:}"
|
||||
pwd="${pwd%%:*}"
|
||||
|
||||
test -n "${pwd}"
|
||||
}
|
||||
|
||||
has_root_pwd /etc/shadow || passwd -l root
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
passwd -l root
|
|
@ -4,9 +4,7 @@ local site = require 'gluon.site_config'
|
|||
local users = require 'gluon.users'
|
||||
local util = require 'gluon.util'
|
||||
|
||||
local uci = require 'luci.model.uci'
|
||||
|
||||
local c = uci.cursor()
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
|
||||
-- The previously used user is removed, we need root privileges to use the packet_mark option
|
||||
|
@ -16,23 +14,30 @@ users.remove_user('gluon-fastd')
|
|||
users.add_group('gluon-fastd', 800)
|
||||
|
||||
|
||||
c:section('fastd', 'fastd', 'mesh_vpn',
|
||||
local enabled = uci:get('fastd', 'mesh_vpn', 'enabled')
|
||||
if not enabled then
|
||||
enabled = site.fastd_mesh_vpn.enabled and 1 or 0
|
||||
end
|
||||
|
||||
|
||||
uci:section('fastd', 'fastd', 'mesh_vpn',
|
||||
{
|
||||
enabled = enabled,
|
||||
group = 'gluon-fastd',
|
||||
syslog_level = 'verbose',
|
||||
interface = 'mesh-vpn',
|
||||
mode = 'tap',
|
||||
mtu = site.fastd_mesh_vpn.mtu,
|
||||
secure_handshakes = '1',
|
||||
secure_handshakes = 1,
|
||||
method = site.fastd_mesh_vpn.methods,
|
||||
packet_mark = 1,
|
||||
status_socket = '/var/run/fastd.mesh_vpn.socket',
|
||||
}
|
||||
)
|
||||
c:delete('fastd', 'mesh_vpn', 'user')
|
||||
uci:delete('fastd', 'mesh_vpn', 'user')
|
||||
|
||||
c:delete('fastd', 'mesh_vpn_backbone')
|
||||
c:section('fastd', 'peer_group', 'mesh_vpn_backbone',
|
||||
uci:delete('fastd', 'mesh_vpn_backbone')
|
||||
uci:section('fastd', 'peer_group', 'mesh_vpn_backbone',
|
||||
{
|
||||
enabled = 1,
|
||||
net = 'mesh_vpn',
|
||||
|
@ -40,14 +45,14 @@ c:section('fastd', 'peer_group', 'mesh_vpn_backbone',
|
|||
}
|
||||
)
|
||||
|
||||
c:delete_all('fastd', 'peer',
|
||||
uci:delete_all('fastd', 'peer',
|
||||
function(peer)
|
||||
return peer.net == 'mesh_vpn' and peer.group == 'mesh_vpn_backbone'
|
||||
end
|
||||
)
|
||||
|
||||
for name, config in pairs(site.fastd_mesh_vpn.backbone.peers) do
|
||||
c:section('fastd', 'peer', 'mesh_vpn_backbone_peer_' .. name,
|
||||
uci:section('fastd', 'peer', 'mesh_vpn_backbone_peer_' .. name,
|
||||
{
|
||||
enabled = 1,
|
||||
net = 'mesh_vpn',
|
||||
|
@ -58,11 +63,11 @@ for name, config in pairs(site.fastd_mesh_vpn.backbone.peers) do
|
|||
)
|
||||
end
|
||||
|
||||
c:save('fastd')
|
||||
c:commit('fastd')
|
||||
uci:save('fastd')
|
||||
uci:commit('fastd')
|
||||
|
||||
|
||||
c:section('network', 'interface', 'mesh_vpn',
|
||||
uci:section('network', 'interface', 'mesh_vpn',
|
||||
{
|
||||
ifname = 'mesh-vpn',
|
||||
proto = 'batadv',
|
||||
|
@ -72,11 +77,11 @@ c:section('network', 'interface', 'mesh_vpn',
|
|||
}
|
||||
)
|
||||
|
||||
c:save('network')
|
||||
c:commit('network')
|
||||
uci:save('network')
|
||||
uci:commit('network')
|
||||
|
||||
|
||||
c:section('firewall', 'include', 'mesh_vpn_dns',
|
||||
uci:section('firewall', 'include', 'mesh_vpn_dns',
|
||||
{
|
||||
type = 'restore',
|
||||
path = '/lib/gluon/mesh-vpn-fastd/iptables.rules',
|
||||
|
@ -84,5 +89,5 @@ c:section('firewall', 'include', 'mesh_vpn_dns',
|
|||
}
|
||||
)
|
||||
|
||||
c:save('firewall')
|
||||
c:commit('firewall')
|
||||
uci:save('firewall')
|
||||
uci:commit('firewall')
|
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
local uci = require 'luci.model.uci'
|
||||
local c = uci.cursor()
|
||||
|
||||
c:section('fastd', 'fastd', 'mesh_vpn',
|
||||
{
|
||||
enabled = site.fastd_mesh_vpn.enabled and 1 or 0
|
||||
}
|
||||
)
|
||||
|
||||
c:save('fastd')
|
||||
c:commit('fastd')
|
Loading…
Reference in New Issue