Skip to content

Commit

Permalink
v8.6-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ngadmini committed Jan 2, 2023
1 parent 0bd7550 commit b115956
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
9 changes: 8 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ license:
*) For more information, please refer to <https://creativecommons.org/licenses/by-sa/4.0/>

what's new in v8.6:
*) major updating
*) move variables that located in grab_http to grab_config
*) updating grab_http and grab_library

Get url to download script-pack (latest version) :
~ curl -s https://api.github.com/repos/ngadmini/Grabbing-Blacklist-for-Bind9-RPZ/releases/latest \
Expand Down Expand Up @@ -86,6 +87,9 @@ prerequisites:
# specify in fqdn or ip-address
HOST=rpz.warnet-ersa.net

# fixed number of lines grab_regex
REGEX=4

# reload Remote Name Daemon Control (rndc)
# set 'yes' to run <rndc reload> or 'no' to <reboot>
RNDC_RELOAD=yes
Expand All @@ -104,6 +108,9 @@ prerequisites:
# NS-IP Trigger with NXDOMAIN Action for ip-address-list
RPZ_IPV=rpz-nsip CNAME .

# fixed number of lines grab_urls
URLS=22

# change to directory where zone-files (rpz.* and db.*) are located in bind9-server
ZONE_DIR=/var/bind9/chroot/etc/bind/zones-rpz

Expand Down
15 changes: 9 additions & 6 deletions libs/grab_config
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
# like in grab_library, instead of changing them here directly.
# go to grab_library line:
# ~ nano +$(grep -n 'f_dft()' grab_library | cut -d: -f1) grab_library
###########################################################################
##################################################################################

# identify clearly and with certainty host-name in FQDN
# or ip-address of your bind9-server
# use fqdn
# identify clearly and with certainty host-name in FQDN or ip-address bind9-server
# use fqdn or ip-address
# HOST=rpz.warnet-ersa.net
# or ip-address
# HOST=172.30.254.253
HOST=rpz.warnet-ersa.net

# fixed number of lines grab_regex
REGEX=4

# bind9-server need reload rndc (Remote Name Daemon Control)
# after syncronizing new dataBASE. but some server with low_RAM
# will out off memory. in this case you could 'reboot' it.
Expand All @@ -46,6 +47,8 @@ RNDC_RELOAD=no
RPZ_DOM=CNAME .
RPZ_IPV=rpz-nsip CNAME .

# fixed number of lines grab_urls
URLS=22

# change to directory where zone-files (rpz.*) and db-files (db.*) are located
#ZONE_DIR=/var/bind9/chroot/etc/bind/zones-rpz
ZONE_DIR=/etc/bind/zones-rpz
10 changes: 4 additions & 6 deletions libs/grab_http.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ f_ok
ar_shy=(grab_build.sh grab_cereal.sh grab_duplic.sh grab_rsync.sh)
ar_shn=(grab_regex grab_urls)
ar_pac=()

declare -A ar_num # numeric value
ar_num[ar_txt]=1 # index's position of: ipv4 category is no.1 at ar_txt
ar_num[ar_shn]=0 #+ grab_regex is no.0 at ar_shn
ar_num[ar_url]=22 # fixed number of lines: grab_urls
ar_num[ar_reg]=4 #+ grab_regex
f_cnf

# requirement inspection
printf "${_pre} %-63s" "check required debian-packages in local-host: $(hostname -I)"
Expand Down Expand Up @@ -94,17 +92,17 @@ for E in "${!ar_shn[@]}"; do

if [[ ${E} -eq ${ar_num[ar_shn]} ]]; then
mapfile -t ar_reg < "${ar_shn[E]}"
[[ ${#ar_reg[@]} -eq ${ar_num[ar_reg]} ]] || f_xcd 249 "${ar_shn[E]}"
[[ ${#ar_reg[@]} -eq ${REGEX} ]] || f_xcd 249 "${ar_shn[E]}"
else
mapfile -t ar_url < "${ar_shn[E]}"
[[ ${#ar_url[@]} -eq ${ar_num[ar_url]} ]] || f_xcd 248 "${ar_shn[E]}"
[[ ${#ar_url[@]} -eq ${URLS} ]] || f_xcd 248 "${ar_shn[E]}"
fi
done
f_ok

printf "${_pre} check availability of remote-files (in %s)\n" "${ar_shn[1]}"
f_uri "${ar_shn[1]}" || :
f_grb # initialize, grabbing and processing raw-domains (CATEGORY)
f_grb # initialize, grabbing and processing raw-domains (CATEGORY)

# category: TRUST+ --> ${ar_cat[5]} with 3 additional entries: ${ar_url[1,7]}
# contents: gambling and [TRUST+Positif](https://trustpositif.kominfo.go.id/)
Expand Down
9 changes: 5 additions & 4 deletions libs/grab_library
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ f_xcd() { # exit code {244..255}
}

f_sm0() { # display offering options
f_cnf
printf "${_wn1} there are still remaining duplicate entries between CATEGORIES\n"
printf "${_hnt} consider continue to next TASKs\n"
printf "${_CYN}\n" "you have 4 options to proceed to the next task:"
Expand Down Expand Up @@ -327,11 +326,13 @@ f_sta() { if [[ $(stat -c "%a" "$2") != "$1" ]]; then chmod "$1" "$2"; fi; }
f_stt() { printf "\n${_RED}\nstarting ${0##*/} ${_ver} at ${_CYN}\n" "$1" "${_lct}"; f_ver; }

f_dft() { # define default values in grab_config
printf "${_inf} forking ${_CYN} with default configurations:\n" "${_foo}"
printf "${_inf} forking ${_CYN} with default configurations\n" "${_foo}"
: "${HOST:=rpz.warnet-ersa.net}" # or ip-address
: "${REGEX:=4}" # fixed number of lines grab_regex
: "${RNDC_RELOAD:=no}" # yes OR no
: "${RPZ_DOM:=CNAME .}" # rpz policy
: "${RPZ_IPV:=rpz-nsip CNAME .}" #
: "${RPZ_IPV:=rpz-nsip CNAME .}" #+
: "${URLS:=22}" # fixed number of lines grab_urls
: "${ZONE_DIR:=/etc/bind/zones-rpz}" # target dir for rsync
}

Expand All @@ -340,7 +341,7 @@ f_cnf() { # valuation variables in grab_config
local _ptr="s/=[ ^ ]/=/g;s/['\"]//g;s/[#;].*//g;s/[[:space:]]+/ /g;s/[[:space:]]$//g"
if [[ -e ${CNF} ]]; then
f_sta 644 "${CNF}"
ar_cnf=(HOST RNDC_RELOAD RPZ_DOM RPZ_IPV ZONE_DIR)
ar_cnf=(HOST REGEX RNDC_RELOAD RPZ_DOM RPZ_IPV URLS ZONE_DIR)
mapfile -t ar_CNF < <(_srt "${CNF}" | _grp -E "^[A-Z]" | _sed "s/[ ^ ]=/=/g" | cut -d= -f1)
if [[ ${ar_CNF[*]} == "${ar_cnf[*]}" ]]; then
mapfile -t ar_VAR < <(_srt "${CNF}" | _grp -E "^[A-Z]" | _sed "${_ptr}" | cut -d= -f2)
Expand Down

0 comments on commit b115956

Please sign in to comment.