gluon-next-node: convert upgrade script to Lua
This commit is contained in:
parent
a6f87d2461
commit
c33a434884
@ -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
|
||||
|
||||
|
@ -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')
|
@ -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
|
Loading…
Reference in New Issue
Block a user