Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi-Software | Pi-hole: Allow user choice whether to show blocking page #2201

Merged
merged 3 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Changes / Improvements / Optimisations:
- DietPi-Services | MariaDB: DietPi now uses the pre-installed "mariadb" systemd service instead of obsoleve "mysql" init.d service: https://github.com/Fourdee/DietPi/pull/2196
- DietPi-Software | Nextcloud Talk video calls with configured TURN server is now available for install: https://github.com/Fourdee/DietPi/pull/2197
- DietPi-Software | NAA Daemon: Added installation support for ARMv8 and x86_64. Thanks Jussi!
- DietPi-Software | Pi-hole: During (re)install you can now decide whether to show a blocking page to clients or not: https://github.com/Fourdee/DietPi/issues/2007

Bug Fixes:
- PREP: Resolved failed rootFS resize: https://github.com/Fourdee/DietPi/issues/2181#issuecomment-433715556
Expand Down
67 changes: 32 additions & 35 deletions dietpi/dietpi-software
Original file line number Diff line number Diff line change
Expand Up @@ -4457,18 +4457,9 @@ _EOF_
# - Install
wget "$INSTALL_URL_ADDRESS" -O install.sh
chmod +x install.sh

local commandline_options='--disable-install-webserver'

./install.sh $commandline_options
local exit_code=0 #always returns 5!
if (( $exit_code )); then

G_WHIP_MSG "Pi-hole installer exited with code ($exit_code) and is not installed."
aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]=0

fi

# Skip Lighttpd install, since user properly has chosen a different one, which was installed as pre-req.
./install.sh --disable-install-webserver
# We can't do reasonable exit code check, since installer always returns 5!
rm install.sh

fi
Expand Down Expand Up @@ -9202,35 +9193,42 @@ _EOF_

Banner_Configuration

# - Add Pi-hole user to www group
# usermod -a -G www-data pihole
# - Create symlinks to align Pi-hole admin and blocking page relative to webroot
cd /var/www
# Move existing files/dirs out of the way
[[ -L admin ]] || [[ -e admin ]] && mv -v admin admin.bak
ln -vsf html/admin admin
[[ -L pihole ]] || [[ -e pihole ]] && mv -v pihole pihole.bak
ln -vsf html/pihole pihole

# - Create a symlink so users can use http://ip/pihole
ln -sf /var/www/html/admin /var/www/pihole
# - Ask user whether to show blocking page
if G_WHIP_YESNO 'Pi-hole can show a blocking page, when clients access a blocked website. This allows you to whitelist domains directly from the blocking page and prevents the need to access the admin page or use the Pi-hole CLI for this.\n
The downside is additional traffic and less performance compared to a silent request block. Additional info can be found at: https://docs.pi-hole.net/ftldns/blockingmode/\n
Do you want to enable the Pi-hole blocking page?'; then

# - Create a symlink so users can use http://ip/admin
ln -sf /var/www/html/admin /var/www/admin
G_CONFIG_INJECT 'BLOCKINGMODE=' 'BLOCKINGMODE=IP-NODATA-AAAA' /etc/pihole/pihole-FTL.conf
# Link blocking page to webroot, where it is required
[[ -L index.php ]] || [[ -e index.php ]] && mv -v index.php index.php.bak
ln -vsf pihole/index.php index.php

# - Generate index page that replaces adverts and prevents popups
# G_RUN_CMD wget https://dietpi.com/images/pi-hole.png -O /var/www/pi-hole.png

systemctl enable pihole-FTL

# rm /var/www/index.php &> /dev/null
# ln -sf /var/www/html/pihole/index.php /var/www/index.php
else

# - Generate web interface PW: https://github.com/Fourdee/DietPi/issues/662
pihole -a -p "$GLOBAL_PW"
G_CONFIG_INJECT 'BLOCKINGMODE=' 'BLOCKINGMODE=NULL' /etc/pihole/pihole-FTL.conf

# - Run Gravity
pihole -g
fi
cd /tmp/$G_PROGRAM_NAME

# - Fix service to disable syslog pre-req preventing start
G_CONFIG_INJECT '# Required-Stop:' '# Required-Stop: $network $remote_fs' /etc/init.d/pihole-FTL
G_CONFIG_INJECT '# Required-Start:' '# Required-Start: $network $remote_fs' /etc/init.d/pihole-FTL
systemctl enable pihole-FTL

# - PiHole now generates a password, inform user of the correct one:
G_WHIP_MSG "DietPi has changed the Pi-hole web interface password to:\n- $GLOBAL_PW\n\nPlease use this password when logging into the web interface:\n - http://ip/pihole\n\nThis password can be changed, please see pihole binary for info:\n - pihole --help"
# - Run Gravity
pihole -g

# - Generate web interface PW: https://github.com/Fourdee/DietPi/issues/662
pihole -a -p "$GLOBAL_PW"
G_WHIP_MSG "DietPi has changed the Pi-hole web interface password to:\n - $GLOBAL_PW\n\nPlease use this password when logging into the web interface:\n - http://$(sed -n 4p /DietPi/dietpi/.network)/admin\n\nThis password can be changed, please see pihole binary for info:\n - pihole --help"

fi

Expand Down Expand Up @@ -13279,13 +13277,12 @@ _EOF_
# - symlinks
rm /var/www/pihole &> /dev/null
rm /var/www/admin &> /dev/null
[[ $(readlink /var/www/index.php) == 'pihole/index.php' ]] && rm /var/www/index.php

G_AGP dnsmasq #pre v4
# - pre Pi-hole v4
G_AGP dnsmasq
rm -R /etc/dnsmasq* &> /dev/null

#https://github.com/Fourdee/DietPi/issues/753
chmod 774 /etc/lighttpd/lighttpd.conf &> /dev/null

fi

UNINSTALLING_INDEX=33
Expand Down