treewide: use new extra_command function for init

This commit is contained in:
CN_SZTL 2020-11-07 19:40:54 +08:00
parent 63d1fa959c
commit 71f8f2a91d
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
8 changed files with 53 additions and 52 deletions

View File

@ -5,8 +5,7 @@ STOP=90
BOOT_IMAGE=/boot/vmlinuz
EXTRA_COMMANDS="status"
EXTRA_HELP=" status Print crashkernel status"
extra_command "status" "Print crashkernel status"
verify_kdump() {
local cfg="$1"

View File

@ -1,14 +1,15 @@
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=99
STOP=01
extra_command "test_crontab" "test_crontab"
CRON_FILE=/etc/crontabs/root
CONFIGURATION=autoipsetadder
EXTRA_COMMANDS="test_crontab"
EXTRA_HELP="
test_crontab"
set_dnsmasq_log()
{
sed -i '/log-facility/d' /etc/dnsmasq.conf

View File

@ -11,9 +11,10 @@
START=90
STOP=15
extra_command "rules"
SERVICE_DAEMONIZE=1
NAME=vssr
EXTRA_COMMANDS=rules
#定义配置文件名称
CONFIG_FILE=/var/etc/${NAME}_t.json

View File

@ -2,6 +2,10 @@
START=60
extra_command "makeconfig"
extra_command "makegfwlist"
extra_command "health"
CRON_FILE=/etc/crontabs/root
PID_PATH=/var/run/dnsforwarder
PID_FILE=${PID_PATH}/dns.pid
@ -51,7 +55,7 @@ health(){
}
makegfwlist(){
makegfwlist(){
local GFW_FILE='/etc/dnsforwarder/gfw.txt'
local GFW_TMP_FILE='/tmp/dnsforwarder-gfw.old'
local TSTIME=`date '+%Y-%m-%d %H:%M:%S'`
@ -62,7 +66,7 @@ makegfwlist(){
sort /tmp/edf.ts | uniq > /tmp/edf.ts
/usr/share/dnsforwarder/gfwlist.sh -i -l -o /tmp/dnsforwarder-gfw.tmp --extra-domain-file /tmp/edf.ts
if [ $? != 0 ]; then
echo 'Failed to fetch gfwlist'
echo 'Failed to fetch gfwlist'
logger -t Failed to fetch gfwlist
return 2
fi
@ -79,7 +83,7 @@ makegfwlist(){
cp ${GFW_TMP_FILE} ${GFW_FILE}
sed -i "s/TS_BUILD_TIME/${TSTIME}/g" ${GFW_FILE}
printf "[\e[33m%s\e[0m]" "PID"
restart
restart
fi
}
@ -88,7 +92,7 @@ makeconfig () {
local log=$(uci get dnsforwarder.@config[0].log 2>/dev/null)
local log_size=$(uci get dnsforwarder.@config[0].log_size 2>/dev/null)
local gfw=$(uci get dnsforwarder.@config[0].gfw 2>/dev/null)
local udp_local=$(uci -d ',' get dnsforwarder.@config[0].udp_local 2>/dev/null)
@ -105,8 +109,8 @@ makeconfig () {
local cache=$(uci get dnsforwarder.@config[0].cache 2>/dev/null)
local cache_size=$(uci get dnsforwarder.@config[0].cache_size 2>/dev/null)
local cache_ignore=$(uci get dnsforwarder.@config[0].cache_ignore 2>/dev/null)
local cache_control=$(uci get dnsforwarder.@config[0].cache_control 2>/dev/null)
local cache_control=$(uci get dnsforwarder.@config[0].cache_control 2>/dev/null)
local domain_statistic=$(uci get dnsforwarder.@config[0].domain_statistic 2>/dev/null)
local udp_local_addr=$(uci get dnsforwarder.@arguments[0].addr 2>/dev/null)
udp_local_addr=${udp_local_addr/:/#}
@ -118,7 +122,7 @@ makeconfig () {
echo "LogFileThresholdLength ${log_size}" >> $DNSFORWARDER_CONF
echo "LogFileFolder /var/log" >> $DNSFORWARDER_CONF
fi
[ -n "$udp_local" ] && echo "UDPLocal ${udp_local}" >> $DNSFORWARDER_CONF
[ -n "$udp_local_addr" ] && eval "makelist 'server=' $udp_local_addr" > /tmp/dnsmasq.dnsforwarder.conf
sed -i "s/ //g" /tmp/dnsmasq.dnsforwarder.conf
@ -126,7 +130,7 @@ makeconfig () {
eval "makelist 'TCPGroup' $tcp_group" >> $DNSFORWARDER_CONF
eval "makelist 'UDPGroup' $udp_group" >> $DNSFORWARDER_CONF
eval "makelist 'GroupFile' $group_file" >> $DNSFORWARDER_CONF
if [ $gfw = "true" ]; then
echo 'GroupFile /etc/dnsforwarder/gfw.txt' >> $DNSFORWARDER_CONF
fi
@ -136,14 +140,14 @@ makeconfig () {
echo "BlockNegativeResponse ${block_negative_resp}" >> $DNSFORWARDER_CONF
eval "makelist 'AppendHosts' $append_host" >> $DNSFORWARDER_CONF
echo "BlockIpv6WhenIpv4Exists ${block_ipv6}" >> $DNSFORWARDER_CONF
echo "UseCache ${cache}" >> $DNSFORWARDER_CONF
if [ $cache = "true" ]; then
echo "CacheSize ${cache_size}" >> $DNSFORWARDER_CONF
echo "MemoryCache false" >> $DNSFORWARDER_CONF
echo "CacheFile /tmp/dnsforwarder.cache" >> $DNSFORWARDER_CONF
echo "IgnoreTTL ${cache_ignore}" >> $DNSFORWARDER_CONF
eval "makelist 'CacheControl' $cache_control" >> $DNSFORWARDER_CONF
eval "makelist 'CacheControl' $cache_control" >> $DNSFORWARDER_CONF
echo "ReloadCache true" >> $DNSFORWARDER_CONF
echo "OverwriteCache true" >> $DNSFORWARDER_CONF
fi
@ -168,7 +172,7 @@ start()
if [ $vt_enabled = 0 ]; then
echo dnsforwarder is not enabled
exit
fi
fi
makeconfig
fixflowoffload
dnsforwarder -f $DNSFORWARDER_CONF -d
@ -182,14 +186,14 @@ start()
local dnsmasq=$(uci get dnsforwarder.@arguments[0].dnsmasq 2>/dev/null)
local addr=$(uci get dnsforwarder.@arguments[0].addr 2>/dev/null)
[ -n "${addr}" ] && addr=${addr/:/#}
if [ "${dnsmasq}" = "1" ]; then
uci delete dhcp.@dnsmasq[0].server 2>/dev/null
# uci add_list dhcp.@dnsmasq[0].server=$addr
uci delete dhcp.@dnsmasq[0].resolvfile 2>/dev/null
uci set dhcp.@dnsmasq[0].noresolv=1
uci set dhcp.@dnsmasq[0].serversfile=/tmp/dnsmasq.dnsforwarder.conf
uci commit dhcp
uci commit dhcp
/etc/init.d/dnsmasq restart
fi
add_cron
@ -205,7 +209,7 @@ stop()
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.d/resolv.conf.auto 2>/dev/null
uci delete dhcp.@dnsmasq[0].noresolv 2>/dev/null
uci delete dhcp.@dnsmasq[0].serversfile 2>/dev/null
uci commit dhcp
uci commit dhcp
/etc/init.d/dnsmasq restart
[ -e ${PID_FILE} ] && {
pid=$(cat ${PID_FILE})
@ -227,18 +231,18 @@ restart()
logger -t There is dnsforwarder pid ${pid}
stop
} || {
logger -t Dnsforwarder is not running
logger -t Dnsforwarder is not running
}
sleep 7
local vt_enabled=$(uci get dnsforwarder.@arguments[0].enabled 2>/dev/null)
echo dnsforwarder status is ${vt_enabled}
echo dnsforwarder status is ${vt_enabled}
logger -t Dnsforwarder is initializing enabled is ${vt_enabled}
if [ ${vt_enabled} = 1 ]; then
[ -n "$pid" ] && {
logger -t There is dnsforwarder pid ${pid}
stop
} || {
logger -t Dnsforwarder is not running
logger -t Dnsforwarder is not running
}
logger -t Restarting dnsforwarder
@ -247,5 +251,3 @@ restart()
/etc/init.d/dnsforwarder disable
fi
}
EXTRA_COMMANDS="makeconfig makegfwlist health"

View File

@ -3,8 +3,10 @@
START=96
STOP=10
extra_command "add_rule"
extra_command "del_rule"
extra_command "reload_rule"
EXTRA_COMMANDS="add_rule del_rule reload_rule"
PROG_PATH=/usr/share/adbyby
DATA_PATH=$PROG_PATH/data
WAN_FILE=/var/etc/dnsmasq-adbyby.d/03-adbyby-ipset.conf
@ -20,7 +22,7 @@ uci_get_by_name() {
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)
@ -65,7 +67,7 @@ ip_rule()
ipset -N adbyby_esc hash:ip
$ipt_n -A ADBYBY -m set --match-set adbyby_esc dst -j RETURN
local icount=$(uci show adbyby | grep 'filter_mode' | wc -l)
let icount=icount-1
for i in $(seq 0 $icount)
@ -82,9 +84,9 @@ ip_rule()
;;
esac
done
case $wan_mode in
0)
;;
@ -96,7 +98,7 @@ ip_rule()
$ipt_n -A ADBYBY -j RETURN
;;
esac
echo "create blockip hash:net family inet hashsize 1024 maxelem 65536" > /tmp/blockip.ipset
awk '!/^$/&&!/^#/{printf("add blockip %s'" "'\n",$0)}' /usr/share/adbyby/blockip.conf >> /tmp/blockip.ipset
ipset -! restore < /tmp/blockip.ipset 2>/dev/null
@ -113,7 +115,7 @@ add_dns()
awk '!/^$/&&!/^#/{printf("address=/%s/'"0.0.0.0"'\n",$0)}' $PROG_PATH/adblack.conf > /var/etc/dnsmasq-adbyby.d/07-dnsmasq.black
echo 'conf-dir=/var/etc/dnsmasq-adbyby.d' > /tmp/dnsmasq.d/dnsmasq-adbyby.conf
local var=1
if [ $wan_mode -eq 1 ]; then
awk '!/^$/&&!/^#/{printf("ipset=/%s/'"adbyby_wan"'\n",$0)}' $PROG_PATH/adhost.conf > $WAN_FILE
@ -123,14 +125,14 @@ add_dns()
cp /usr/share/adbyby/dnsmasq.ads /var/etc/dnsmasq-adbyby.d/05-dnsmasq.ads
fi
fi
mkdir -p /tmp/adbyby/rules/data /tmp/adbyby/rules/host
rm -f /tmp/adbyby/rules/data/* /tmp/adbyby/rules/host/*
cp -a /usr/share/adbyby/rules/data/* /tmp/adbyby/rules/data 2>/dev/null
cp -a /usr/share/adbyby/rules/host/* /tmp/adbyby/rules/host 2>/dev/null
echo 'addn-hosts=/tmp/adbyby/rules/host/' >> /tmp/dnsmasq.d/dnsmasq-adbyby.conf
echo 'conf-dir=/tmp/adbyby/rules/data' >> /tmp/dnsmasq.d/dnsmasq-adbyby.conf
[ $block_ios -eq 1 ] && echo 'address=/mesu.apple.com/0.0.0.0' >> /tmp/dnsmasq.d/dnsmasq-adbyby.conf
if [ $block_douyin -eq 1 ]; then
cat <<-EOF >/tmp/etc/dnsmasq-adbyby.d/08-dnsmasq.douyin
@ -166,7 +168,7 @@ add_rule()
fi
$ipt_n -A ADBYBY -p tcp -j REDIRECT --to-ports 8118 2>/dev/null
$ipt_n -I PREROUTING -p tcp --dport 80 -j ADBYBY 2>/dev/null
mkdir -p /var/etc
echo -e "/etc/init.d/adbyby restart" > "/var/etc/adbyby.include"
}
@ -199,14 +201,14 @@ start()
{
config_load adbyby
config_foreach get_config adbyby
if [ $enable -ne 0 ]; then
add_cron
[ ! -d "/tmp/adbyby/data" ] && cp -a /usr/share/adbyby /tmp/ && rm -f /tmp/adbyby.updated
add_rules
/tmp/adbyby/adbyby >/dev/null 2>&1 &
add_dns
add_rule
/etc/init.d/dnsmasq restart

View File

@ -11,9 +11,10 @@
START=90
STOP=15
extra_command "rules"
SERVICE_DAEMONIZE=1
NAME=brook
EXTRA_COMMANDS=rules
FWI=$(uci get firewall.brook.path 2>/dev/null)
uci_get_by_name() {
@ -225,4 +226,4 @@ stop() {
kill -9 $pid
done
fi
}
}

View File

@ -7,11 +7,9 @@ START=95
USE_PROCD=1
#PROCD_DEBUG=1
EXTRA_COMMANDS="status flush libver"
EXTRA_HELP=\
" flush Flush DNS cache stored in Pcap_DNSProxy and DNSMasq
libver Print library version Pcap_DNSProxy linked to
status Show the running status of Pcap_DNSProxy"
extra_command "flush" "Flush DNS cache stored in Pcap_DNSProxy and DNSMasq"
extra_command "libver" "Print library version Pcap_DNSProxy linked to"
extra_command "status" "Show the running status of Pcap_DNSProxy"
PROG=/usr/sbin/Pcap_DNSProxy
CONFDIR=/etc/pcap-dnsproxy

View File

@ -7,10 +7,7 @@ USE_PROCD=1
SCUTCLIENT_PATH=/usr/bin/scutclient
SCUTCLIENT_CONFIG=scutclient
EXTRA_COMMANDS="logoff"
EXTRA_HELP=<<EOF
logoff Log off manually
EOF
extra_command "logoff" "Log off manually"
scutclient_validate_drcom() {
uci_validate_section scutclient drcom "${1}" \