From 42306fc7ce6954fbcab9add1eb8a254d7bf88169 Mon Sep 17 00:00:00 2001 From: LEAN-ESX Date: Tue, 10 Mar 2020 06:57:39 -0700 Subject: [PATCH] luci-app-adbyby-plus: convert to procd --- package/lean/frp/Makefile | 6 +- package/lean/luci-app-adbyby-plus/Makefile | 2 +- .../root/etc/init.d/adbyby | 71 +++++++++++-------- .../root/usr/share/adbyby/adbybyupdate.sh | 2 +- 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/package/lean/frp/Makefile b/package/lean/frp/Makefile index cc933edc8..4a1cc2c1c 100644 --- a/package/lean/frp/Makefile +++ b/package/lean/frp/Makefile @@ -51,11 +51,11 @@ define frp/templates define Package/$(1)/install $$(call GoPackage/Package/Install/Bin,$$(PKG_INSTALL_DIR)) - - $(STAGING_DIR_HOST)/bin/upx --lzma --best $(PKG_INSTALL_DIR)/usr/bin/$(1) $$(INSTALL_DIR) $$(1)/usr/bin $$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/usr/bin/$(1) $$(1)/usr/bin/ + + $(STAGING_DIR_HOST)/bin/upx --lzma --best $$(1)/usr/bin/$(1) endef endef @@ -65,4 +65,4 @@ $(foreach component,$(FRP_COMPONENTS), \ $(eval $(call frp/templates,$(component))) \ $(eval $(call GoBinPackage,$(component))) \ $(eval $(call BuildPackage,$(component))) \ -) +) \ No newline at end of file diff --git a/package/lean/luci-app-adbyby-plus/Makefile b/package/lean/luci-app-adbyby-plus/Makefile index ddf7cee3b..95d1f0acb 100644 --- a/package/lean/luci-app-adbyby-plus/Makefile +++ b/package/lean/luci-app-adbyby-plus/Makefile @@ -10,7 +10,7 @@ LUCI_DEPENDS:=+adbyby +wget +ipset +dnsmasq-full LUCI_PKGARCH:=all PKG_NAME:=luci-app-adbyby-plus PKG_VERSION:=2.0 -PKG_RELEASE:=56 +PKG_RELEASE:=58 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-adbyby-plus/root/etc/init.d/adbyby b/package/lean/luci-app-adbyby-plus/root/etc/init.d/adbyby index 8f4385cad..08b9ae136 100755 --- a/package/lean/luci-app-adbyby-plus/root/etc/init.d/adbyby +++ b/package/lean/luci-app-adbyby-plus/root/etc/init.d/adbyby @@ -1,8 +1,10 @@ #!/bin/sh /etc/rc.common -START=99 +START=98 STOP=10 +USE_PROCD=1 + EXTRA_COMMANDS="add_rule del_rule reload_rule" PROG_PATH=/usr/share/adbyby DATA_PATH=$PROG_PATH/data @@ -11,12 +13,26 @@ CRON_FILE=/etc/crontabs/root CONFIG=adbyby ipt_n="iptables -t nat" +uci_get_by_name() { + local ret=$(uci get $CONFIG.$1.$2 2>/dev/null) + echo ${ret:=$3} +} + +uci_get_by_type() { + local index=0 + if [ -n $4 ]; then + + index=$4 + fi + local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null) + echo ${ret:=$3} +} get_config() { - config_get_bool enable $1 enable - config_get_bool cron_mode $1 cron_mode - config_get wan_mode $1 wan_mode + config_get_bool enable $1 enable 0 + config_get_bool cron_mode $1 cron_mode 1 + config_get wan_mode $1 wan_mode 1 config_get_bool block_ios $1 block_ios 0 config_get_bool mem_mode $1 mem_mode 1 } @@ -163,30 +179,37 @@ reload_rule() iptables-save | grep ADBYBY >/dev/null || add_rule } -start() +start_service() { config_load adbyby config_foreach get_config adbyby - [ $enable -eq 0 ] && exit 0 - add_cron - [ ! -d "/tmp/adbyby/data" ] && cp -a /usr/share/adbyby /tmp/ && rm -f /tmp/adbyby.updated - add_rules - /tmp/adbyby/adbyby &>/dev/null & - add_dns - iptables-save | grep ADBYBY >/dev/null || \ - add_rule - /etc/init.d/dnsmasq reload + + if [ $enable -ne 0 ]; then + add_cron + [ ! -d "/tmp/adbyby/data" ] && cp -a /usr/share/adbyby /tmp/ && rm -f /tmp/adbyby.updated + add_rules + + procd_open_instance + procd_set_param command '/tmp/adbyby/adbyby' + procd_append_param command '--no-daemon' + procd_set_param respawn + procd_set_param stderr 1 + procd_close_instance + + add_dns + iptables-save | grep ADBYBY >/dev/null || \ + add_rule + /etc/init.d/dnsmasq reload + fi } -stop() +stop_service() { config_load adbyby config_foreach get_config adbyby del_rule del_cron del_dns - kill -9 $(ps | grep 'admem.sh' | grep -v grep | awk '{print $1}') >/dev/null 2>&1 - kill -9 $(ps | grep '/tmp/adbyby/adbyby' | grep -v grep | awk '{print $1}') >/dev/null 2>&1 /etc/init.d/dnsmasq reload } @@ -197,18 +220,4 @@ boot() } -uci_get_by_name() { - local ret=$(uci get $CONFIG.$1.$2 2>/dev/null) - echo ${ret:=$3} -} - -uci_get_by_type() { - local index=0 - if [ -n $4 ]; then - - index=$4 - fi - local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null) - echo ${ret:=$3} -} diff --git a/package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adbybyupdate.sh b/package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adbybyupdate.sh index bd55c7289..0ff22a6ea 100755 --- a/package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adbybyupdate.sh +++ b/package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adbybyupdate.sh @@ -43,6 +43,6 @@ if [ ! -f "/tmp/adbyby.updated" ];then rm -f /tmp/adbyby/data/*.bak - /etc/init.d/adbyby restart + kill -9 $(busybox ps -w | grep "adbyby --no-daemon" | grep -v grep | awk '{print $1}') >/dev/null 2>&1 fi