mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-05 13:40:56 +00:00
Merge pull request #1312 from pi-hole/pihole-backports
Pi-hole Core v2.13.2
This commit is contained in:
commit
3d1ccd9625
@ -33,6 +33,6 @@ groups:
|
|||||||
conditions:
|
conditions:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
required: -1
|
required: 4
|
||||||
teams:
|
teams:
|
||||||
- admin
|
- admin
|
||||||
|
@ -84,6 +84,9 @@ PoplistFile() {
|
|||||||
if ${addmode}; then
|
if ${addmode}; then
|
||||||
AddDomain "${dom}" "${listMain}"
|
AddDomain "${dom}" "${listMain}"
|
||||||
RemoveDomain "${dom}" "${listAlt}"
|
RemoveDomain "${dom}" "${listAlt}"
|
||||||
|
if [[ "${listMain}" == "${whitelist}" || "${listMain}" == "${blacklist}" ]]; then
|
||||||
|
RemoveDomain "${dom}" "${wildcardlist}"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
RemoveDomain "${dom}" "${listMain}"
|
RemoveDomain "${dom}" "${listMain}"
|
||||||
fi
|
fi
|
||||||
|
202
advanced/Scripts/piholeCheckout.sh
Normal file
202
advanced/Scripts/piholeCheckout.sh
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Pi-hole: A black hole for Internet advertisements
|
||||||
|
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||||
|
# Network-wide ad blocking via your own hardware.
|
||||||
|
#
|
||||||
|
# Checkout other branches than master
|
||||||
|
#
|
||||||
|
# This file is copyright under the latest version of the EUPL.
|
||||||
|
# Please see LICENSE file for your rights under this license.
|
||||||
|
|
||||||
|
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
||||||
|
PH_TEST="true" source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
|
||||||
|
|
||||||
|
# webInterfaceGitUrl set in basic-install.sh
|
||||||
|
# webInterfaceDir set in basic-install.sh
|
||||||
|
# piholeGitURL set in basic-install.sh
|
||||||
|
# is_repo() sourced from basic-install.sh
|
||||||
|
# setupVars set in basic-install.sh
|
||||||
|
|
||||||
|
source "${setupVars}"
|
||||||
|
|
||||||
|
update="false"
|
||||||
|
|
||||||
|
fully_fetch_repo() {
|
||||||
|
# Add upstream branches to shallow clone
|
||||||
|
local directory="${1}"
|
||||||
|
|
||||||
|
cd "${directory}" || return 1
|
||||||
|
if is_repo "${directory}"; then
|
||||||
|
git remote set-branches origin '*' || return 1
|
||||||
|
git fetch --quiet || return 1
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
get_available_branches(){
|
||||||
|
# Return available branches
|
||||||
|
local directory="${1}"
|
||||||
|
|
||||||
|
cd "${directory}" || return 1
|
||||||
|
# Get reachable remote branches
|
||||||
|
git remote show origin | grep 'tracked' | sed 's/tracked//;s/ //g'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fetch_checkout_pull_branch() {
|
||||||
|
# Check out specified branch
|
||||||
|
local directory="${1}"
|
||||||
|
local branch="${2}"
|
||||||
|
|
||||||
|
# Set the reference for the requested branch, fetch, check it put and pull it
|
||||||
|
cd "${directory}"
|
||||||
|
git remote set-branches origin "${branch}" || return 1
|
||||||
|
git fetch --quiet || return 1
|
||||||
|
checkout_pull_branch "${directory}" "${branch}" || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
checkout_pull_branch() {
|
||||||
|
# Check out specified branch
|
||||||
|
local directory="${1}"
|
||||||
|
local branch="${2}"
|
||||||
|
local oldbranch
|
||||||
|
|
||||||
|
cd "${directory}" || return 1
|
||||||
|
|
||||||
|
oldbranch="$(git symbolic-ref HEAD)"
|
||||||
|
|
||||||
|
git checkout "${branch}" || return 1
|
||||||
|
|
||||||
|
if [ "$(git diff "${oldbranch}" | grep -c "^")" -gt "0" ]; then
|
||||||
|
update="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull || return 1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
warning1() {
|
||||||
|
echo "::: Note that changing the branch is a severe change of your Pi-hole system."
|
||||||
|
echo "::: This is not supported unless one of the developers explicitly asks you to do this!"
|
||||||
|
read -r -p "::: Have you read and understood this? [y/N] " response
|
||||||
|
case ${response} in
|
||||||
|
[yY][eE][sS]|[yY])
|
||||||
|
echo "::: Continuing."
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "::: Aborting."
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
checkout()
|
||||||
|
{
|
||||||
|
local corebranches
|
||||||
|
local webbranches
|
||||||
|
|
||||||
|
# Avoid globbing
|
||||||
|
set -f
|
||||||
|
|
||||||
|
#This is unlikely
|
||||||
|
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||||
|
echo "::: Critical Error: Core Pi-Hole repo is missing from system!"
|
||||||
|
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
if [[ ${INSTALL_WEB} == "true" ]]; then
|
||||||
|
if ! is_repo "${webInterfaceDir}" ; then
|
||||||
|
echo "::: Critical Error: Web Admin repo is missing from system!"
|
||||||
|
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${1}" ]]; then
|
||||||
|
echo "::: No option detected. Please use 'pihole checkout <master|dev>'."
|
||||||
|
echo "::: Or enter the repository and branch you would like to check out:"
|
||||||
|
echo "::: 'pihole checkout <web|core> <branchname>'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! warning1 ; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${1}" == "dev" ]] ; then
|
||||||
|
# Shortcut to check out development branches
|
||||||
|
echo "::: Shortcut \"dev\" detected - checking out development / devel branches ..."
|
||||||
|
echo "::: Pi-hole core"
|
||||||
|
fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "development" || { echo "Unable to pull Core developement branch"; exit 1; }
|
||||||
|
if [[ ${INSTALL_WEB} == "true" ]]; then
|
||||||
|
echo "::: Web interface"
|
||||||
|
fetch_checkout_pull_branch "${webInterfaceDir}" "devel" || { echo "Unable to pull Web development branch"; exit 1; }
|
||||||
|
fi
|
||||||
|
echo "::: done!"
|
||||||
|
elif [[ "${1}" == "master" ]] ; then
|
||||||
|
# Shortcut to check out master branches
|
||||||
|
echo "::: Shortcut \"master\" detected - checking out master branches ..."
|
||||||
|
echo "::: Pi-hole core"
|
||||||
|
fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "master" || { echo "Unable to pull Core master branch"; exit 1; }
|
||||||
|
if [[ ${INSTALL_WEB} == "true" ]]; then
|
||||||
|
echo "::: Web interface"
|
||||||
|
fetch_checkout_pull_branch "${webInterfaceDir}" "master" || { echo "Unable to pull web master branch"; exit 1; }
|
||||||
|
fi
|
||||||
|
echo "::: done!"
|
||||||
|
elif [[ "${1}" == "core" ]] ; then
|
||||||
|
echo -n "::: Fetching remote branches for Pi-hole core from ${piholeGitUrl} ... "
|
||||||
|
if ! fully_fetch_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||||
|
echo "::: Fetching all branches for Pi-hole core repo failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
corebranches=($(get_available_branches "${PI_HOLE_FILES_DIR}"))
|
||||||
|
echo " done!"
|
||||||
|
echo "::: ${#corebranches[@]} branches available"
|
||||||
|
echo ":::"
|
||||||
|
# Have to user chosing the branch he wants
|
||||||
|
if ! (for e in "${corebranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then
|
||||||
|
echo "::: Requested branch \"${2}\" is not available!"
|
||||||
|
echo "::: Available branches for core are:"
|
||||||
|
for e in "${corebranches[@]}"; do echo "::: $e"; done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
checkout_pull_branch "${PI_HOLE_FILES_DIR}" "${2}"
|
||||||
|
elif [[ "${1}" == "web" && "${INSTALL_WEB}" == "true" ]] ; then
|
||||||
|
echo -n "::: Fetching remote branches for the web interface from ${webInterfaceGitUrl} ... "
|
||||||
|
if ! fully_fetch_repo "${webInterfaceDir}" ; then
|
||||||
|
echo "::: Fetching all branches for Pi-hole web interface repo failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
webbranches=($(get_available_branches "${webInterfaceDir}"))
|
||||||
|
echo " done!"
|
||||||
|
echo "::: ${#webbranches[@]} branches available"
|
||||||
|
echo ":::"
|
||||||
|
# Have to user chosing the branch he wants
|
||||||
|
if ! (for e in "${webbranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then
|
||||||
|
echo "::: Requested branch \"${2}\" is not available!"
|
||||||
|
echo "::: Available branches for web are:"
|
||||||
|
for e in "${webbranches[@]}"; do echo "::: $e"; done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
checkout_pull_branch "${webInterfaceDir}" "${2}"
|
||||||
|
else
|
||||||
|
echo "::: Requested option \"${1}\" is not available!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Force updating everything
|
||||||
|
if [[ ! "${1}" == "web" && "${update}" == "true" ]]; then
|
||||||
|
echo "::: Running installer to upgrade your installation"
|
||||||
|
if "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh" --unattended; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Unable to complete update, contact Pi-hole"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
@ -24,6 +24,8 @@ WHITELISTFILE="/etc/pihole/whitelist.txt"
|
|||||||
BLACKLISTFILE="/etc/pihole/blacklist.txt"
|
BLACKLISTFILE="/etc/pihole/blacklist.txt"
|
||||||
ADLISTFILE="/etc/pihole/adlists.list"
|
ADLISTFILE="/etc/pihole/adlists.list"
|
||||||
PIHOLELOG="/var/log/pihole.log"
|
PIHOLELOG="/var/log/pihole.log"
|
||||||
|
PIHOLEGITDIR="/etc/.pihole/"
|
||||||
|
ADMINGITDIR="/var/www/html/admin/"
|
||||||
WHITELISTMATCHES="/tmp/whitelistmatches.list"
|
WHITELISTMATCHES="/tmp/whitelistmatches.list"
|
||||||
|
|
||||||
TIMEOUT=60
|
TIMEOUT=60
|
||||||
@ -111,22 +113,61 @@ version_check() {
|
|||||||
header_write "Detecting Installed Package Versions:"
|
header_write "Detecting Installed Package Versions:"
|
||||||
|
|
||||||
local error_found
|
local error_found
|
||||||
|
local pi_hole_ver
|
||||||
|
local pi_hole_branch
|
||||||
|
local pi_hole_commit
|
||||||
|
local admin_ver
|
||||||
|
local admin_branch
|
||||||
|
local admin_commit
|
||||||
|
local light_ver
|
||||||
|
local php_ver
|
||||||
|
local status
|
||||||
error_found=0
|
error_found=0
|
||||||
|
|
||||||
local pi_hole_ver="$(cd /etc/.pihole/ && git describe --tags --abbrev=0)" \
|
cd "${PIHOLEGITDIR}" &> /dev/null || \
|
||||||
&& log_echo -r "Pi-hole: $pi_hole_ver" || (log_echo "Pi-hole git repository not detected." && error_found=1)
|
{ status="Pi-hole git directory not found."; error_found=1; }
|
||||||
local admin_ver="$(cd /var/www/html/admin && git describe --tags --abbrev=0)" \
|
if git status &> /dev/null; then
|
||||||
&& log_echo -r "WebUI: $admin_ver" || (log_echo "Pi-hole Admin Pages git repository not detected." && error_found=1)
|
pi_hole_ver=$(git describe --tags --abbrev=0)
|
||||||
local light_ver="$(lighttpd -v |& head -n1 | cut -d " " -f1)" \
|
pi_hole_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
&& log_echo -r "${light_ver}" || (log_echo "lighttpd not installed." && error_found=1)
|
pi_hole_commit=$(git describe --long --dirty --tags --always)
|
||||||
local php_ver="$(php -v |& head -n1)" \
|
log_echo -r "Pi-hole: ${pi_hole_ver:-Untagged} (${pi_hole_branch:-Detached}:${pi_hole_commit})"
|
||||||
&& log_echo -r "${php_ver}" || (log_echo "PHP not installed." && error_found=1)
|
else
|
||||||
|
status=${status:-"Pi-hole repository damaged."}
|
||||||
|
error_found=1
|
||||||
|
fi
|
||||||
|
if [[ "${status}" ]]; then
|
||||||
|
log_echo "${status}"
|
||||||
|
unset status
|
||||||
|
fi
|
||||||
|
|
||||||
(local pi_hole_branch="$(cd /etc/.pihole/ && git rev-parse --abbrev-ref HEAD)" && log_echo -r "Pi-hole branch: ${pi_hole_branch}") || log_echo "Unable to obtain Pi-hole branch"
|
cd "${ADMINGITDIR}" || \
|
||||||
(local pi_hole_rev="$(cd /etc/.pihole/ && git describe --long --dirty --tags)" && log_echo -r "Pi-hole rev: ${pi_hole_rev}") || log_echo "Unable to obtain Pi-hole revision"
|
{ status="Pi-hole Dashboard git directory not found."; error_found=1; }
|
||||||
|
if git status &> /dev/null; then
|
||||||
|
admin_ver=$(git describe --tags --abbrev=0)
|
||||||
|
admin_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
admin_commit=$(git describe --long --dirty --tags --always)
|
||||||
|
log_echo -r "Pi-hole Dashboard: ${admin_ver:-Untagged} (${admin_branch:-Detached}:${admin_commit})"
|
||||||
|
else
|
||||||
|
status=${status:-"Pi-hole Dashboard repository damaged."}
|
||||||
|
error_found=1
|
||||||
|
fi
|
||||||
|
if [[ "${status}" ]]; then
|
||||||
|
log_echo "${status}"
|
||||||
|
unset status
|
||||||
|
fi
|
||||||
|
|
||||||
(local admin_branch="$(cd /var/www/html/admin && git rev-parse --abbrev-ref HEAD)" && log_echo -r "AdminLTE branch: ${admin_branch}") || log_echo "Unable to obtain AdminLTE branch"
|
if light_ver=$(lighttpd -v |& head -n1 | cut -d " " -f1); then
|
||||||
(local admin_rev="$(cd /var/www/html/admin && git describe --long --dirty --tags)" && log_echo -r "AdminLTE rev: ${admin_rev}") || log_echo "Unable to obtain AdminLTE revision"
|
log_echo -r "${light_ver}"
|
||||||
|
else
|
||||||
|
log_echo "lighttpd not installed."
|
||||||
|
error_found=1
|
||||||
|
fi
|
||||||
|
if php_ver=$(php -v |& head -n1); then
|
||||||
|
log_echo -r "${php_ver}"
|
||||||
|
else
|
||||||
|
log_echo "PHP not installed."
|
||||||
|
error_found=1
|
||||||
|
fi
|
||||||
|
|
||||||
return "${error_found}"
|
return "${error_found}"
|
||||||
}
|
}
|
||||||
|
@ -8,67 +8,104 @@
|
|||||||
# This file is copyright under the latest version of the EUPL.
|
# This file is copyright under the latest version of the EUPL.
|
||||||
# Please see LICENSE file for your rights under this license.
|
# Please see LICENSE file for your rights under this license.
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
|
||||||
# Flags:
|
|
||||||
latest=false
|
|
||||||
current=false
|
|
||||||
|
|
||||||
DEFAULT="-1"
|
DEFAULT="-1"
|
||||||
|
PHGITDIR="/etc/.pihole/"
|
||||||
|
WEBGITDIR="/var/www/html/admin/"
|
||||||
|
|
||||||
|
getLocalVersion() {
|
||||||
|
# Get the tagged version of the local repository
|
||||||
|
local directory="${1}"
|
||||||
|
local version
|
||||||
|
|
||||||
|
cd "${directory}" || { echo "${DEFAULT}"; return 1; }
|
||||||
|
version=$(git describe --tags --always || \
|
||||||
|
echo "${DEFAULT}")
|
||||||
|
if [[ "${version}" =~ ^v ]]; then
|
||||||
|
echo "${version}"
|
||||||
|
elif [[ "${version}" == "${DEFAULT}" ]]; then
|
||||||
|
echo "ERROR"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo "Untagged"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
getLocalHash() {
|
||||||
|
# Get the short hash of the local repository
|
||||||
|
local directory="${1}"
|
||||||
|
local hash
|
||||||
|
|
||||||
|
cd "${directory}" || { echo "${DEFAULT}"; return 1; }
|
||||||
|
hash=$(git rev-parse --short HEAD || \
|
||||||
|
echo "${DEFAULT}")
|
||||||
|
if [[ "${hash}" == "${DEFAULT}" ]]; then
|
||||||
|
echo "ERROR"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo "${hash}"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
getRemoteVersion(){
|
||||||
|
# Get the version from the remote origin
|
||||||
|
local daemon="${1}"
|
||||||
|
local version
|
||||||
|
|
||||||
|
version=$(curl --silent --fail https://api.github.com/repos/pi-hole/${daemon}/releases/latest | \
|
||||||
|
awk -F: '$1 ~/tag_name/ { print $2 }' | \
|
||||||
|
tr -cd '[[:alnum:]]._-')
|
||||||
|
if [[ "${version}" =~ ^v ]]; then
|
||||||
|
echo "${version}"
|
||||||
|
else
|
||||||
|
echo "ERROR"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#PHHASHLATEST=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/commits/master | \
|
||||||
|
# grep sha | \
|
||||||
|
# head -n1 | \
|
||||||
|
# awk -F ' ' '{ print $2 }' | \
|
||||||
|
# tr -cd '[[:alnum:]]._-')
|
||||||
|
|
||||||
|
#WEBHASHLATEST=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/commits/master | \
|
||||||
|
# grep sha | \
|
||||||
|
# head -n1 | \
|
||||||
|
# awk -F ' ' '{ print $2 }' | \
|
||||||
|
# tr -cd '[[:alnum:]]._-')
|
||||||
|
|
||||||
|
|
||||||
normalOutput() {
|
normalOutput() {
|
||||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
echo "::: Pi-hole version is $(getLocalVersion "${PHGITDIR}") (Latest version is $(getRemoteVersion pi-hole))"
|
||||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
if [ -d "${WEBGITDIR}" ]; then
|
||||||
|
echo "::: Web-Admin version is $(getLocalVersion "${WEBGITDIR}") (Latest version is $(getRemoteVersion AdminLTE))"
|
||||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
fi
|
||||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
|
||||||
|
|
||||||
echo "::: Pi-hole version is ${piholeVersion} (Latest version is ${piholeVersionLatest:-${DEFAULT}})"
|
|
||||||
echo "::: Web-Admin version is ${webVersion} (Latest version is ${webVersionLatest:-${DEFAULT}})"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
webOutput() {
|
webOutput() {
|
||||||
for var in "$@"; do
|
if [ -d "${WEBGITDIR}" ]; then
|
||||||
case "${var}" in
|
case "${1}" in
|
||||||
"-l" | "--latest" ) latest=true;;
|
"-l" | "--latest" ) echo $(getRemoteVersion AdminLTE);;
|
||||||
"-c" | "--current" ) current=true;;
|
"-c" | "--current" ) echo $(getLocalVersion "${WEBGITDIR}");;
|
||||||
* ) echo "::: Invalid Option!"; exit 1;
|
"-h" | "--hash" ) echo $(getLocalHash "${WEBGITDIR}");;
|
||||||
esac
|
* ) echo "::: Invalid Option!"; exit 1;
|
||||||
done
|
esac
|
||||||
|
else
|
||||||
if [[ "${latest}" == true && "${current}" == false ]]; then
|
echo "::: Web interface not installed!"; exit 1;
|
||||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
fi
|
||||||
echo "${webVersionLatest:--1}"
|
|
||||||
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
|
||||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
|
||||||
echo "${webVersion}"
|
|
||||||
else
|
|
||||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
|
||||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
|
||||||
echo "::: Web-Admin version is ${webVersion} (Latest version is ${webVersionLatest:-${DEFAULT}})"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
coreOutput() {
|
coreOutput() {
|
||||||
for var in "$@"; do
|
case "${1}" in
|
||||||
case "${var}" in
|
"-l" | "--latest" ) echo $(getRemoteVersion pi-hole);;
|
||||||
"-l" | "--latest" ) latest=true;;
|
"-c" | "--current" ) echo $(getLocalVersion "${PHGITDIR}");;
|
||||||
"-c" | "--current" ) current=true;;
|
"-h" | "--hash" ) echo $(getLocalHash "${PHGITDIR}");;
|
||||||
* ) echo "::: Invalid Option!"; exit 1;
|
* ) echo "::: Invalid Option!"; exit 1;
|
||||||
esac
|
esac
|
||||||
done
|
|
||||||
|
|
||||||
if [[ "${latest}" == true && "${current}" == false ]]; then
|
|
||||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
|
||||||
echo "${piholeVersionLatest:--1}"
|
|
||||||
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
|
||||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
|
||||||
echo "${piholeVersion}"
|
|
||||||
else
|
|
||||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
|
||||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
|
||||||
echo "::: Pi-hole version is ${piholeVersion} (Latest version is ${piholeVersionLatest:-${DEFAULT}})"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
@ -93,10 +130,8 @@ if [[ $# = 0 ]]; then
|
|||||||
normalOutput
|
normalOutput
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for var in "$@"; do
|
case "${1}" in
|
||||||
case "${var}" in
|
"-a" | "--admin" ) shift; webOutput "$@";;
|
||||||
"-a" | "--admin" ) shift; webOutput "$@";;
|
"-p" | "--pihole" ) shift; coreOutput "$@" ;;
|
||||||
"-p" | "--pihole" ) shift; coreOutput "$@" ;;
|
"-h" | "--help" ) helpFunc;;
|
||||||
"-h" | "--help" ) helpFunc;;
|
esac
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
@ -134,7 +134,7 @@ trust-anchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE3
|
|||||||
|
|
||||||
delete_dnsmasq_setting "host-record"
|
delete_dnsmasq_setting "host-record"
|
||||||
|
|
||||||
if [ ! -z "${HOSTRECORD+x}" ]; then
|
if [ ! -z "${HOSTRECORD}" ]; then
|
||||||
add_dnsmasq_setting "host-record" "${HOSTRECORD}"
|
add_dnsmasq_setting "host-record" "${HOSTRECORD}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ _pihole() {
|
|||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
opts="admin blacklist chronometer debug disable enable flush help logging query reconfigure restartdns setupLCD status tail uninstall updateGravity updatePihole version whitelist"
|
opts="admin blacklist chronometer debug disable enable flush help logging query reconfigure restartdns setupLCD status tail uninstall updateGravity updatePihole version whitelist checkout"
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
|
35
pihole
35
pihole
@ -8,9 +8,8 @@
|
|||||||
# This file is copyright under the latest version of the EUPL.
|
# This file is copyright under the latest version of the EUPL.
|
||||||
# Please see LICENSE file for your rights under this license.
|
# Please see LICENSE file for your rights under this license.
|
||||||
|
|
||||||
|
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
||||||
|
|
||||||
|
|
||||||
PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
|
||||||
readonly wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
readonly wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
||||||
# Must be root to use this tool
|
# Must be root to use this tool
|
||||||
if [[ ! $EUID -eq 0 ]];then
|
if [[ ! $EUID -eq 0 ]];then
|
||||||
@ -128,17 +127,19 @@ queryFunc() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Scan for possible wildcard matches
|
# Scan for possible wildcard matches
|
||||||
local wildcards=($(processWildcards "${domain}"))
|
if [ -e "${wildcardlist}" ]; then
|
||||||
for domain in ${wildcards[@]}; do
|
local wildcards=($(processWildcards "${domain}"))
|
||||||
result=$(scanList "\/${domain}\/" ${wildcardlist})
|
for domain in ${wildcards[@]}; do
|
||||||
# Remove empty lines before couting number of results
|
result=$(scanList "\/${domain}\/" ${wildcardlist})
|
||||||
count=$(sed '/^\s*$/d' <<< "$result" | wc -l)
|
# Remove empty lines before couting number of results
|
||||||
if [[ ${count} > 0 ]]; then
|
count=$(sed '/^\s*$/d' <<< "$result" | wc -l)
|
||||||
echo "::: Wildcard blocking ${domain} (${count} results)"
|
if [[ ${count} > 0 ]]; then
|
||||||
echo "${result}"
|
echo "::: Wildcard blocking ${domain} (${count} results)"
|
||||||
echo ""
|
echo "${result}"
|
||||||
fi
|
echo ""
|
||||||
done
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,6 +279,12 @@ tailFunc() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
piholeCheckoutFunc() {
|
||||||
|
source "${PI_HOLE_SCRIPT_DIR}"/piholeCheckout.sh
|
||||||
|
shift
|
||||||
|
checkout "$@"
|
||||||
|
}
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
cat << EOM
|
cat << EOM
|
||||||
::: Control all PiHole specific functions!
|
::: Control all PiHole specific functions!
|
||||||
@ -311,6 +318,7 @@ helpFunc() {
|
|||||||
::: Blocking can also be disabled only temporarily, e.g.,
|
::: Blocking can also be disabled only temporarily, e.g.,
|
||||||
::: 'pihole disable 5m' - will disable blocking for 5 minutes
|
::: 'pihole disable 5m' - will disable blocking for 5 minutes
|
||||||
::: restartdns Restart dnsmasq
|
::: restartdns Restart dnsmasq
|
||||||
|
::: checkout Check out different branches
|
||||||
EOM
|
EOM
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@ -341,5 +349,6 @@ case "${1}" in
|
|||||||
"restartdns" ) restartDNS;;
|
"restartdns" ) restartDNS;;
|
||||||
"-a" | "admin" ) webpageFunc "$@";;
|
"-a" | "admin" ) webpageFunc "$@";;
|
||||||
"-t" | "tail" ) tailFunc;;
|
"-t" | "tail" ) tailFunc;;
|
||||||
|
"checkout" ) piholeCheckoutFunc "$@";;
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user