73 lines
1.7 KiB
Lua
Executable File
73 lines
1.7 KiB
Lua
Executable File
#!/usr/bin/lua
|
|
|
|
local uci = require('simple-uci').cursor()
|
|
local site = require 'gluon.site'
|
|
local util = require 'gluon.util'
|
|
local wireless = require 'gluon.wireless'
|
|
local sysconfig = require 'gluon.sysconfig'
|
|
local util = require 'gluon.util'
|
|
local olsrd = require 'gluon.olsrd'
|
|
|
|
uci:delete('openvpn', 'olsr12_vpn')
|
|
|
|
-- NOTE: we need to place olsr12 files in a persistent directory,
|
|
-- since reconfigure only happens on upgrades
|
|
-- Since it happens on upgrades tho, we do not need to store it
|
|
-- in a permanent directory like /etc/openvpn
|
|
|
|
if site.mesh.olsrd.olsr12.enable() then
|
|
-- TODO: gluon_wired once added in mesh-olsrd
|
|
uci:section('network', 'interface', 'olsr12', {
|
|
ifname = 'olsr12',
|
|
proto = 'tap',
|
|
zone = 'mesh',
|
|
})
|
|
|
|
local cred = io.open('/etc/olsr12.auth', 'w')
|
|
cred:write(sysconfig.primary_mac .. '\n' .. sysconfig.primary_mac .. '\n')
|
|
cred:close()
|
|
|
|
local ca = io.open('/etc/olsr12.ca', 'w')
|
|
ca:write(site.mesh.olsrd.olsr12.ca())
|
|
ca:close()
|
|
|
|
uci:section('openvpn', 'openvpn', 'olsr12_vpn', {
|
|
enabled = true,
|
|
client = true,
|
|
|
|
dev = 'olsr12',
|
|
dev_type = 'tap',
|
|
|
|
data_ciphers_fallback = 'none',
|
|
persist_key = true,
|
|
persist_tun = true,
|
|
|
|
ca = '/etc/olsr12.ca',
|
|
|
|
verb = 3,
|
|
|
|
remote = {
|
|
site.mesh.olsrd.olsr12.server() .. " " .. site.mesh.olsrd.olsr12.port(1194)
|
|
},
|
|
|
|
auth_user_pass = '/etc/olsr12.auth',
|
|
})
|
|
|
|
uci:section('olsrd2', 'interface', 'olsr12_mesh', {
|
|
ifname = { 'olsr12' },
|
|
bindto = uci:get_list('olsrd2', 'wired_mesh', 'bindto'),
|
|
-- TODO: link quality
|
|
})
|
|
|
|
local intfs = uci:get_list('firewall', 'mesh', 'network')
|
|
|
|
table.insert(intfs, 'olsr12')
|
|
|
|
uci:set_list('firewall', 'mesh', 'network', intfs)
|
|
end
|
|
|
|
uci:save('olsrd2')
|
|
uci:save('firewall')
|
|
uci:save('network')
|
|
uci:save('openvpn')
|