mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-25 14:20:18 +00:00
Merge branch 'development' into fix/issue-template
This commit is contained in:
commit
16d67f55b3
6 changed files with 303 additions and 253 deletions
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
# Pi-hole: A black hole for Internet advertisements
|
# Pi-hole: A black hole for Internet advertisements
|
||||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||||
# Network-wide ad blocking via your own hardware.
|
# Network-wide ad blocking via your own hardware.
|
||||||
|
@ -91,10 +92,10 @@ printFunc() {
|
||||||
printf "%s%s$spc" "$title" "$text_main"
|
printf "%s%s$spc" "$title" "$text_main"
|
||||||
|
|
||||||
if [[ -n "$text_addn" ]]; then
|
if [[ -n "$text_addn" ]]; then
|
||||||
printf "%s(%s)%s\n" "$COL_NC$COL_DARK_GRAY" "$text_addn" "$COL_NC"
|
printf "%s(%s)%s\\n" "$COL_NC$COL_DARK_GRAY" "$text_addn" "$COL_NC"
|
||||||
else
|
else
|
||||||
# Do not print trailing newline on final line
|
# Do not print trailing newline on final line
|
||||||
[[ -z "$text_last" ]] && printf "%s\n" "$COL_NC"
|
[[ -z "$text_last" ]] && printf "%s\\n" "$COL_NC"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +127,7 @@ get_init_stats() {
|
||||||
mins=$(( ($1%3600)/60 )); secs=$(( $1%60 ))
|
mins=$(( ($1%3600)/60 )); secs=$(( $1%60 ))
|
||||||
[[ "$day" -ge "2" ]] && plu="s"
|
[[ "$day" -ge "2" ]] && plu="s"
|
||||||
[[ "$day" -ge "1" ]] && days="$day day${plu}, " || days=""
|
[[ "$day" -ge "1" ]] && days="$day day${plu}, " || days=""
|
||||||
printf "%s%02d:%02d:%02d\n" "$days" "$hrs" "$mins" "$secs"
|
printf "%s%02d:%02d:%02d\\n" "$days" "$hrs" "$mins" "$secs"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set Colour Codes
|
# Set Colour Codes
|
||||||
|
@ -285,6 +286,7 @@ get_sys_stats() {
|
||||||
sys_loadavg=$(cut -d " " -f1,2,3 /proc/loadavg)
|
sys_loadavg=$(cut -d " " -f1,2,3 /proc/loadavg)
|
||||||
|
|
||||||
# Get CPU usage, only counting processes over 1% as active
|
# Get CPU usage, only counting processes over 1% as active
|
||||||
|
# shellcheck disable=SC2009
|
||||||
cpu_raw=$(ps -eo pcpu,rss --no-headers | grep -E -v " 0")
|
cpu_raw=$(ps -eo pcpu,rss --no-headers | grep -E -v " 0")
|
||||||
cpu_tasks=$(wc -l <<< "$cpu_raw")
|
cpu_tasks=$(wc -l <<< "$cpu_raw")
|
||||||
cpu_taskact=$(sed -r "/(^ 0.)/d" <<< "$cpu_raw" | wc -l)
|
cpu_taskact=$(sed -r "/(^ 0.)/d" <<< "$cpu_raw" | wc -l)
|
||||||
|
@ -306,7 +308,7 @@ get_sys_stats() {
|
||||||
# Determine colour for temperature
|
# Determine colour for temperature
|
||||||
if [[ -n "$temp_file" ]]; then
|
if [[ -n "$temp_file" ]]; then
|
||||||
if [[ "$temp_unit" == "C" ]]; then
|
if [[ "$temp_unit" == "C" ]]; then
|
||||||
cpu_temp=$(printf "%.0fc\n" "$(calcFunc "$(< $temp_file) / 1000")")
|
cpu_temp=$(printf "%.0fc\\n" "$(calcFunc "$(< $temp_file) / 1000")")
|
||||||
|
|
||||||
case "${cpu_temp::-1}" in
|
case "${cpu_temp::-1}" in
|
||||||
-*|[0-9]|[1-3][0-9]) cpu_col="$COL_LIGHT_BLUE";;
|
-*|[0-9]|[1-3][0-9]) cpu_col="$COL_LIGHT_BLUE";;
|
||||||
|
@ -320,7 +322,7 @@ get_sys_stats() {
|
||||||
cpu_temp_str=" @ $cpu_col$cpu_temp$COL_NC$COL_DARK_GRAY"
|
cpu_temp_str=" @ $cpu_col$cpu_temp$COL_NC$COL_DARK_GRAY"
|
||||||
|
|
||||||
elif [[ "$temp_unit" == "F" ]]; then
|
elif [[ "$temp_unit" == "F" ]]; then
|
||||||
cpu_temp=$(printf "%.0ff\n" "$(calcFunc "($(< $temp_file) / 1000) * 9 / 5 + 32")")
|
cpu_temp=$(printf "%.0ff\\n" "$(calcFunc "($(< $temp_file) / 1000) * 9 / 5 + 32")")
|
||||||
|
|
||||||
case "${cpu_temp::-1}" in
|
case "${cpu_temp::-1}" in
|
||||||
-*|[0-9]|[0-9][0-9]) cpu_col="$COL_LIGHT_BLUE";;
|
-*|[0-9]|[0-9][0-9]) cpu_col="$COL_LIGHT_BLUE";;
|
||||||
|
@ -333,7 +335,7 @@ get_sys_stats() {
|
||||||
cpu_temp_str=" @ $cpu_col$cpu_temp$COL_NC$COL_DARK_GRAY"
|
cpu_temp_str=" @ $cpu_col$cpu_temp$COL_NC$COL_DARK_GRAY"
|
||||||
|
|
||||||
else
|
else
|
||||||
cpu_temp_str=$(printf " @ %.0fk\n" "$(calcFunc "($(< $temp_file) / 1000) + 273.15")")
|
cpu_temp_str=$(printf " @ %.0fk\\n" "$(calcFunc "($(< $temp_file) / 1000) + 273.15")")
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
cpu_temp_str=""
|
cpu_temp_str=""
|
||||||
|
@ -365,12 +367,12 @@ get_ftl_stats() {
|
||||||
local stats_raw
|
local stats_raw
|
||||||
|
|
||||||
mapfile -t stats_raw < <(pihole-FTL "stats")
|
mapfile -t stats_raw < <(pihole-FTL "stats")
|
||||||
domains_being_blocked_raw="${stats_raw[1]#* }"
|
domains_being_blocked_raw="${stats_raw[0]#* }"
|
||||||
dns_queries_today_raw="${stats_raw[3]#* }"
|
dns_queries_today_raw="${stats_raw[1]#* }"
|
||||||
ads_blocked_today_raw="${stats_raw[5]#* }"
|
ads_blocked_today_raw="${stats_raw[2]#* }"
|
||||||
ads_percentage_today_raw="${stats_raw[7]#* }"
|
ads_percentage_today_raw="${stats_raw[3]#* }"
|
||||||
queries_forwarded_raw="${stats_raw[11]#* }"
|
queries_forwarded_raw="${stats_raw[5]#* }"
|
||||||
queries_cached_raw="${stats_raw[13]#* }"
|
queries_cached_raw="${stats_raw[6]#* }"
|
||||||
|
|
||||||
# Only retrieve these stats when not called from jsonFunc
|
# Only retrieve these stats when not called from jsonFunc
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
|
@ -378,11 +380,11 @@ get_ftl_stats() {
|
||||||
local top_domain_raw
|
local top_domain_raw
|
||||||
local top_client_raw
|
local top_client_raw
|
||||||
|
|
||||||
domains_being_blocked=$(printf "%.0f\n" "${domains_being_blocked_raw}")
|
domains_being_blocked=$(printf "%.0f\\n" "${domains_being_blocked_raw}")
|
||||||
dns_queries_today=$(printf "%.0f\n" "${dns_queries_today_raw}")
|
dns_queries_today=$(printf "%.0f\\n" "${dns_queries_today_raw}")
|
||||||
ads_blocked_today=$(printf "%.0f\n" "${ads_blocked_today_raw}")
|
ads_blocked_today=$(printf "%.0f\\n" "${ads_blocked_today_raw}")
|
||||||
ads_percentage_today=$(printf "%'.0f\n" "${ads_percentage_today_raw}")
|
ads_percentage_today=$(printf "%'.0f\\n" "${ads_percentage_today_raw}")
|
||||||
queries_cached_percentage=$(printf "%.0f\n" "$(calcFunc "$queries_cached_raw * 100 / ( $queries_forwarded_raw + $queries_cached_raw )")")
|
queries_cached_percentage=$(printf "%.0f\\n" "$(calcFunc "$queries_cached_raw * 100 / ( $queries_forwarded_raw + $queries_cached_raw )")")
|
||||||
recent_blocked=$(pihole-FTL recentBlocked)
|
recent_blocked=$(pihole-FTL recentBlocked)
|
||||||
read -r -a top_ad_raw <<< "$(pihole-FTL "top-ads (1)")"
|
read -r -a top_ad_raw <<< "$(pihole-FTL "top-ads (1)")"
|
||||||
read -r -a top_domain_raw <<< "$(pihole-FTL "top-domains (1)")"
|
read -r -a top_domain_raw <<< "$(pihole-FTL "top-domains (1)")"
|
||||||
|
@ -412,6 +414,8 @@ get_strings() {
|
||||||
used_str="Used: "
|
used_str="Used: "
|
||||||
leased_str="Leased: "
|
leased_str="Leased: "
|
||||||
domains_being_blocked=$(printf "%'.0f" "$domains_being_blocked")
|
domains_being_blocked=$(printf "%'.0f" "$domains_being_blocked")
|
||||||
|
ads_blocked_today=$(printf "%'.0f" "$ads_blocked_today")
|
||||||
|
dns_queries_today=$(printf "%'.0f" "$dns_queries_today")
|
||||||
ph_info="Blocking: $domains_being_blocked sites"
|
ph_info="Blocking: $domains_being_blocked sites"
|
||||||
total_str="Total: "
|
total_str="Total: "
|
||||||
else
|
else
|
||||||
|
@ -473,8 +477,8 @@ chronoFunc() {
|
||||||
${COL_DARK_GRAY}$scr_line_str${COL_NC}"
|
${COL_DARK_GRAY}$scr_line_str${COL_NC}"
|
||||||
else
|
else
|
||||||
echo -e "[0;1;31;91m|¯[0;1;33;93m¯[0;1;32;92m¯[0;1;32;92m(¯[0;1;36;96m)[0;1;34;94m_[0;1;35;95m|[0;1;33;93m¯[0;1;31;91m|_ [0;1;32;92m__[0;1;36;96m_|[0;1;31;91m¯[0;1;34;94m|[0;1;35;95m__[0;1;31;91m_[0m$phc_ver_str
|
echo -e "[0;1;31;91m|¯[0;1;33;93m¯[0;1;32;92m¯[0;1;32;92m(¯[0;1;36;96m)[0;1;34;94m_[0;1;35;95m|[0;1;33;93m¯[0;1;31;91m|_ [0;1;32;92m__[0;1;36;96m_|[0;1;31;91m¯[0;1;34;94m|[0;1;35;95m__[0;1;31;91m_[0m$phc_ver_str
|
||||||
[0;1;33;93m| ¯[0;1;32;92m_[0;1;36;96m/¯[0;1;34;94m|[0;1;35;95m_[0;1;31;91m| [0;1;33;93m' [0;1;32;92m\/ [0;1;36;96m_ [0;1;34;94m\ [0;1;35;95m/ [0;1;31;91m-[0;1;33;93m_)[0m$lte_ver_str
|
[0;1;33;93m| ¯[0;1;32;92m_[0;1;36;96m/¯[0;1;34;94m|[0;1;35;95m_[0;1;31;91m| [0;1;33;93m' [0;1;32;92m\\/ [0;1;36;96m_ [0;1;34;94m\\ [0;1;35;95m/ [0;1;31;91m-[0;1;33;93m_)[0m$lte_ver_str
|
||||||
[0;1;32;92m|_[0;1;36;96m| [0;1;34;94m|_[0;1;35;95m| [0;1;33;93m|_[0;1;32;92m||[0;1;36;96m_\[0;1;34;94m__[0;1;35;95m_/[0;1;31;91m_\[0;1;33;93m__[0;1;32;92m_|[0m$ftl_ver_str
|
[0;1;32;92m|_[0;1;36;96m| [0;1;34;94m|_[0;1;35;95m| [0;1;33;93m|_[0;1;32;92m||[0;1;36;96m_\\[0;1;34;94m__[0;1;35;95m_/[0;1;31;91m_\\[0;1;33;93m__[0;1;32;92m_|[0m$ftl_ver_str
|
||||||
${COL_DARK_GRAY}$scr_line_str${COL_NC}"
|
${COL_DARK_GRAY}$scr_line_str${COL_NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,9 @@ readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
PH_TEST=true
|
PH_TEST=true
|
||||||
|
|
||||||
# Have to ignore the following rule as spaces in paths are not supported by ShellCheck
|
# shellcheck disable=SC1090
|
||||||
#shellcheck disable=SC1090
|
|
||||||
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
|
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
|
||||||
|
# shellcheck disable=SC1091
|
||||||
source "/opt/pihole/COL_TABLE"
|
source "/opt/pihole/COL_TABLE"
|
||||||
|
|
||||||
# is_repo() sourced from basic-install.sh
|
# is_repo() sourced from basic-install.sh
|
||||||
|
@ -51,15 +50,15 @@ GitCheckUpdateAvail() {
|
||||||
# defaults to the current one.
|
# defaults to the current one.
|
||||||
REMOTE="$(git rev-parse "@{upstream}")"
|
REMOTE="$(git rev-parse "@{upstream}")"
|
||||||
|
|
||||||
if [[ ${#LOCAL} == 0 ]]; then
|
if [[ "${#LOCAL}" == 0 ]]; then
|
||||||
echo -e " ${COL_LIGHT_RED}Error: Local revision could not be obtained, ask Pi-hole support."
|
echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support
|
||||||
echo -e " Additional debugging output:${COL_NC}"
|
Additional debugging output:${COL_NC}"
|
||||||
git status
|
git status
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if [[ ${#REMOTE} == 0 ]]; then
|
if [[ "${#REMOTE}" == 0 ]]; then
|
||||||
echo -e " ${COL_LIGHT_RED}Error: Remote revision could not be obtained, ask Pi-hole support."
|
echo -e "\\n ${COL_LIGHT_RED}Error: Remote revision could not be obtained, please contact Pi-hole Support
|
||||||
echo -e " Additional debugging output:${COL_NC}"
|
Additional debugging output:${COL_NC}"
|
||||||
git status
|
git status
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -94,13 +93,15 @@ FTLcheckUpdate() {
|
||||||
main() {
|
main() {
|
||||||
local pihole_version_current
|
local pihole_version_current
|
||||||
local web_version_current
|
local web_version_current
|
||||||
#shellcheck disable=1090,2154
|
local basicError="\\n ${COL_LIGHT_RED}Unable to complete update, please contact Pi-hole Support${COL_NC}"
|
||||||
|
|
||||||
|
# shellcheck disable=1090,2154
|
||||||
source "${setupVars}"
|
source "${setupVars}"
|
||||||
|
|
||||||
#This is unlikely
|
# This is unlikely
|
||||||
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||||
echo -e " ${COL_LIGHT_RED}Critical Error: Core Pi-hole repo is missing from system!"
|
echo -e "\\n ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!
|
||||||
echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
|
Please re-run install script from https://pi-hole.net${COL_NC}"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -108,18 +109,18 @@ main() {
|
||||||
|
|
||||||
if GitCheckUpdateAvail "${PI_HOLE_FILES_DIR}" ; then
|
if GitCheckUpdateAvail "${PI_HOLE_FILES_DIR}" ; then
|
||||||
core_update=true
|
core_update=true
|
||||||
echo -e " ${INFO} Pi-hole Core:\t${COL_YELLOW}update available${COL_NC}"
|
echo -e " ${INFO} Pi-hole Core:\\t${COL_YELLOW}update available${COL_NC}"
|
||||||
else
|
else
|
||||||
core_update=false
|
core_update=false
|
||||||
echo -e " ${INFO} Pi-hole Core:\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
echo -e " ${INFO} Pi-hole Core:\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if FTLcheckUpdate ; then
|
if FTLcheckUpdate ; then
|
||||||
FTL_update=true
|
FTL_update=true
|
||||||
echo -e " ${INFO} FTL:\t\t${COL_YELLOW}update available${COL_NC}"
|
echo -e " ${INFO} FTL:\\t\\t${COL_YELLOW}update available${COL_NC}"
|
||||||
else
|
else
|
||||||
FTL_update=false
|
FTL_update=false
|
||||||
echo -e " ${INFO} FTL:\t\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logic: Don't update FTL when there is a core update available
|
# Logic: Don't update FTL when there is a core update available
|
||||||
|
@ -132,19 +133,19 @@ main() {
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${INSTALL_WEB} == true ]]; then
|
if [[ "${INSTALL_WEB}" == true ]]; then
|
||||||
if ! is_repo "${ADMIN_INTERFACE_DIR}" ; then
|
if ! is_repo "${ADMIN_INTERFACE_DIR}" ; then
|
||||||
echo -e " ${COL_LIGHT_RED}Critical Error: Web Admin repo is missing from system!"
|
echo -e "\\n ${COL_LIGHT_RED}Error: Web Admin repo is missing from system!
|
||||||
echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
|
Please re-run install script from https://pi-hole.net${COL_NC}"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}" ; then
|
if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}" ; then
|
||||||
web_update=true
|
web_update=true
|
||||||
echo -e " ${INFO} Web Interface:\t${COL_YELLOW}update available${COL_NC}"
|
echo -e " ${INFO} Web Interface:\\t${COL_YELLOW}update available${COL_NC}"
|
||||||
else
|
else
|
||||||
web_update=false
|
web_update=false
|
||||||
echo -e " ${INFO} Web Interface:\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
echo -e " ${INFO} Web Interface:\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logic
|
# Logic
|
||||||
|
@ -163,25 +164,24 @@ main() {
|
||||||
echo -e " ${TICK} Everything is up to date!"
|
echo -e " ${TICK} Everything is up to date!"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif ! ${core_update} && ${web_update} ; then
|
elif ! ${core_update} && ${web_update} ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${INFO} Pi-hole Web Admin files out of date"
|
echo -e " ${INFO} Pi-hole Web Admin files out of date"
|
||||||
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
||||||
|
|
||||||
elif ${core_update} && ! ${web_update} ; then
|
elif ${core_update} && ! ${web_update} ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${INFO} Pi-hole core files out of date"
|
echo -e " ${INFO} Pi-hole core files out of date"
|
||||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||||
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || echo -e " ${COL_LIGHT_RED}Unable to complete update, contact Pi-hole${COL_NC}" && exit 1
|
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || \
|
||||||
|
echo -e "${basicError}" && exit 1
|
||||||
elif ${core_update} && ${web_update} ; then
|
elif ${core_update} && ${web_update} ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${INFO} Updating Pi-hole core and web admin files"
|
echo -e " ${INFO} Updating Pi-hole core and web admin files"
|
||||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||||
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --unattended || echo -e " ${COL_LIGHT_RED}Unable to complete update, contact Pi-hole${COL_NC}" && exit 1
|
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --unattended || \
|
||||||
|
echo -e "${basicError}" && exit 1
|
||||||
else
|
else
|
||||||
echo -e " ${COL_LIGHT_RED}Update script has malfunctioned, fallthrough reached. Please contact support${COL_NC}"
|
echo -e " ${COL_LIGHT_RED}Update script has malfunctioned, please contact Pi-hole Support${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else # Web Admin not installed, so only verify if core is up to date
|
else # Web Admin not installed, so only verify if core is up to date
|
||||||
|
@ -193,38 +193,36 @@ main() {
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${INFO} Pi-hole core files out of date"
|
echo -e " ${INFO} Pi-hole Core files out of date"
|
||||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||||
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || echo -e " ${COL_LIGHT_RED}Unable to complete update, contact Pi-hole${COL_NC}" && exit 1
|
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || \
|
||||||
|
echo -e "${basicError}" && exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${web_update}" == true ]]; then
|
if [[ "${web_update}" == true ]]; then
|
||||||
web_version_current="$(/usr/local/bin/pihole version --admin --current)"
|
web_version_current="$(/usr/local/bin/pihole version --admin --current)"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${INFO} Web Admin version is now at ${web_version_current/* v/v}"
|
echo -e " ${INFO} Web Admin version is now at ${web_version_current/* v/v}
|
||||||
echo -e " ${INFO} If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'"
|
${INFO} If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${core_update}" == true ]]; then
|
if [[ "${core_update}" == true ]]; then
|
||||||
pihole_version_current="$(/usr/local/bin/pihole version --pihole --current)"
|
pihole_version_current="$(/usr/local/bin/pihole version --pihole --current)"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${INFO} Pi-hole version is now at ${pihole_version_current/* v/v}"
|
echo -e " ${INFO} Pi-hole version is now at ${pihole_version_current/* v/v}
|
||||||
echo -e " ${INFO} If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'"
|
${INFO} If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${FTL_update} == true ]]; then
|
if [[ "${FTL_update}" == true ]]; then
|
||||||
FTL_version_current="$(/usr/bin/pihole-FTL tag)"
|
FTL_version_current="$(/usr/bin/pihole-FTL tag)"
|
||||||
echo ""
|
echo -e "\\n ${INFO} FTL version is now at ${FTL_version_current/* v/v}"
|
||||||
echo -e " ${INFO} FTL version is now at ${FTL_version_current/* v/v}"
|
|
||||||
start_service pihole-FTL
|
start_service pihole-FTL
|
||||||
enable_service pihole-FTL
|
enable_service pihole-FTL
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
|
@ -29,6 +29,7 @@ Options:
|
||||||
-c, celsius Set Celsius as preferred temperature unit
|
-c, celsius Set Celsius as preferred temperature unit
|
||||||
-f, fahrenheit Set Fahrenheit as preferred temperature unit
|
-f, fahrenheit Set Fahrenheit as preferred temperature unit
|
||||||
-k, kelvin Set Kelvin as preferred temperature unit
|
-k, kelvin Set Kelvin as preferred temperature unit
|
||||||
|
-r, hostrecord Add a name to the DNS associated to an IPv4/IPv6 address
|
||||||
-h, --help Show this help dialog
|
-h, --help Show this help dialog
|
||||||
-i, interface Specify dnsmasq's interface listening behavior
|
-i, interface Specify dnsmasq's interface listening behavior
|
||||||
Add '-h' for more info on interface usage"
|
Add '-h' for more info on interface usage"
|
||||||
|
@ -292,7 +293,9 @@ ra-param=*,0,0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
rm "${dhcpconfig}" &> /dev/null
|
if [[ -f "${dhcpconfig}" ]]; then
|
||||||
|
rm "${dhcpconfig}" &> /dev/null
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,12 +393,23 @@ RemoveDHCPStaticAddress() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SetHostRecord() {
|
SetHostRecord() {
|
||||||
if [ -n "${args[3]}" ]; then
|
if [[ "${1}" == "-h" ]] || [[ "${1}" == "--help" ]]; then
|
||||||
|
echo "Usage: pihole -a hostrecord <domain> [IPv4-address],[IPv6-address]
|
||||||
|
Example: 'pihole -a hostrecord home.domain.com 192.168.1.1,2001:db8:a0b:12f0::1'
|
||||||
|
Add a name to the DNS associated to an IPv4/IPv6 address
|
||||||
|
|
||||||
|
Options:
|
||||||
|
\"\" Empty: Remove host record
|
||||||
|
-h, --help Show this help dialog"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${args[3]}" ]]; then
|
||||||
change_setting "HOSTRECORD" "${args[2]},${args[3]}"
|
change_setting "HOSTRECORD" "${args[2]},${args[3]}"
|
||||||
echo "Setting host record for ${args[2]} -> ${args[3]}"
|
echo -e " ${TICK} Setting host record for ${args[2]} to ${args[3]}"
|
||||||
else
|
else
|
||||||
change_setting "HOSTRECORD" ""
|
change_setting "HOSTRECORD" ""
|
||||||
echo "Removing host record"
|
echo -e " ${TICK} Removing host record"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ProcessDNSSettings
|
ProcessDNSSettings
|
||||||
|
@ -472,7 +486,7 @@ main() {
|
||||||
"resolve" ) ResolutionSettings;;
|
"resolve" ) ResolutionSettings;;
|
||||||
"addstaticdhcp" ) AddDHCPStaticAddress;;
|
"addstaticdhcp" ) AddDHCPStaticAddress;;
|
||||||
"removestaticdhcp" ) RemoveDHCPStaticAddress;;
|
"removestaticdhcp" ) RemoveDHCPStaticAddress;;
|
||||||
"hostrecord" ) SetHostRecord;;
|
"-r" | "hostrecord" ) SetHostRecord "$3";;
|
||||||
"-i" | "interface" ) SetListeningMode "$@";;
|
"-i" | "interface" ) SetListeningMode "$@";;
|
||||||
"-t" | "teleporter" ) Teleporter;;
|
"-t" | "teleporter" ) Teleporter;;
|
||||||
"adlist" ) CustomizeAdLists;;
|
"adlist" ) CustomizeAdLists;;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
15
pihole
15
pihole
|
@ -149,7 +149,7 @@ Options:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Strip valid options, leaving only the domain and invalid options
|
# Strip valid options, leaving only the domain and invalid options
|
||||||
options=$(sed 's/ \?-\(exact\|adlist\|bp\|all\) \?//g' <<< "$options")
|
options=$(sed 's/ \?-\(exact\|adlist\(s\)\?\|bp\|all\) \?//g' <<< "$options")
|
||||||
|
|
||||||
# Handle errors
|
# Handle errors
|
||||||
if [[ "${options}" == *" "* ]]; then
|
if [[ "${options}" == *" "* ]]; then
|
||||||
|
@ -181,13 +181,14 @@ Options:
|
||||||
results=($(scanList "${query}" "${lists}" "${method}"))
|
results=($(scanList "${query}" "${lists}" "${method}"))
|
||||||
|
|
||||||
if [[ -n "${results[*]}" ]]; then
|
if [[ -n "${results[*]}" ]]; then
|
||||||
|
blResult=true
|
||||||
# Loop through each scanList line to print appropriate title
|
# Loop through each scanList line to print appropriate title
|
||||||
for result in "${results[@]}"; do
|
for result in "${results[@]}"; do
|
||||||
filename="${result/:*/}"
|
filename="${result/:*/}"
|
||||||
if [[ -n "$exact" ]]; then
|
if [[ -n "$exact" ]]; then
|
||||||
printf " Exact result in %s\n" "${filename}"
|
printf " Exact result in %s\n" "${filename}"
|
||||||
elif [[ -n "$blockpage" ]]; then
|
elif [[ -n "$blockpage" ]]; then
|
||||||
printf " [i] %s\n" "${filename}"
|
printf "π %s\n" "${filename}"
|
||||||
else
|
else
|
||||||
domain="${result/*:/}"
|
domain="${result/*:/}"
|
||||||
if [[ ! "${filename}" == "${filename_prev:-}" ]]; then
|
if [[ ! "${filename}" == "${filename_prev:-}" ]]; then
|
||||||
|
@ -216,7 +217,7 @@ Options:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${blockpage}" ]]; then
|
if [[ -n "${blockpage}" ]]; then
|
||||||
echo " ${INFO} ${match}"
|
echo "π ${wildcardlist/*\/}"
|
||||||
else
|
else
|
||||||
echo " *.${match}"
|
echo " *.${match}"
|
||||||
fi
|
fi
|
||||||
|
@ -287,12 +288,18 @@ Options:
|
||||||
filenum=("${filename/list./}")
|
filenum=("${filename/list./}")
|
||||||
filenum=("${filenum/.*/}")
|
filenum=("${filenum/.*/}")
|
||||||
filename="${adlists[$filenum]}"
|
filename="${adlists[$filenum]}"
|
||||||
|
|
||||||
|
# If gravity has generated associated .domains files
|
||||||
|
# but adlists.list has been modified since
|
||||||
|
if [[ -z "${filename}" ]]; then
|
||||||
|
filename="${COL_LIGHT_RED}Error: no associated adlists URL found${COL_NC}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${exact}" ]]; then
|
if [[ -n "${exact}" ]]; then
|
||||||
printf " %s\n" "${filename}"
|
printf " %s\n" "${filename}"
|
||||||
elif [[ -n "${blockpage}" ]]; then
|
elif [[ -n "${blockpage}" ]]; then
|
||||||
printf " [%s] %s\n" "${filenum}" "${filename}"
|
printf "%s %s\n" "${filenum}" "${filename}"
|
||||||
else # Standard query output
|
else # Standard query output
|
||||||
|
|
||||||
# Print filename heading once per file, not for every match
|
# Print filename heading once per file, not for every match
|
||||||
|
|
|
@ -59,6 +59,8 @@ def test_setupVars_saved_to_file(Pihole):
|
||||||
TERM=xterm
|
TERM=xterm
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
{}
|
{}
|
||||||
|
mkdir -p /etc/dnsmasq.d
|
||||||
|
version_check_dnsmasq
|
||||||
finalExports
|
finalExports
|
||||||
cat /etc/pihole/setupVars.conf
|
cat /etc/pihole/setupVars.conf
|
||||||
'''.format(set_setup_vars))
|
'''.format(set_setup_vars))
|
||||||
|
@ -78,7 +80,7 @@ def test_configureFirewall_firewalld_running_no_errors(Pihole):
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
configureFirewall
|
configureFirewall
|
||||||
''')
|
''')
|
||||||
expected_stdout = 'Configuring FirewallD for httpd and dnsmasq.'
|
expected_stdout = 'Configuring FirewallD for httpd and dnsmasq'
|
||||||
assert expected_stdout in configureFirewall.stdout
|
assert expected_stdout in configureFirewall.stdout
|
||||||
firewall_calls = Pihole.run('cat /var/log/firewall-cmd').stdout
|
firewall_calls = Pihole.run('cat /var/log/firewall-cmd').stdout
|
||||||
assert 'firewall-cmd --state' in firewall_calls
|
assert 'firewall-cmd --state' in firewall_calls
|
||||||
|
@ -93,7 +95,7 @@ def test_configureFirewall_firewalld_disabled_no_errors(Pihole):
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
configureFirewall
|
configureFirewall
|
||||||
''')
|
''')
|
||||||
expected_stdout = 'No active firewall detected.. skipping firewall configuration.'
|
expected_stdout = 'No active firewall detected.. skipping firewall configuration'
|
||||||
assert expected_stdout in configureFirewall.stdout
|
assert expected_stdout in configureFirewall.stdout
|
||||||
|
|
||||||
def test_configureFirewall_firewalld_enabled_declined_no_errors(Pihole):
|
def test_configureFirewall_firewalld_enabled_declined_no_errors(Pihole):
|
||||||
|
@ -319,11 +321,11 @@ def test_FTL_detect_aarch64_no_errors(Pihole):
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdetect
|
FTLdetect
|
||||||
''')
|
''')
|
||||||
expected_stdout = info_box + ' Downloading latest version of FTL...'
|
expected_stdout = info_box + ' FTL Checks...'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
expected_stdout = tick_box + ' Detected ARM-aarch64 architecture'
|
expected_stdout = tick_box + ' Detected ARM-aarch64 architecture'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
expected_stdout = tick_box + ' Installing FTL'
|
expected_stdout = tick_box + ' Downloading and Installing FTL'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
|
|
||||||
def test_FTL_detect_armv6l_no_errors(Pihole):
|
def test_FTL_detect_armv6l_no_errors(Pihole):
|
||||||
|
@ -336,11 +338,11 @@ def test_FTL_detect_armv6l_no_errors(Pihole):
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdetect
|
FTLdetect
|
||||||
''')
|
''')
|
||||||
expected_stdout = info_box + ' Downloading latest version of FTL...'
|
expected_stdout = info_box + ' FTL Checks...'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
expected_stdout = tick_box + ' Detected ARM-hf architecture (armv6 or lower)'
|
expected_stdout = tick_box + ' Detected ARM-hf architecture (armv6 or lower)'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
expected_stdout = tick_box + ' Installing FTL'
|
expected_stdout = tick_box + ' Downloading and Installing FTL'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
|
|
||||||
def test_FTL_detect_armv7l_no_errors(Pihole):
|
def test_FTL_detect_armv7l_no_errors(Pihole):
|
||||||
|
@ -353,11 +355,11 @@ def test_FTL_detect_armv7l_no_errors(Pihole):
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdetect
|
FTLdetect
|
||||||
''')
|
''')
|
||||||
expected_stdout = info_box + ' Downloading latest version of FTL...'
|
expected_stdout = info_box + ' FTL Checks...'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
expected_stdout = tick_box + ' Detected ARM-hf architecture (armv7+)'
|
expected_stdout = tick_box + ' Detected ARM-hf architecture (armv7+)'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
expected_stdout = tick_box + ' Installing FTL'
|
expected_stdout = tick_box + ' Downloading and Installing FTL'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
|
|
||||||
def test_FTL_detect_x86_64_no_errors(Pihole):
|
def test_FTL_detect_x86_64_no_errors(Pihole):
|
||||||
|
@ -366,11 +368,11 @@ def test_FTL_detect_x86_64_no_errors(Pihole):
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdetect
|
FTLdetect
|
||||||
''')
|
''')
|
||||||
expected_stdout = info_box + ' Downloading latest version of FTL...'
|
expected_stdout = info_box + ' FTL Checks...'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
expected_stdout = tick_box + ' Detected x86_64 architecture'
|
expected_stdout = tick_box + ' Detected x86_64 architecture'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
expected_stdout = tick_box + ' Installing FTL'
|
expected_stdout = tick_box + ' Downloading and Installing FTL'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
|
|
||||||
def test_FTL_detect_unknown_no_errors(Pihole):
|
def test_FTL_detect_unknown_no_errors(Pihole):
|
||||||
|
@ -391,7 +393,7 @@ def test_FTL_download_aarch64_no_errors(Pihole):
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLinstall pihole-FTL-aarch64-linux-gnu
|
FTLinstall pihole-FTL-aarch64-linux-gnu
|
||||||
''')
|
''')
|
||||||
expected_stdout = tick_box + ' Installing FTL'
|
expected_stdout = tick_box + ' Downloading and Installing FTL'
|
||||||
assert expected_stdout in download_binary.stdout
|
assert expected_stdout in download_binary.stdout
|
||||||
error = 'Error: Download of binary from Github failed'
|
error = 'Error: Download of binary from Github failed'
|
||||||
assert error not in download_binary.stdout
|
assert error not in download_binary.stdout
|
||||||
|
@ -405,7 +407,7 @@ def test_FTL_download_unknown_fails_no_errors(Pihole):
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLinstall pihole-FTL-mips
|
FTLinstall pihole-FTL-mips
|
||||||
''')
|
''')
|
||||||
expected_stdout = cross_box + ' Installing FTL'
|
expected_stdout = cross_box + ' Downloading and Installing FTL'
|
||||||
assert expected_stdout in download_binary.stdout
|
assert expected_stdout in download_binary.stdout
|
||||||
error = 'Error: URL not found'
|
error = 'Error: URL not found'
|
||||||
assert error in download_binary.stdout
|
assert error in download_binary.stdout
|
||||||
|
@ -442,7 +444,7 @@ def test_IPv6_only_link_local(Pihole):
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
useIPv6dialog
|
useIPv6dialog
|
||||||
''')
|
''')
|
||||||
expected_stdout = 'Found neither IPv6 ULA nor GUA address, blocking IPv6 ads will not be enabled'
|
expected_stdout = 'Unable to find IPv6 ULA/GUA address, IPv6 adblocking will not be enabled'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
|
|
||||||
def test_IPv6_only_ULA(Pihole):
|
def test_IPv6_only_ULA(Pihole):
|
||||||
|
|
Loading…
Reference in a new issue