From b5a8959f59382555f1d8ef6f794d0da03c61f047 Mon Sep 17 00:00:00 2001 From: Sunz3r Date: Thu, 6 Jul 2017 13:24:15 +0200 Subject: [PATCH] gluon-config-mode-mesh-vpn: add tunneldigger to reboot page (#1172) --- .../config-mode/reboot/0100-mesh-vpn.lua | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua b/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua index 4901aa5d..14e834e7 100644 --- a/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua +++ b/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua @@ -1,5 +1,6 @@ local uci = require("simple-uci").cursor() local lutil = require "gluon.web.util" +local fs = require "nixio.fs" local site = require 'gluon.site_config' local sysconfig = require 'gluon.sysconfig' @@ -8,7 +9,10 @@ local util = require "gluon.util" local pretty_hostname = require 'pretty_hostname' -local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled") + +local has_fastd = fs.access('/lib/gluon/mesh-vpn/fastd') +local has_tunneldigger = fs.access('/lib/gluon/mesh-vpn/tunneldigger') + local hostname = pretty_hostname.get(uci) local contact = uci:get_first("gluon-node-info", "owner", "contact") @@ -16,11 +20,20 @@ local contact = uci:get_first("gluon-node-info", "owner", "contact") local pubkey local msg -if meshvpn_enabled then - pubkey = util.trim(lutil.exec("/etc/init.d/fastd show_key mesh_vpn")) - msg = _translate('gluon-config-mode:pubkey') -else - msg = _translate('gluon-config-mode:novpn') + +if has_tunneldigger then + local tunneldigger_enabled = uci:get_bool("tunneldigger", "mesh_vpn", "enabled") + if not tunneldigger_enabled then + msg = _translate('gluon-config-mode:novpn') + end +elseif has_fastd then + local fastd_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled") + if fastd_enabled then + pubkey = util.trim(lutil.exec("/etc/init.d/fastd show_key mesh_vpn")) + msg = _translate('gluon-config-mode:pubkey') + else + msg = _translate('gluon-config-mode:novpn') + end end if not msg then return end