Introduce new package gluon-upgrade-static-interface-ffhh
Signed-off-by: Bjoern Dobe <bjoern@dobecom.de>
This commit is contained in:
parent
6187a611a1
commit
eb99353a88
4 changed files with 114 additions and 0 deletions
36
gluon-upgrade-static-interface-ffhh/Makefile
Normal file
36
gluon-upgrade-static-interface-ffhh/Makefile
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=gluon-upgrade-static-interface-ffhh
|
||||||
|
PKG_VERSION:=1
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/gluon-upgrade-static-interface-ffhh
|
||||||
|
SECTION:=gluon
|
||||||
|
CATEGORY:=Gluon
|
||||||
|
TITLE:=Configure infaces with static IP
|
||||||
|
DEPENDS:=+gluon-core +gluon-ebtables
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/gluon-upgrade-static-interface-ffhh/description
|
||||||
|
This package allows to define interface with static ip adresses in gluon config
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Prepare
|
||||||
|
mkdir -p $(PKG_BUILD_DIR)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/gluon-upgrade-static-interface-ffhh/install
|
||||||
|
$(CP) ./files/* $(1)/
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,gluon-upgrade-static-interface-ffhh))
|
17
gluon-upgrade-static-interface-ffhh/README.md
Normal file
17
gluon-upgrade-static-interface-ffhh/README.md
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# ffhh gluon-upgrade-static-interface-ffhh
|
||||||
|
|
||||||
|
This package adds options to /etc/config/gluon to configure an additional interface with static IP.
|
||||||
|
This interface can be used, for example, for local management networks or configuration interfaces of WLAN radio links.
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
In /etc/config/gluon several interfaces with static addresses can be created.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
config interface 'wartung'
|
||||||
|
option netmask '255.255.255.0'
|
||||||
|
option proto 'static'
|
||||||
|
option ipaddr '192.168.0.1'
|
||||||
|
option ifname 'lan1.5'
|
||||||
|
```
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local uci=require('simple-uci').cursor()
|
||||||
|
|
||||||
|
local function has_static_role(section)
|
||||||
|
for _, role in ipairs(section.role or {}) do
|
||||||
|
if role == "static" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
uci:foreach('gluon', 'interface', function(s)
|
||||||
|
if has_static_role(s) then
|
||||||
|
-- io.stderr:write("+++ ")
|
||||||
|
-- io.stderr:write(s[".name"])
|
||||||
|
-- io.stderr:write("\n")
|
||||||
|
|
||||||
|
local config_section = { proto = "static" }
|
||||||
|
local mapping = { ipaddr = "ipaddr", ifname = "name", netmask = "netmask" }
|
||||||
|
|
||||||
|
for key, lookup in pairs(mapping) do
|
||||||
|
local value = uci:get('gluon', s[".name"], lookup)
|
||||||
|
if value then
|
||||||
|
config_section[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
uci:section('network', 'interface', s[".name"], config_section)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
uci:save('network')
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local uci=require('simple-uci').cursor()
|
||||||
|
|
||||||
|
local function has_static_role(section)
|
||||||
|
for _, role in ipairs(section.role or {}) do
|
||||||
|
if role == "static" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
uci:foreach('gluon', 'interface', function(s)
|
||||||
|
if has_static_role(s) then
|
||||||
|
|
||||||
|
uci:section('firewall','zone',s[".name"],{
|
||||||
|
name=s[".name"],
|
||||||
|
network=s[".name"],
|
||||||
|
input='ACCEPT',
|
||||||
|
output='ACCEPT',
|
||||||
|
forward='DROP',
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
uci:save('firewall')
|
Loading…
Add table
Add a link
Reference in a new issue