gluon-ddhcpd: add new package to configure ddhcpd for gluon
This commit is contained in:
parent
79ca7a7baa
commit
277d1bf8e1
13
package/gluon-ddhcpd/Makefile
Normal file
13
package/gluon-ddhcpd/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=gluon-ddhcpd
|
||||
PKG_VERSION:=1
|
||||
|
||||
include ../gluon.mk
|
||||
|
||||
define Package/gluon-ddhcpd
|
||||
TITLE:=Distributed DHCP Daemon for Gluon
|
||||
DEPENDS:=+gluon-core +ddhcpd
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackageGluon,gluon-ddhcpd))
|
2
package/gluon-ddhcpd/check_site.lua
Normal file
2
package/gluon-ddhcpd/check_site.lua
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
need_string_match(in_domain({'next_node', 'ip4'}), '^%d+.%d+.%d+.%d+$', true)
|
6
package/gluon-ddhcpd/files/etc/ddhcp-hook.sh
Executable file
6
package/gluon-ddhcpd/files/etc/ddhcp-hook.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
for i in /etc/ddhcpd.d/*
|
||||
do
|
||||
$i "$@"
|
||||
done
|
53
package/gluon-ddhcpd/files/etc/init.d/gluon-ddhcpd
Executable file
53
package/gluon-ddhcpd/files/etc/init.d/gluon-ddhcpd
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=90
|
||||
USE_PROCD=1
|
||||
NAME=ddhcpd
|
||||
DAEMON=/usr/sbin/ddhcpd
|
||||
MAXDELAY=10
|
||||
|
||||
validate_section_ddhcpd() {
|
||||
uci_validate_section "$NAME" ddhcpd settings \
|
||||
'dhcp_interface:string:br-client' \
|
||||
'server_interface:string:br-client' \
|
||||
'block_size_pow:uinteger:2' \
|
||||
'spare_blocks:uinteger:1' \
|
||||
'timeout:uinteger:30' \
|
||||
'block_network:cidr4' \
|
||||
'dhcp_lease_time:uinteger:300'
|
||||
server_interface=$(ubus call network.interface dump | jsonfilter -e "@.interface[@.interface='$(cat /lib/gluon/respondd/client.dev 2>/dev/null)' && @.up=true].device")
|
||||
}
|
||||
|
||||
start_service() {
|
||||
[ -x /lib/gluon/ddhcpd/arguments ] || exit 1
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command $DAEMON -D
|
||||
|
||||
config_load "${NAME}"
|
||||
|
||||
validate_section_ddhcpd || {
|
||||
echo "validation failed"
|
||||
return 1
|
||||
}
|
||||
|
||||
procd_append_param command -s "$spare_blocks"
|
||||
procd_append_param command -b "$block_size_pow"
|
||||
procd_append_param command -c "$dhcp_interface"
|
||||
procd_append_param command -i "$server_interface"
|
||||
procd_append_param command -N "$block_network"
|
||||
procd_append_param command -o "51:4:0.0.1.44"
|
||||
procd_append_param command -o "3:4:$(lua -e 'print(require("gluon.site").next_node.ip4())')"
|
||||
procd_append_param command -o "6:4:$(lua -e 'print(require("gluon.site").next_node.ip4())')"
|
||||
procd_append_param command $(/lib/gluon/ddhcpd/arguments)
|
||||
procd_set_param respawn
|
||||
procd_set_param netdev "$dhcp_interface"
|
||||
[ "$dhcp_interface" == "$server_interface" ] || procd_append_param netdev "$server_interface"
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_config_trigger "config.change" "ddhcpd" /etc/init.d/ddhcpd restart
|
||||
procd_add_interface_trigger "interface.*" "$server_interface" /etc/init.d/ddhcpd restart
|
||||
}
|
0
package/gluon-ddhcpd/files/lib/gluon/ddhcpd/arguments
Executable file
0
package/gluon-ddhcpd/files/lib/gluon/ddhcpd/arguments
Executable file
3
package/gluon-ddhcpd/files/lib/gluon/upgrade/317-ddhcpd-disable
Executable file
3
package/gluon-ddhcpd/files/lib/gluon/upgrade/317-ddhcpd-disable
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci set ddhcpd.settings.enabled="0"
|
22
package/gluon-ddhcpd/luasrc/lib/gluon/upgrade/315-dhcp-config-firewall
Executable file
22
package/gluon-ddhcpd/luasrc/lib/gluon/upgrade/315-dhcp-config-firewall
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local uci = require('simple-uci').cursor()
|
||||
|
||||
uci:section('firewall', 'rule', 'local_node_dhcp', {
|
||||
src = 'local_client',
|
||||
name = 'allow_dhcp_local_client',
|
||||
dest_port = '67',
|
||||
proto = 'udp',
|
||||
target = 'ACCEPT'
|
||||
})
|
||||
|
||||
uci:section('firewall', 'rule', 'ddhcpd_mmfd', {
|
||||
dest_port = '1234',
|
||||
src = 'mmfd',
|
||||
src_ip = 'fe80::/64',
|
||||
name = 'allow_ddhcp_to_reserve_blocks',
|
||||
proto = 'udp',
|
||||
target = 'ACCEPT'
|
||||
})
|
||||
|
||||
uci:save('firewall')
|
9
package/gluon-ddhcpd/luasrc/lib/gluon/upgrade/316-ddhcp
Executable file
9
package/gluon-ddhcpd/luasrc/lib/gluon/upgrade/316-ddhcp
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local site = require 'gluon.site'
|
||||
|
||||
local uci = require('simple-uci').cursor()
|
||||
|
||||
uci:set('ddhcpd', 'settings', 'block_network', site.prefix4())
|
||||
|
||||
uci:save('ddhcpd')
|
Loading…
Reference in New Issue
Block a user