luci-app-adbyby-plus: convert to procd

This commit is contained in:
LEAN-ESX 2020-03-10 06:57:39 -07:00
parent f6423cc17a
commit 42306fc7ce
4 changed files with 45 additions and 36 deletions

View File

@ -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))) \
)
)

View File

@ -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

View File

@ -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}
}

View File

@ -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