HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: /volume1/@appstore/DNSServer/script/flushcache.sh
#!/bin/sh

ChrootDir="/var/packages/DNSServer/target/named"
RndcKeyFile=${ChrootDir}"/rndc.key"
BinDir="/var/packages/DNSServer/target/bin"

name="$1"
view="$2"

. /var/packages/DNSServer/scripts/start-stop-status
ChangeOwner

cd ${BinDir}

if [ "x"  = "x$name" ]; then
	./rndc -k ${RndcKeyFile} flush ${view}
else
	./rndc -k ${RndcKeyFile} flushtree ${name} ${view}
	# work around for this bug:
	# -------------------------------------------------------------------------
	# If create forward zone with a forwarder ip which
	# doesn't contains the specified zone. After this zone create,
	# any change of forwarder ip will flush doamin cache failed even
	# this forwarder ip contains the specified zone.
	# (ie. flush by ./rndc flushtree always fail)
	#
	# When this issue occurs,
	# only ./rndc flush (ie. flush all domains) can solve the issue.
	#--------------------------------------------------------------------------
	result=`./dig @localhost "$name" +short`
	if [ "$?" = "0" ] && [ "x$result" = "x" ]; then # use dig to find if flushtree fail or success
		./rndc -k ${RndcKeyFile} flush ${view}
	fi
fi