From ad7a36fdce12b96b071ca0602230ff62364401af Mon Sep 17 00:00:00 2001 From: Cyrus Fox Date: Fri, 10 Mar 2017 03:22:41 +0100 Subject: [PATCH] gluon-mesh-vpn-tunneldigger: add package for tunneldigger L2TP support --- package/gluon-mesh-vpn-tunneldigger/Makefile | 38 +++++++++++++++++++ .../check_site.lua | 1 + .../files/lib/gluon/mesh-vpn/tunneldigger | 0 .../gluon/upgrade/400-mesh-vpn-tunneldigger | 32 ++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 package/gluon-mesh-vpn-tunneldigger/Makefile create mode 100644 package/gluon-mesh-vpn-tunneldigger/check_site.lua create mode 100644 package/gluon-mesh-vpn-tunneldigger/files/lib/gluon/mesh-vpn/tunneldigger create mode 100755 package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger diff --git a/package/gluon-mesh-vpn-tunneldigger/Makefile b/package/gluon-mesh-vpn-tunneldigger/Makefile new file mode 100644 index 00000000..6aadc3b6 --- /dev/null +++ b/package/gluon-mesh-vpn-tunneldigger/Makefile @@ -0,0 +1,38 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-mesh-vpn-tunneldigger +PKG_VERSION:=3 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include ../gluon.mk + +define Package/gluon-mesh-vpn-tunneldigger + SECTION:=gluon + CATEGORY:=Gluon + TITLE:=Support for connecting meshes via tunneltigger/L2TPv3 pseudowire + DEPENDS:=+gluon-core +gluon-mesh-vpn-core +tunneldigger +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Configure +endef + +define Build/Compile + $(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/) +endef + +define Package/gluon-mesh-vpn-tunneldigger/install + $(CP) ./files/* $(1)/ + $(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/ +endef + +define Package/gluon-mesh-vpn-tunneldigger/postinst +#!/bin/sh +$(call GluonCheckSite,check_site.lua) +endef + +$(eval $(call BuildPackage,gluon-mesh-vpn-tunneldigger)) diff --git a/package/gluon-mesh-vpn-tunneldigger/check_site.lua b/package/gluon-mesh-vpn-tunneldigger/check_site.lua new file mode 100644 index 00000000..f218a1ef --- /dev/null +++ b/package/gluon-mesh-vpn-tunneldigger/check_site.lua @@ -0,0 +1 @@ +need_string_array('mesh_vpn.tunneldigger.brokers') diff --git a/package/gluon-mesh-vpn-tunneldigger/files/lib/gluon/mesh-vpn/tunneldigger b/package/gluon-mesh-vpn-tunneldigger/files/lib/gluon/mesh-vpn/tunneldigger new file mode 100644 index 00000000..e69de29b diff --git a/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger b/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger new file mode 100755 index 00000000..04ddf734 --- /dev/null +++ b/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger @@ -0,0 +1,32 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' +local util = require 'gluon.util' + +local uci = require('simple-uci').cursor() + + +local enabled = uci:get('tunneldigger', 'mesh_vpn', 'enabled') +if enabled == nil then + enabled = uci:get_first('tunneldigger', 'broker', 'enabled') +end +if enabled == nil then + enabled = site.mesh_vpn.enabled or false +end + +-- Delete old broker config section +if not uci:get('tunneldigger', 'mesh_vpn') then + uci:delete_all('tunneldigger', 'broker') +end + +uci:section('tunneldigger', 'broker', 'mesh_vpn', { + enabled = enabled, + uuid = util.node_id(), + interface = 'mesh-vpn', + bind_interface = 'br-wan', + group = 'gluon-mesh-vpn', + broker_selection = 'usage', + address = site.mesh_vpn.tunneldigger.brokers, +}) + +uci:save('tunneldigger')