Skip to content

Commit

Permalink
Merge pull request pi-hole#1021 from pi-hole/development
Browse files Browse the repository at this point in the history
[RELEASE] Pi-Hole Core 2.10.1
  • Loading branch information
PromoFaux authored Dec 23, 2016
2 parents bef0a2f + ffd31d8 commit bfe5506
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 159 deletions.
11 changes: 1 addition & 10 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@

**How familiar are you with the codebase?:**

- [] 1 (very unfamiliar)
- [] 2
- [] 3
- [] 4
- [] 5
- [] 6
- [] 7
- [] 8
- [] 9
- [] 10 (very familiar)
_{replace this text with a number from 1 to 10, with 1 being not familiar, and 10 being very familiar}_

---
**[FEATURE REQUEST | QUESTION | OTHER]:**
Expand Down
11 changes: 1 addition & 10 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@

**How familiar are you with the codebase?:**

- [] 1 (very unfamiliar)
- [] 2
- [] 3
- [] 4
- [] 5
- [] 6
- [] 7
- [] 8
- [] 9
- [] 10 (very familiar)
_{replace this text with a number from 1 to 10, with 1 being not familiar, and 10 being very familiar}_

---
_{replace this line with your pull request content}_
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## The multi-platform, network-wide ad blocker

Block ads for **all** your devices _without_ the need to install client-side software. The Pi-hole blocks ads the DNS-level, so all your devices are protected.
Block ads for **all** your devices _without_ the need to install client-side software. The Pi-hole blocks ads at the DNS-level, so all your devices are protected.

- Web Browsers
- Cell Phones
Expand Down Expand Up @@ -53,7 +53,7 @@ wget -O basic-install.sh https://install.pi-hole.net
bash basic-install.sh
```

Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](http://pi-hole.net/faq/can-i-set-the-pi-hole-to-be-the-dns-server-at-my-router-so-i-dont-have-to-change-settings-for-my-devices/) and then any device that connects to your network will have ads blocked without any further configuration. Alternatively, you can manually set each device to [use the Raspberry Pi as its DNS server](http://pi-hole.net/faq/how-do-i-use-the-pi-hole-as-my-dns-server/).
Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](https://discourse.pi-hole.net/t/how-do-i-configure-my-devices-to-use-pi-hole-as-their-dns-server/245) and then any device that connects to your network will have ads blocked without any further configuration. Alternatively, you can manually set each device to [use the Raspberry Pi as its DNS server](http://pi-hole.net/faq/how-do-i-use-the-pi-hole-as-my-dns-server/).

## Installing the Pi-hole (Click to Watch!)
<p align="center">
Expand Down
8 changes: 3 additions & 5 deletions advanced/Scripts/chronometer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
piLog="/var/log/pihole.log"
gravity="/etc/pihole/gravity.list"

today=$(date "+%b %e")

. /etc/pihole/setupVars.conf

CalcBlockedDomains() {
Expand All @@ -35,15 +33,15 @@ CalcBlockedDomains() {

CalcQueriesToday() {
if [ -e "${piLog}" ]; then
queriesToday=$(cat "${piLog}" | grep "${today}" | awk '/query/ {print $6}' | wc -l)
queriesToday=$(awk '/query\[/ {print $6}' < "${piLog}" | wc -l)
else
queriesToday="Err."
fi
}

CalcblockedToday() {
if [ -e "${piLog}" ] && [ -e "${gravity}" ];then
blockedToday=$(cat ${piLog} | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l)
blockedToday=$(awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' < "${piLog}" | wc -l)
else
blockedToday="Err."
fi
Expand Down Expand Up @@ -104,7 +102,7 @@ normalChrono() {

echo "Blocking: ${blockedDomainsTotal}"
echo "Queries: ${queriesToday}" #same total calculation as dashboard
echo "Pi-holed: ${blockedToday} (${percentBlockedToday}%)"
echo "Pi-holed: ${blockedToday} (${percentBlockedToday}%)"

sleep 5
done
Expand Down
17 changes: 16 additions & 1 deletion advanced/Scripts/webpage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ SetWebPassword(){
SetDNSServers(){

# Remove setting from file (create backup setupVars.conf.bak)
sed -i.bak '/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/DNS_FQDN_REQUIRED/d;' /etc/pihole/setupVars.conf
sed -i.bak '/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/DNS_FQDN_REQUIRED/d;/DNS_BOGUS_PRIV/d;' /etc/pihole/setupVars.conf
# Save setting to file
echo "PIHOLE_DNS_1=${args[2]}" >> /etc/pihole/setupVars.conf
if [[ "${args[3]}" != "none" ]]; then
Expand Down Expand Up @@ -215,6 +215,20 @@ SetDNSDomainName(){

}

ResolutionSettings() {

typ=${args[2]}
state=${args[3]}

if [[ "${typ}" == "forward" ]]; then
sed -i.bak '/API_GET_UPSTREAM_DNS_HOSTNAME/d;' /etc/pihole/setupVars.conf
echo "API_GET_UPSTREAM_DNS_HOSTNAME=${state}" >> /etc/pihole/setupVars.conf
elif [[ "${typ}" == "clients" ]]; then
sed -i.bak '/API_GET_CLIENT_HOSTNAME/d;' /etc/pihole/setupVars.conf
echo "API_GET_CLIENT_HOSTNAME=${state}" >> /etc/pihole/setupVars.conf
fi
}

case "${args[1]}" in
"-p" | "password" ) SetWebPassword;;
"-c" | "celsius" ) unit="C"; SetTemperatureUnit;;
Expand All @@ -231,6 +245,7 @@ case "${args[1]}" in
"layout" ) SetWebUILayout;;
"-h" | "--help" ) helpFunc;;
"domainname" ) SetDNSDomainName;;
"resolve" ) ResolutionSettings;;
* ) helpFunc;;
esac

Expand Down
7 changes: 4 additions & 3 deletions advanced/pihole.cron
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
# scripts, any changes made to this file will be overwritten when the softare
# is updated or re-installed. Please make any changes to the appropriate crontab
# or other cron file snippets.
PATH="$PATH:/usr/local/bin/"

# Pi-hole: Update the ad sources once a week on Sunday at 01:59
# Download any updates from the adlists
59 1 * * 7 root PATH="$PATH:/usr/local/bin/" pihole updateGravity
59 1 * * 7 root pihole updateGravity

# Pi-hole: Update Pi-hole! Uncomment to enable auto update
#30 2 * * 7 root PATH="$PATH:/usr/local/bin/" pihole updatePihole
#30 2 * * 7 root pihole updatePihole

# Pi-hole: Flush the log daily at 00:00 so it doesn't get out of control
# Stats will be viewable in the Web interface thanks to the cron job above
00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush
00 00 * * * root pihole flush
1 change: 0 additions & 1 deletion advanced/pihole.sudo
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

www-data ALL=NOPASSWD: /usr/local/bin/pihole
87 changes: 0 additions & 87 deletions advanced/selinux/pihole.te

This file was deleted.

72 changes: 48 additions & 24 deletions automated install/basic-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,14 @@ fi
is_repo() {
# Use git to check if directory is currently under VCS, return the value
local directory="${1}"
git -C "${directory}" status --short &> /dev/null
return
if [ -d $directory ]; then
# git -C is not used here to support git versions older than 1.8.4
curdir=$PWD; cd $directory; git status --short &> /dev/null; rc=$?; cd $curdir
return $rc
else
# non-zero return code if directory does not exist OR is not a valid git repository
return 1
fi
}

make_repo() {
Expand All @@ -152,7 +158,7 @@ make_repo() {
update_repo() {
local directory="${1}"
# Pull the latest commits
echo -n "::: Updating repo in $1..."
echo -n "::: Updating repo in $1..."
cd "${directory}" || exit 1
git stash -q &> /dev/null
git pull -q &> /dev/null
Expand Down Expand Up @@ -628,6 +634,7 @@ installScripts() {
# Install files from local core repository
if is_repo "${PI_HOLE_LOCAL_REPO}"; then
cd "${PI_HOLE_LOCAL_REPO}"
install -o "${USER}" -Dm755 -d /opt/pihole
install -o "${USER}" -Dm755 -t /opt/pihole/ gravity.sh
install -o "${USER}" -Dm755 -t /opt/pihole/ ./advanced/Scripts/*.sh
install -o "${USER}" -Dm755 -t /opt/pihole/ ./automated\ install/uninstall.sh
Expand Down Expand Up @@ -800,6 +807,15 @@ installPiholeWeb() {
echo -n "::: Installing sudoer file..."
mkdir -p /etc/sudoers.d/
cp /etc/.pihole/advanced/pihole.sudo /etc/sudoers.d/pihole
# Add lighttpd user (OS dependent) to sudoers file
echo "${LIGHTTPD_USER} ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole

if [[ "$LIGHTTPD_USER" == "lighttpd" ]]; then
# Allow executing pihole via sudo with Fedora
# Usually /usr/local/bin is not permitted as directory for sudoable programms
echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin" >> /etc/sudoers.d/pihole
fi

chmod 0440 /etc/sudoers.d/pihole
echo " done!"
}
Expand All @@ -820,8 +836,12 @@ runGravity() {
echo "::: Cleaning up previous install (preserving whitelist/blacklist)"
rm /etc/pihole/list.*
fi
# Test if /etc/pihole/adlists.default exists
if [[ ! -e /etc/pihole/adlists.default ]]; then
cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
fi
echo "::: Running gravity.sh"
/opt/pihole/gravity.sh
{ /opt/pihole/gravity.sh; }
}

create_pihole_user() {
Expand Down Expand Up @@ -877,7 +897,6 @@ installPihole() {
installScripts
installConfigs
CreateLogFile
configureSelinux
installPiholeWeb
installCron
configureFirewall
Expand Down Expand Up @@ -908,31 +927,32 @@ updatePihole() {
installScripts
installConfigs
CreateLogFile
configureSelinux
installPiholeWeb
installCron
configureFirewall
finalExports #re-export setupVars.conf to account for any new vars added in new versions
runGravity
}

configureSelinux() {


checkSelinux() {
if [ -x "$(command -v getenforce)" ]; then
printf "\n::: SELinux Detected\n"
printf ":::\tChecking for SELinux policy development packages..."
package_check_install "selinux-policy-devel" > /dev/null
echo " installed!"
printf ":::\tEnabling httpd server side includes (SSI).. "
setsebool -P httpd_ssi_exec on &> /dev/null && echo "Success" || echo "SELinux not enabled"
printf "\n:::\tCompiling Pi-Hole SELinux policy..\n"
if ! [ -x "$(command -v systemctl)" ]; then
sed -i.bak '/systemd/d' /etc/.pihole/advanced/selinux/pihole.te
echo ":::"
echo -n "::: SELinux Support Detected... Mode: "
enforceMode=$(getenforce)
echo "${enforceMode}"
if [[ "${enforceMode}" == "Enforcing" ]]; then
if (whiptail --title "SELinux Enforcing Detected" --yesno "SELinux is being Enforced on your system!\n\nPi-hole currently does not support SELinux, but you may still continue with the installation.\n\nNote: Admin UI Will not function fully without setting your policies correctly\n\nContinue installing Pi-hole?" ${r} ${c}); then
echo ":::"
echo "::: Continuing installation with SELinux Enforcing."
echo "::: Please refer to official SELinux documentation to create a custom policy."
else
echo ":::"
echo "::: Not continuing install after SELinux Enforcing detected."
exit 1
fi
fi
checkmodule -M -m -o /etc/pihole/pihole.mod /etc/.pihole/advanced/selinux/pihole.te
semodule_package -o /etc/pihole/pihole.pp -m /etc/pihole/pihole.mod
semodule -i /etc/pihole/pihole.pp
rm -f /etc/pihole/pihole.mod
semodule -l | grep pihole &> /dev/null && echo "::: Installed Pi-Hole SELinux policy" || echo "::: Warning: Pi-Hole SELinux policy did not install."
fi
}

Expand Down Expand Up @@ -998,7 +1018,8 @@ update_dialogs() {
}

main() {
# Check arguments for the undocumented flags

# Check arguments for the undocumented flags
for var in "$@"; do
case "$var" in
"--reconfigure" ) reconfigure=true;;
Expand Down Expand Up @@ -1033,6 +1054,9 @@ main() {
# Install packages used by this installation script
install_dependent_packages INSTALLER_DEPS[@]

# Check if SELinux is Enforcing
checkSelinux

if [[ "${reconfigure}" == true ]]; then
echo "::: --reconfigure passed to install script. Not downloading/updating local repos"
else
Expand All @@ -1053,10 +1077,10 @@ main() {
get_available_interfaces
# Find interfaces and let the user choose one
chooseInterface
# Let the user decide if they want to block ads over IPv4 and/or IPv6
use4andor6
# Decide what upstream DNS Servers to use
setDNS
# Let the user decide if they want to block ads over IPv4 and/or IPv6
use4andor6
# Let the user decide if they want query logging enabled...
setLogging

Expand Down
Loading

0 comments on commit bfe5506

Please sign in to comment.