From d8e70293813a2ea92e2440c2cd0c84d92572bcdf Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Fri, 21 Dec 2018 00:55:05 +0800 Subject: [PATCH] luci app sfe: dnscache daemon by prcd --- package/lean/luci-app-sfe/Makefile | 2 +- package/lean/luci-app-sfe/root/etc/init.d/sfe | 42 +++++++++---------- .../luci-app-sfe/root/etc/uci-defaults/sfe | 3 -- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/package/lean/luci-app-sfe/Makefile b/package/lean/luci-app-sfe/Makefile index 2504a24aa..210529c78 100644 --- a/package/lean/luci-app-sfe/Makefile +++ b/package/lean/luci-app-sfe/Makefile @@ -9,7 +9,7 @@ LUCI_TITLE:=LuCI support for Turbo ACC (SFE) LUCI_DEPENDS:=+kmod-fast-classifier +pdnsd-alt +kmod-tcp-bbr @LINUX_4_9 LUCI_PKGARCH:=all PKG_VERSION:=1.0 -PKG_RELEASE:=11 +PKG_RELEASE:=12 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-sfe/root/etc/init.d/sfe b/package/lean/luci-app-sfe/root/etc/init.d/sfe index 5b3c2512e..f00256dd7 100755 --- a/package/lean/luci-app-sfe/root/etc/init.d/sfe +++ b/package/lean/luci-app-sfe/root/etc/init.d/sfe @@ -1,12 +1,15 @@ #!/bin/sh /etc/rc.common -# Copyright (c) 2011-2015 OpenWrt.org +# Copyright (C) 2007-2012 OpenWrt.org -START=30 +START=90 +USE_PROCD=1 + +PDNSD_BIN="/var/sbin/dnscache" DNSMASQ_RESTART=N DNS_SERVER="114.114.114.114,114.114.115.115" -start_pdnsd() { +pdnsd_genconfig() { DNS_SERVER=$(uci get sfe.config.dns_server 2>/dev/null) [ -d /var/etc ] || mkdir -p /var/etc @@ -125,13 +128,6 @@ EOF [ -d /var/sbin ] || mkdir -p /var/sbin [ -f /var/sbin/dnscache ] || cp -a /usr/sbin/pdnsd /var/sbin/dnscache - /var/sbin/dnscache -c /var/etc/dnscache.conf -d - echo "Start DNS Cache" -} - -stop_pdnsd() { - kill $(pidof dnscache) >/dev/null 2>&1 || kill -9 $(ps | grep dnscache | grep -v grep | awk '{print $1}') >/dev/null 2>&1 - echo "Stop DNS Cache" } change_dns() { @@ -149,14 +145,14 @@ revert_dns() { uci commit dhcp } -start(){ +start_service() { enable=$(uci get sfe.config.enabled 2>/dev/null) wifi=$(uci get sfe.config.wifi) ipv6=$(uci get sfe.config.ipv6) dns=$(uci get sfe.config.dns 2>/dev/null) bbr=$(uci get sfe.config.bbr 2>/dev/null) - if [ $enable -eq 1 ]; then - echo "enable" + + if [ $enable -eq 1 ]; then ! (lsmod | grep fast_classifier >/dev/null) && (modprobe fast_classifier) if [ $wifi -eq 1 ] ; then echo 1 > /sys/fast_classifier/skip_to_bridge_ingress @@ -172,27 +168,33 @@ start(){ else rmmod fast_classifier >/dev/null 2>&1 fi + if [ $dns -eq 1 ]; then - start_pdnsd + pdnsd_genconfig + procd_open_instance + procd_set_param command "$PDNSD_BIN" -c /var/etc/dnscache.conf + procd_set_param respawn + procd_set_param stderr 1 + procd_close_instance change_dns fi + if [ $bbr -eq 1 ]; then sysctl -w net.ipv4.tcp_congestion_control=bbr else sysctl -w net.ipv4.tcp_congestion_control=cubic fi if [ "$DNSMASQ_RESTART" = N ]; then - /etc/init.d/dnsmasq restart && echo "DNSMASQ change" + /etc/init.d/dnsmasq restart fi } -stop(){ +stop_service(){ enable=$(uci get sfe.config.enabled 2>/dev/null) [ $enable -ne 1 ] && rmmod fast_classifier >/dev/null 2>&1 - stop_pdnsd revert_dns if [ "$DNSMASQ_RESTART" = N ]; then - /etc/init.d/dnsmasq restart && echo "DNSMASQ revert" + /etc/init.d/dnsmasq restart fi } @@ -201,6 +203,4 @@ restart(){ stop start /etc/init.d/dnsmasq restart && echo "DNSMASQ restart" -} - - +} \ No newline at end of file diff --git a/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe b/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe index 444964d9b..50adb160f 100755 --- a/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe +++ b/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe @@ -7,9 +7,6 @@ uci -q batch <<-EOF >/dev/null commit ucitrack EOF -sed -i '/dnscache-watchdog.sh/d' /etc/crontabs/root -echo '*/60 * * * * /usr/share/dnscache-watchdog.sh' >> /etc/crontabs/root - [ ! -f /usr/sbin/dnscache ] && ln /usr/sbin/pdnsd /usr/sbin/dnscache /etc/init.d/sfe enable