Add new package gluon-wan-dnsmasq
This package provides a secondary dnsmasq instance on port 54 which resolves everything over the WAN interface.
This commit is contained in:
parent
d638359215
commit
f389ef925e
35
package/gluon-wan-dnsmasq/Makefile
Normal file
35
package/gluon-wan-dnsmasq/Makefile
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=gluon-wan-dnsmasq
|
||||||
|
PKG_VERSION:=1
|
||||||
|
|
||||||
|
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/gluon-wan-dnsmasq
|
||||||
|
SECTION:=gluon
|
||||||
|
CATEGORY:=Gluon
|
||||||
|
TITLE:=Support for a secondary DNS server using the WAN interface
|
||||||
|
DEPENDS:=+gluon-core +dnsmasq
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/gluon-wan-dnsmasq/description
|
||||||
|
Gluon community wifi mesh firmware framework: Support for a secondary DNS server using the WAN interface
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Prepare
|
||||||
|
mkdir -p $(PKG_BUILD_DIR)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/gluon-wan-dnsmasq/install
|
||||||
|
$(CP) ./files/* $(1)/
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,gluon-wan-dnsmasq))
|
@ -0,0 +1,3 @@
|
|||||||
|
if [ "$INTERFACE" = 'wan' -o "$INTERFACE" = 'wan6' ]; then
|
||||||
|
/lib/gluon/wan-dnsmasq/update.lua
|
||||||
|
fi
|
26
package/gluon-wan-dnsmasq/files/etc/init.d/gluon-wan-dnsmasq
Executable file
26
package/gluon-wan-dnsmasq/files/etc/init.d/gluon-wan-dnsmasq
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=60
|
||||||
|
|
||||||
|
SERVICE_NAME=gluon-wan-dnsmasq
|
||||||
|
SERVICE_USE_PID=1
|
||||||
|
SERVICE_PID_FILE=/var/run/gluon-wan-dnsmasq.pid
|
||||||
|
|
||||||
|
|
||||||
|
PORT=54
|
||||||
|
PACKET_MARK=1
|
||||||
|
|
||||||
|
RESOLV_CONF_DIR=/var/gluon/wan-dnsmasq
|
||||||
|
RESOLV_CONF=$RESOLV_CONF_DIR/resolv.conf
|
||||||
|
|
||||||
|
|
||||||
|
start() {
|
||||||
|
mkdir -p $RESOLV_CONF_DIR
|
||||||
|
touch $RESOLV_CONF
|
||||||
|
|
||||||
|
service_start /usr/sbin/dnsmasq -x $SERVICE_PID_FILE -u root -i lo -p $PORT --packet-mark=$PACKET_MARK -h -r $RESOLV_CONF
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
service_stop /usr/sbin/dnsmasq
|
||||||
|
}
|
25
package/gluon-wan-dnsmasq/files/lib/gluon/wan-dnsmasq/update.lua
Executable file
25
package/gluon-wan-dnsmasq/files/lib/gluon/wan-dnsmasq/update.lua
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local RESOLV_CONF_DIR = '/var/gluon/wan-dnsmasq'
|
||||||
|
local RESOLV_CONF = RESOLV_CONF_DIR .. '/resolv.conf'
|
||||||
|
|
||||||
|
|
||||||
|
local ubus = require('ubus').connect()
|
||||||
|
local fs = require 'nixio.fs'
|
||||||
|
|
||||||
|
|
||||||
|
local function write_servers(f, iface)
|
||||||
|
local servers = ubus:call('network.interface.' .. iface, 'status', {}).inactive['dns-server']
|
||||||
|
for _, server in ipairs(servers) do
|
||||||
|
f:write('nameserver ', server, '\n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
fs.mkdirr(RESOLV_CONF_DIR)
|
||||||
|
local f = io.open(RESOLV_CONF, 'w+')
|
||||||
|
|
||||||
|
pcall(write_servers, f, 'wan6')
|
||||||
|
pcall(write_servers, f, 'wan')
|
||||||
|
|
||||||
|
f:close()
|
Loading…
Reference in New Issue
Block a user