mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
Merge pull request #441 from pi-hole/development
Pihole v2.6.1.2. Closes #439
This commit is contained in:
commit
01e1e34874
4 changed files with 52 additions and 36 deletions
|
@ -11,16 +11,7 @@
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
echo "::: Immediately blacklists one or more domains in the hosts file"
|
helpFunc
|
||||||
echo ":::"
|
|
||||||
echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Options:"
|
|
||||||
echo "::: -d, --delmode Remove domains from the blacklist"
|
|
||||||
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
|
||||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
|
||||||
echo "::: -q, --quiet output is less verbose"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#globals
|
#globals
|
||||||
|
@ -58,6 +49,21 @@ if [[ -f $piholeIPv6file ]];then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
function helpFunc()
|
||||||
|
{
|
||||||
|
echo "::: Immediately blacklists one or more domains in the hosts file"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Options:"
|
||||||
|
echo "::: -d, --delmode Remove domains from the blacklist"
|
||||||
|
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
||||||
|
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
||||||
|
echo "::: -q, --quiet output is less verbose"
|
||||||
|
echo "::: -h, --help Show this help dialog"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
function HandleOther(){
|
function HandleOther(){
|
||||||
#check validity of domain
|
#check validity of domain
|
||||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||||
|
@ -176,6 +182,7 @@ do
|
||||||
"-d" | "--delmode" ) addmode=false;;
|
"-d" | "--delmode" ) addmode=false;;
|
||||||
"-f" | "--force" ) force=true;;
|
"-f" | "--force" ) force=true;;
|
||||||
"-q" | "--quiet" ) versbose=false;;
|
"-q" | "--quiet" ) versbose=false;;
|
||||||
|
"-h" | "--help" ) helpFunc;;
|
||||||
* ) HandleOther "$var";;
|
* ) HandleOther "$var";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
|
@ -11,16 +11,7 @@
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
echo "::: Immediately whitelists one or more domains in the hosts file"
|
helpFunc
|
||||||
echo ":::"
|
|
||||||
echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Options:"
|
|
||||||
echo "::: -d, --delmode Remove domains from the whitelist"
|
|
||||||
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
|
|
||||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
|
||||||
echo "::: -q, --quiet output is less verbose"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#globals
|
#globals
|
||||||
|
@ -57,6 +48,21 @@ if [[ -f $piholeIPv6file ]];then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
function helpFunc()
|
||||||
|
{
|
||||||
|
echo "::: Immediately whitelists one or more domains in the hosts file"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Options:"
|
||||||
|
echo "::: -d, --delmode Remove domains from the whitelist"
|
||||||
|
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
|
||||||
|
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
||||||
|
echo "::: -q, --quiet output is less verbose"
|
||||||
|
echo "::: -h, --help Show this help dialog"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
function HandleOther(){
|
function HandleOther(){
|
||||||
#check validity of domain
|
#check validity of domain
|
||||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||||
|
@ -189,6 +195,7 @@ do
|
||||||
"-d" | "--delmode" ) addmode=false;;
|
"-d" | "--delmode" ) addmode=false;;
|
||||||
"-f" | "--force" ) force=true;;
|
"-f" | "--force" ) force=true;;
|
||||||
"-q" | "--quiet" ) versbose=false;;
|
"-q" | "--quiet" ) versbose=false;;
|
||||||
|
"-h" | "--help" ) helpFunc;;
|
||||||
* ) HandleOther "$var";;
|
* ) HandleOther "$var";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
|
@ -110,7 +110,8 @@ welcomeDialogs() {
|
||||||
|
|
||||||
# Explain the need for a static address
|
# Explain the need for a static address
|
||||||
whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed" "The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
|
whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed" "The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
|
||||||
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c
|
|
||||||
|
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,7 +175,7 @@ cleanupIPv6() {
|
||||||
|
|
||||||
use4andor6() {
|
use4andor6() {
|
||||||
# Let use select IPv4 and/or IPv6
|
# Let use select IPv4 and/or IPv6
|
||||||
cmd=(whiptail --separate-output --checklist "Select Protocols" $r $c 2)
|
cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)" $r $c 2)
|
||||||
options=(IPv4 "Block ads over IPv4" on
|
options=(IPv4 "Block ads over IPv4" on
|
||||||
IPv6 "Block ads over IPv6" off)
|
IPv6 "Block ads over IPv6" off)
|
||||||
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
|
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
|
||||||
|
@ -232,8 +233,8 @@ getStaticIPv4Settings() {
|
||||||
Gateway: $IPv4gw" $r $c) then
|
Gateway: $IPv4gw" $r $c) then
|
||||||
# If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict.
|
# If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict.
|
||||||
whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict" "It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that.
|
whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict" "It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that.
|
||||||
If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want.
|
If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want.
|
||||||
It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c
|
It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c
|
||||||
# Nothing else to do since the variables are already set above
|
# Nothing else to do since the variables are already set above
|
||||||
else
|
else
|
||||||
# Otherwise, we need to ask the user to input their desired settings.
|
# Otherwise, we need to ask the user to input their desired settings.
|
||||||
|
@ -695,12 +696,12 @@ displayFinalMessage() {
|
||||||
# Final completion message to user
|
# Final completion message to user
|
||||||
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
|
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
|
||||||
|
|
||||||
$IPv4addr
|
IPv4: $IPv4addr
|
||||||
$piholeIPv6
|
IPv6: $piholeIPv6
|
||||||
|
|
||||||
If you set a new IP address, you should restart the Pi.
|
If you set a new IP address, you should restart the Pi.
|
||||||
|
|
||||||
The install log is in /etc/pihole." $r $c
|
The install log is in /etc/pihole." $r $c
|
||||||
}
|
}
|
||||||
|
|
||||||
######## SCRIPT ############
|
######## SCRIPT ############
|
||||||
|
|
13
pihole
13
pihole
|
@ -11,10 +11,10 @@
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# Must be root to use this tool
|
# Must be root to use this tool
|
||||||
if [[ $EUID -eq 0 ]];then
|
if [[ ! $EUID -eq 0 ]];then
|
||||||
echo "::: You are root."
|
#echo "::: You are root."
|
||||||
else
|
#else
|
||||||
echo "::: Sudo will be used for this tool."
|
#echo "::: Sudo will be used for this tool."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the pihole cannot be invoked without privileges.
|
# If it isn't, exit because the pihole cannot be invoked without privileges.
|
||||||
if [[ $(dpkg-query -s sudo) ]];then
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
|
@ -63,7 +63,8 @@ function setupLCDFunction {
|
||||||
}
|
}
|
||||||
|
|
||||||
function chronometerFunc {
|
function chronometerFunc {
|
||||||
$SUDO /opt/pihole/chronometer.sh
|
shift
|
||||||
|
$SUDO /opt/pihole/chronometer.sh "$@"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ case "$1" in
|
||||||
"-u" | "updateDashboard" ) updateDashboardFunc;;
|
"-u" | "updateDashboard" ) updateDashboardFunc;;
|
||||||
"-g" | "updateGravity" ) updateGravityFunc;;
|
"-g" | "updateGravity" ) updateGravityFunc;;
|
||||||
"-s" | "setupLCD" ) setupLCDFunction;;
|
"-s" | "setupLCD" ) setupLCDFunction;;
|
||||||
"-c" | "chronometer" ) chronometerFunc;;
|
"-c" | "chronometer" ) chronometerFunc "$@";;
|
||||||
"-h" | "help" ) helpFunc;;
|
"-h" | "help" ) helpFunc;;
|
||||||
"uninstall" ) uninstallFunc;;
|
"uninstall" ) uninstallFunc;;
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
|
|
Loading…
Reference in a new issue