mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-25 07:33:43 +00:00
Merge development into development-v6
This commit is contained in:
commit
200a82acfb
1 changed files with 65 additions and 62 deletions
37
gravity.sh
37
gravity.sh
|
@ -543,19 +543,23 @@ gravity_DownloadBlocklistFromUrl() {
|
||||||
# Check if this IP matches any IP of the system
|
# Check if this IP matches any IP of the system
|
||||||
if [[ -n "${ip}" && $(grep -Ec "inet(|6) ${ip}" <<<"$(ip a)") -gt 0 ]]; then
|
if [[ -n "${ip}" && $(grep -Ec "inet(|6) ${ip}" <<<"$(ip a)") -gt 0 ]]; then
|
||||||
blocked=true
|
blocked=true
|
||||||
fi;;
|
fi
|
||||||
|
;;
|
||||||
"NXDOMAIN")
|
"NXDOMAIN")
|
||||||
if [[ $(dig "${domain}" | grep "NXDOMAIN" -c) -ge 1 ]]; then
|
if [[ $(dig "${domain}" | grep "NXDOMAIN" -c) -ge 1 ]]; then
|
||||||
blocked=true
|
blocked=true
|
||||||
fi;;
|
fi
|
||||||
|
;;
|
||||||
"NODATA")
|
"NODATA")
|
||||||
if [[ $(dig "${domain}" | grep "NOERROR" -c) -ge 1 ]] && [[ -z $(dig +short "${domain}") ]]; then
|
if [[ $(dig "${domain}" | grep "NOERROR" -c) -ge 1 ]] && [[ -z $(dig +short "${domain}") ]]; then
|
||||||
blocked=true
|
blocked=true
|
||||||
fi;;
|
fi
|
||||||
|
;;
|
||||||
"NULL" | *)
|
"NULL" | *)
|
||||||
if [[ $(dig "${domain}" +short | grep "0.0.0.0" -c) -ge 1 ]]; then
|
if [[ $(dig "${domain}" +short | grep "0.0.0.0" -c) -ge 1 ]]; then
|
||||||
blocked=true
|
blocked=true
|
||||||
fi;;
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ "${blocked}" == true ]]; then
|
if [[ "${blocked}" == true ]]; then
|
||||||
|
@ -586,7 +590,7 @@ gravity_DownloadBlocklistFromUrl() {
|
||||||
else
|
else
|
||||||
port=80
|
port=80
|
||||||
fi
|
fi
|
||||||
echo -e "${OVER} ${CROSS} ${str} ${domain} is blocked by one of your lists. Using DNS server ${upstream} instead";
|
echo -e "${OVER} ${CROSS} ${str} ${domain} is blocked by one of your lists. Using DNS server ${upstream} instead"
|
||||||
echo -ne " ${INFO} ${str} Pending..."
|
echo -ne " ${INFO} ${str} Pending..."
|
||||||
cmd_ext="--resolve $domain:$port:$ip"
|
cmd_ext="--resolve $domain:$port:$ip"
|
||||||
fi
|
fi
|
||||||
|
@ -598,25 +602,21 @@ gravity_DownloadBlocklistFromUrl() {
|
||||||
# running the script.
|
# running the script.
|
||||||
if [[ $url == "file://"* ]]; then
|
if [[ $url == "file://"* ]]; then
|
||||||
# Get the file path
|
# Get the file path
|
||||||
file_path=$(echo "$url" | cut --delimiter='/' --fields=3-)
|
file_path=$(echo "$url" | cut -d'/' -f3-)
|
||||||
# Check if the file exists and is a regular file (or a symlink to one)
|
# Check if the file exists and is a regular file (i.e. not a socket, fifo, tty, block). Might still be a symlink.
|
||||||
if [[ ! -e $file_path ]]; then
|
if [[ ! -f $file_path ]]; then
|
||||||
# Output that the file does not exist
|
# Output that the file does not exist
|
||||||
echo -e "${OVER} ${CROSS} ${file_path} does not exist"
|
echo -e "${OVER} ${CROSS} ${file_path} does not exist"
|
||||||
download=false
|
download=false
|
||||||
elif [[ ! -f $file_path ]]; then
|
|
||||||
# Output that the file is not a regular file
|
|
||||||
echo -e "${OVER} ${CROSS} ${file_path} is not a regular file"
|
|
||||||
download=false
|
|
||||||
else
|
else
|
||||||
# Check if the file has a+r permissions
|
# Check if the file or a file referenced by the symlink has a+r permissions
|
||||||
permissions=$(stat --dereference --format="%a" "$file_path")
|
permissions=$(stat -L -c "%a" "$file_path")
|
||||||
if [[ $permissions == *4 || $permissions == *5 || $permissions == *6 || $permissions == *7 ]]; then
|
if [[ $permissions == *4 || $permissions == *5 || $permissions == *6 || $permissions == *7 ]]; then
|
||||||
# Output that we are using the local file
|
# Output that we are using the local file
|
||||||
echo -e "${OVER} ${INFO} Using local file ${file_path}"
|
echo -e "${OVER} ${INFO} Using local file ${file_path}"
|
||||||
else
|
else
|
||||||
# Output that the file does not have the correct permissions
|
# Output that the file does not have the correct permissions
|
||||||
echo -e "${OVER} ${CROSS} Cannot read file (file needs to have o+r permission)"
|
echo -e "${OVER} ${CROSS} Cannot read file (file needs to have a+r permission)"
|
||||||
download=false
|
download=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -624,7 +624,7 @@ gravity_DownloadBlocklistFromUrl() {
|
||||||
|
|
||||||
if [[ "${download}" == true ]]; then
|
if [[ "${download}" == true ]]; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
httpCode=$(curl --connect-timeout ${curl_connect_timeout} --silent --location ${compression} ${cmd_ext} ${heisenbergCompensator} --write-out "%{http_code}" "${url}" --output "${listCurlBuffer}" 2>/dev/null)
|
httpCode=$(curl --connect-timeout ${curl_connect_timeout} -s -L ${compression} ${cmd_ext} ${heisenbergCompensator} -w "%{http_code}" "${url}" -o "${listCurlBuffer}" 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $url in
|
case $url in
|
||||||
|
@ -900,7 +900,10 @@ for var in "$@"; do
|
||||||
case "${var}" in
|
case "${var}" in
|
||||||
"-f" | "--force") forceDelete=true ;;
|
"-f" | "--force") forceDelete=true ;;
|
||||||
"-r" | "--repair") repairSelector "$3" ;;
|
"-r" | "--repair") repairSelector "$3" ;;
|
||||||
"-u" | "--upgrade" ) upgrade_gravityDB "${gravityDBfile}" "${piholeDir}"; exit 0;;
|
"-u" | "--upgrade")
|
||||||
|
upgrade_gravityDB "${gravityDBfile}" "${piholeDir}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
"-h" | "--help") helpFunc ;;
|
"-h" | "--help") helpFunc ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue