gluon-mesh-vpn-fastd: merge secret generation setup into main upgrade script

There wasn't really a reason to have a separate script to set a single
value.

In addition, the old script was using the identifier 'c' instead of
'uci' for the UCI cursor. Following the convention of the other scripts
is helpful so it is easy to grep for all uses of a certain config file/
option.
This commit is contained in:
Matthias Schiffer 2022-01-01 23:06:03 +01:00
parent d8f6ed2406
commit b68a07e930
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
2 changed files with 6 additions and 12 deletions

View File

@ -9,6 +9,11 @@ local uci = require('simple-uci').cursor()
local syslog_level = uci:get('fastd', 'mesh_vpn', 'syslog_level') or 'verbose'
local secret = uci:get('fastd', 'mesh_vpn', 'secret')
if not secret or not secret:match(('%x'):rep(64)) then
secret = 'generate'
end
local methods
if site.mesh_vpn.fastd.configurable(false) then
@ -38,6 +43,7 @@ end
uci:section('fastd', 'fastd', 'mesh_vpn', {
group = 'gluon-mesh-vpn',
syslog_level = syslog_level,
secret = secret,
interface = vpn_core.get_interface(),
mode = 'tap',
mtu = site.mesh_vpn.mtu(),

View File

@ -1,12 +0,0 @@
#!/usr/bin/lua
local uci = require 'simple-uci'
local c = uci.cursor()
local secret = c:get("fastd", "mesh_vpn", "secret")
if not secret or not secret:match(("%x"):rep(64)) then
c:set("fastd", "mesh_vpn", "secret", "generate")
c:save("fastd")
end