Commit a32379da authored by Jan Pavlinec's avatar Jan Pavlinec

resolver-conf: add new local domains script

parent ddd840dc
......@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=resolver-conf
PKG_VERSION:=0.0.1
PKG_RELEASE:=10
PKG_RELEASE:=11
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
......@@ -26,6 +26,11 @@ define Package/resolver-conf
CATEGORY:=Network
SUBMENU:=IP Addresses and Names
TITLE:=Resolver configuration
ifeq ($(CONFIG_TARGET_mvebu_Turris-Omnia),y)
DEPENDS:=+unbound-control
else
DEPENDS:=+unbound-control
endif
endef
define Package/$(PKG_NAME)/description
......@@ -46,6 +51,8 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/resolver
$(INSTALL_BIN) ./files/resolver-conv $(1)/etc/resolver/resolver-conv.sh
$(INSTALL_BIN) ./files/dhcp_host_domain_ng.py $(1)/etc/resolver/dhcp_host_domain_ng.py
$(INSTALL_BIN) ./files/dynamic-domain-conv $(1)/etc/resolver/dynamic-domain-conv.sh
ifeq ($(CONFIG_TARGET_mvebu_Turris-Omnia),y)
$(INSTALL_CONF) ./files/resolver-omnia-config $(1)/etc/config/resolver
else
......@@ -57,6 +64,7 @@ endif
$(INSTALL_BIN) ./files/resolver-reload $(1)/etc/hotplug.d/iface/40-resolver-reload
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/resolver-defaults $(1)/etc/uci-defaults/resolver-defaults
endef
define Package/$(PKG_NAME)/postinst
......@@ -66,6 +74,7 @@ if [ -z "$$IPKG_INSTROOT" ]; then
/etc/uci-defaults/resolver-defaults && rm /etc/uci-defaults/resolver-defaults
$(if $(CONFIG_TARGET_mvebu_Turris-Omnia),,
if [ ! -e "/etc/resolver/converted" ]; then
/etc/resolver/dynamic-domain-conv.sh
/etc/resolver/resolver-conv.sh
touch /etc/resolver/converted
fi)
......
This diff is collapsed.
#!/bin/sh
#convert value from /etc/config/resolver and /etc/config/dhcp
get_kresd_dd() {
dd_val=$(uci get resolver.kresd.dynamic_domains)
if [ $? -eq 1 ]; then
echo -n 0
else
echo $dd_val
fi
}
# convert resolver.kresd.dynamic_domain => resolver.common.dynamic_domain
dd_val=$(uci get resolver.common.dynamic_domains)
if [ $? -eq 1 ] && [ ! -f /etc/resolver/dd_converted ]; then
echo uci set resolver.common.dynamic_domains=$(get_kresd_dd)
uci set resolver.common.dynamic_domains=$(get_kresd_dd)
uci commit resolver
touch /etc/resolver/dd_converted
else
echo "nothing done"
fi
#convert dhcp.@dnsmasq[0].dhcpscript to /etc/resolver/dhcp_host_domain_ng.py
dd_script=$(uci get dhcp.@dnsmasq[0].dhcpscript)
if [ "$dd_script" = "/etc/kresd/dhcp_host_domain_ng.sh" ]; then
uci set dhcp.@dnsmasq[0].dhcpscript="/etc/resolver/dhcp_host_domain_ng.py"
uci commit dhcp
fi
#!/bin/sh
if [ "$(uci -q get dhcp.@dnsmasq[0].port || echo 53)" = 53 ] ; then
dhcp_port=$(uci -q get dhcp.@dnsmasq[0].port)
if [ $? -eq 1 ] && \
[ ! -f /etc/resolver/dnsmasq_disabled ]; then
uci set dhcp.@dnsmasq[0].port=0
touch /etc/resolver/dnsmasq_disabled
fi
# Make sure we can set time for resolution to work, before the resolution works.
uci show system.ntp.server | grep -q '217\.31\.202\.100' || uci add_list system.ntp.server=217.31.202.100
......
......@@ -3,7 +3,7 @@
SERVICE_USE_PID=0
DHCP_SCRIPT=/etc/kresd/dhcp_host_domain_ng.sh
DHCP_SCRIPT=/etc/resolver/dhcp_host_domain_ng.py
START=60
......@@ -23,6 +23,11 @@ prefered_resolver() {
PREF_RESOLVER=$(prefered_resolver)
set_dhcp_script() {
uci_set dhcp "@dnsmasq[0]" dhcpscript "$DHCP_SCRIPT"
uci_commit dhcp
}
run_dhcp_script() {
local action resolver dynamic_domains
action=$1
......@@ -30,11 +35,10 @@ run_dhcp_script() {
# enable dynamic local domains
config_load resolver
config_get_bool dynamic_domains "kresd" dynamic_domains 0
config_get_bool dynamic_domains "common" dynamic_domains 0
if ( [ "$resolver" == "kresd" ] && \
[ "$dynamic_domains" == "1" ] ) && ( \
if [ "$dynamic_domains" == "1" ] && ( \
[ "$action" == "reload" ] || \
[ "$action" == "restart" ] || \
[ "$action" == "start" ] ); \
......@@ -95,6 +99,7 @@ run_cmd() {
fi
#run script to refresh dynamic domains
set_dhcp_script
run_dhcp_script $param $LAST_SERVICE
}
save_resolver_info() {
......@@ -104,7 +109,7 @@ save_resolver_info() {
cp /var/run/unbound.pid /var/run/resolver.pid
else #kresd
sleep 1
pid_num=$(ps|grep kres|grep -v grep|tail -n 1|awk '{print $1}')
pid_num=$(pidof kresd )
echo $pid_num>/var/run/resolver.pid
fi
echo $LAST_SERVICE>/var/run/resolver.name
......
......@@ -14,6 +14,7 @@ config resolver 'common'
option ignore_root_key '0'
option prefetch 'yes'
option static_domains '1'
option dynamic_domains '0'
config resolver 'kresd'
option rundir '/tmp/kresd'
......@@ -22,7 +23,6 @@ config resolver 'kresd'
option forks '1'
#option include_config '/tmp/kresd.custom.conf'
#list hostname_config '/etc/hosts'
option dynamic_domains '0'
#list rpz_file '/tmp/file.rpz'
config resolver 'unbound'
......@@ -54,7 +54,8 @@ config resolver 'unbound'
# list python_script "/etc/unbound/ubmodule-tst.py"
config resolver 'unbound_remote_control'
option control_enable 'no'
option control_enable 'yes'
option control_use_cert 'no'
list control_interface '0.0.0.0'
list control_interface '::0'
......
......@@ -13,6 +13,7 @@ config resolver 'common'
option prefered_resolver 'unbound'
option ignore_root_key '0'
option static_domains '1'
option dynamic_domains '0'
config resolver 'kresd'
option rundir '/tmp/kresd'
......@@ -50,7 +51,8 @@ config resolver 'unbound_python'
list python_script "/etc/unbound/ubmodule-tst.py"
config resolver 'unbound_remote_control'
option control_enable 'no'
option control_enable 'yes'
option control_use_cert 'no'
list control_interface '0.0.0.0'
list control_interface '::0'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment