2015-12-06 14:31:49 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-01-30 20:12:40 +00:00
|
|
|
# Pi-hole: A black hole for Internet advertisements
|
|
|
|
# (c) 2015, 2016 by Jacob Salmela
|
|
|
|
# Network-wide ad blocking via your Raspberry Pi
|
|
|
|
# http://pi-hole.net
|
|
|
|
# Completely uninstalls Pi-hole
|
2015-12-06 14:31:49 +00:00
|
|
|
#
|
|
|
|
# Pi-hole is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
2016-03-02 19:28:33 +00:00
|
|
|
# Check if root, and if not then rerun with sudo.
|
|
|
|
echo ":::"
|
2016-01-16 19:56:08 +00:00
|
|
|
if [[ $EUID -eq 0 ]];then
|
2016-03-02 19:28:33 +00:00
|
|
|
echo "::: You are root."
|
|
|
|
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
|
|
|
# rather than rerunning as sudo. Just in case it turns up by accident,
|
|
|
|
# explicitly set the $SUDO variable to an empty string.
|
|
|
|
SUDO=""
|
2016-01-16 19:56:08 +00:00
|
|
|
else
|
2016-03-02 19:28:33 +00:00
|
|
|
echo "::: sudo will be used."
|
|
|
|
# Check if it is actually installed
|
|
|
|
# If it isn't, exit because the install cannot complete
|
|
|
|
if [[ $(dpkg-query -s sudo) ]];then
|
2016-03-02 21:18:32 +00:00
|
|
|
echo "::: Running sudo $0 $@"
|
|
|
|
sudo "$0" "$@"
|
2016-03-02 19:28:33 +00:00
|
|
|
exit $?
|
|
|
|
else
|
|
|
|
echo "::: Please install sudo or run this script as root."
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-01-16 19:56:08 +00:00
|
|
|
fi
|
|
|
|
|
2015-11-21 19:29:03 +00:00
|
|
|
|
|
|
|
######### SCRIPT ###########
|
2016-03-02 19:28:33 +00:00
|
|
|
apt-get -y remove --purge dnsutils bc toilet
|
|
|
|
apt-get -y remove --purge dnsmasq
|
|
|
|
apt-get -y remove --purge lighttpd php5-common php5-cgi php5
|
2016-01-16 19:56:08 +00:00
|
|
|
|
|
|
|
# Only web directories/files that are created by pihole should be removed.
|
|
|
|
echo "Removing the Pi-hole Web server files..."
|
2016-03-02 19:28:33 +00:00
|
|
|
rm -rf /var/www/html/admin
|
|
|
|
rm -rf /var/www/html/pihole
|
|
|
|
rm /var/www/html/index.lighttpd.orig
|
2016-01-16 19:56:08 +00:00
|
|
|
|
|
|
|
# If the web directory is empty after removing these files, then the parent html folder can be removed.
|
|
|
|
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
2016-03-02 19:28:33 +00:00
|
|
|
rm -rf /var/www/html
|
2016-01-16 19:56:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Removing dnsmasq config files..."
|
2016-03-02 19:28:33 +00:00
|
|
|
rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
2016-01-16 19:56:08 +00:00
|
|
|
|
|
|
|
# Attempt to preserve backwards compatibility with older versions
|
|
|
|
# to guarantee no additional changes were made to /etc/crontab after
|
|
|
|
# the installation of pihole, /etc/crontab.pihole should be permanently
|
|
|
|
# preserved.
|
|
|
|
if [[ -f /etc/crontab.orig ]]; then
|
|
|
|
echo "Initial Pi-hole cron detected. Restoring the default system cron..."
|
2016-03-02 19:28:33 +00:00
|
|
|
mv /etc/crontab /etc/crontab.pihole
|
|
|
|
mv /etc/crontab.orig /etc/crontab
|
|
|
|
service cron restart
|
2016-01-16 19:56:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Attempt to preserve backwards compatibility with older versions
|
|
|
|
if [[ -f /etc/cron.d/pihole ]];then
|
|
|
|
echo "Removing cron.d/pihole..."
|
2016-03-02 19:28:33 +00:00
|
|
|
rm /etc/cron.d/pihole
|
2016-01-16 19:56:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Removing config files and scripts..."
|
2016-03-02 19:28:33 +00:00
|
|
|
rm /etc/dnsmasq.conf
|
2016-03-02 20:49:23 +00:00
|
|
|
rm /etc/sudoers.d/pihole
|
2016-03-02 19:28:33 +00:00
|
|
|
rm -rf /etc/lighttpd/
|
|
|
|
rm /var/log/pihole.log
|
|
|
|
rm /usr/local/bin/gravity.sh
|
|
|
|
rm /usr/local/bin/chronometer.sh
|
|
|
|
rm /usr/local/bin/whitelist.sh
|
2016-03-02 20:49:23 +00:00
|
|
|
rm /usr/local/bin/piholeReloadServices.sh
|
|
|
|
rm /usr/local/bin/piholeSetPermissions.sh
|
2016-03-02 19:28:33 +00:00
|
|
|
rm /usr/local/bin/piholeLogFlush.sh
|
2016-03-02 20:53:28 +00:00
|
|
|
rm /usr/local/bin/updateDashboard.sh
|
2016-03-02 19:28:33 +00:00
|
|
|
rm -rf /etc/pihole/
|