gluon/package/gluon-mesh-vpn-openvpn/luasrc/lib/gluon/upgrade/400-mesh-vpn-openvpn
2022-08-11 11:13:44 +02:00

29 lines
570 B
Lua
Executable File

#!/usr/bin/lua
local site = require 'gluon.site'
local util = require 'gluon.util'
local vpn_core = require 'gluon.mesh-vpn'
local uci = require('simple-uci').cursor()
local enabled = vpn_core.enabled()
local file = '/etc/openvpn/mesh_vpn.ovpn'
-- TODO: support for directly specifying options in site conf??
fd = io.open(file, 'w')
fd:write(site.mesh_vpn.openvpn.config())
fd:write("\ndev " .. vpn_core.get_interface())
fd:close()
-- NOTE: ip is set by static-ip
uci:section('openvpn', 'mesh_vpn', {
enabled = enabled,
config = file,
})
uci:save('openvpn')