diff --git a/package/gluon-next-node/Makefile b/package/gluon-next-node/Makefile index 4a064988..0edcec64 100644 --- a/package/gluon-next-node/Makefile +++ b/package/gluon-next-node/Makefile @@ -1,8 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gluon-next-node -PKG_VERSION:=1 -PKG_RELEASE:=1.$(GLUON_CONFIG_VERSION) +PKG_VERSION:=2 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) @@ -30,6 +29,7 @@ define Build/Compile endef define Package/gluon-next-node/install + $(CP) ./files/* $(1)/ $(GLUON_GENERATE) ./generate/* $(1)/ endef diff --git a/package/gluon-next-node/files/lib/gluon/upgrade/next-node/invariant/010-next-node b/package/gluon-next-node/files/lib/gluon/upgrade/next-node/invariant/010-next-node new file mode 100755 index 00000000..55507fa4 --- /dev/null +++ b/package/gluon-next-node/files/lib/gluon/upgrade/next-node/invariant/010-next-node @@ -0,0 +1,65 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' +local uci = require 'luci.model.uci' +local ip = require 'luci.ip' + +local c = uci.cursor() + + +c:delete('network', 'local_node_dev') +c:section('network', 'device', 'local_node_dev', + { + name = 'local-node', + ifname = 'br-client', + type = 'macvlan', + macaddr = site.next_node.mac, + } +) + +c:delete('network', 'local_node') +c:section('network', 'interface', 'local_node', + { + ifname = 'local-node', + proto = 'static', + ipaddr = site.next_node.ip4, + netmask = '255.255.255.255', + ip6addr = site.next_node.ip6 .. '/128', + } +) + +local prefix4 = ip.IPv4(site.prefix4) +c:delete('network', 'local_node_route4') +c:section('network', 'route', 'local_node_route4', + { + interface = 'client', + target = prefix4:network():string(), + netmask = prefix4:mask():string(), + gateway = '0.0.0.0', + } +) + +c:delete('network', 'local_node_route6') +c:section('network', 'route6', 'local_node_route6', + { + interface = 'client', + target = site.prefix6, + gateway = '::', + } +) + +c:save('network') +c:commit('network') + +c:delete('firewall', 'local_node') +c:section('firewall', 'zone', 'local_node', + { + name = 'local_node', + network = {'local_node'}, + input = 'ACCEPT', + output = 'ACCEPT', + forward = 'REJECT', + } +) +c:save('firewall') +c:commit('firewall') diff --git a/package/gluon-next-node/generate/lib/gluon/upgrade/next-node/invariant/010-next-node b/package/gluon-next-node/generate/lib/gluon/upgrade/next-node/invariant/010-next-node deleted file mode 100755 index 649ec7c4..00000000 --- a/package/gluon-next-node/generate/lib/gluon/upgrade/next-node/invariant/010-next-node +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -. /lib/functions.sh - - -uci_remove network local_node_dev -uci_add network device local_node_dev -uci_set network local_node_dev name 'local-node' -uci_set network local_node_dev ifname 'br-client' -uci_set network local_node_dev type 'macvlan' -uci_set network local_node_dev macaddr '@next_node.mac@' - -uci_remove network local_node -uci_add network interface local_node -uci_set network local_node ifname 'local-node' -uci_set network local_node proto 'static' -uci_set network local_node ipaddr '@next_node.ip4@' -uci_set network local_node netmask '255.255.255.255' -uci_set network local_node ip6addr '@next_node.ip6@/128' - -eval $(ipcalc.sh '@prefix4@') - -uci_remove network local_node_route4 -uci_add network route local_node_route4 -uci_set network local_node_route4 interface 'client' -uci_set network local_node_route4 target "$IP" -uci_set network local_node_route4 netmask "$NETMASK" -uci_set network local_node_route4 gateway '0.0.0.0' - -uci_remove network local_node_route6 -uci_add network route6 local_node_route6 -uci_set network local_node_route6 interface 'client' -uci_set network local_node_route6 target '@prefix6@' -uci_set network local_node_route6 gateway '::' - -uci_commit network - -uci_remove firewall local_node -uci_add firewall zone local_node -uci_set firewall local_node name 'local_node' -uci add_list firewall.local_node.network='local_node' -uci_set firewall local_node input 'ACCEPT' -uci_set firewall local_node output 'ACCEPT' -uci_set firewall local_node forward 'REJECT' -uci_commit firewall