diff --git a/README.md b/README.md index 60c54f87..77f259e6 100644 --- a/README.md +++ b/README.md @@ -68,12 +68,11 @@ Sending a donation using our links below is **extremely helpful** in offsetting ### Alternative support If you'd rather not [donate](https://pi-hole.net/donate/) (_which is okay!_), there are other ways you can help support us: - +- [Patreon](https://patreon.com/pihole) _Become a patron for rewards_ - [Digital Ocean](http://www.digitalocean.com/?refcode=344d234950e1) _affiliate link_ - [UNIXstickers.com](http://unixstickers.refr.cc/jacobs) _save $5 when you spend $9 using our affiliate link_ - [Pi-hole Swag Store](https://pi-hole.net/shop/) _affiliate link_ - [Amazon](http://www.amazon.com/exec/obidos/redirect-home/pihole09-20) _affiliate link_ -- [Ho-ost](https://clients.ho-ost.com/aff.php?aff=19) _save 50% with our affiliate link_ - [DNS Made Easy](https://cp.dnsmadeeasy.com/u/133706) _affiliate link_ - [Vultr](http://www.vultr.com/?ref=7190426) _affiliate link_ - Spreading the word about our software, and how you have benefited from it @@ -99,9 +98,6 @@ While we are primarily reachable on our Frequently Asked Questions
/etc/pihole/
! Please update gravity by running pihole -g
, or repair Pi-hole using pihole -r
.");
+}
// Set location of adlists file
if (is_file("/etc/pihole/adlists.list")) {
@@ -327,6 +329,7 @@ setHeader();
setTimeout(function(){window.location.reload(1);}, 10000);
$("#bpOutput").removeClass("add");
$("#bpOutput").addClass("success");
+ $("#bpOutput").html("");
} else {
$("#bpOutput").removeClass("add");
$("#bpOutput").addClass("error");
@@ -336,6 +339,7 @@ setHeader();
error: function(jqXHR, exception) {
$("#bpOutput").removeClass("add");
$("#bpOutput").addClass("exception");
+ $("#bpOutput").html("");
}
});
}
diff --git a/advanced/pihole-FTL.service b/advanced/pihole-FTL.service
index ef8ee9c2..ecc7a52a 100644
--- a/advanced/pihole-FTL.service
+++ b/advanced/pihole-FTL.service
@@ -69,13 +69,25 @@ stop() {
echo
}
+# Indicate the service status
+status() {
+ if is_running; then
+ echo "[ ok ] pihole-FTL is running"
+ exit 0
+ else
+ echo "[ ] pihole-FTL is not running"
+ exit 1
+ fi
+}
+
+
### main logic ###
case "$1" in
stop)
stop
;;
status)
- status pihole-FTL
+ status
;;
start|restart|reload|condrestart)
stop
diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
index 3100ce58..36d717f5 100755
--- a/automated install/basic-install.sh
+++ b/automated install/basic-install.sh
@@ -58,6 +58,10 @@ IPV6_ADDRESS=""
QUERY_LOGGING=true
INSTALL_WEB_INTERFACE=true
+if [ -z "${USER}" ]; then
+ USER="$(id -un)"
+fi
+
# Find the rows and columns will default to 80x24 if it can not be detected
screen_size=$(stty size 2>/dev/null || echo 24 80)
@@ -156,13 +160,29 @@ if command -v apt-get &> /dev/null; then
# use iproute
iproute_pkg="iproute"
fi
- # We prefer the php metapackage if it's there
- if ${PKG_MANAGER} install --dry-run php > /dev/null 2>&1; then
- phpVer="php"
- # If not,
- else
+ # Check for and determine version number (major and minor) of current php install
+ if command -v php &> /dev/null; then
+ phpInsVersion="$(php -v | head -n1 | grep -Po '(?<=PHP )[^ ]+')"
+ echo -e " ${INFO} Existing PHP installation detected : PHP version $phpInsVersion"
+ phpInsMajor="$(echo "$phpInsVersion" | cut -d\. -f1)"
+ phpInsMinor="$(echo "$phpInsVersion" | cut -d\. -f2)"
+ # Is installed php version 7.0 or greater
+ if [ "$(echo "$phpInsMajor.$phpInsMinor < 7.0" | bc )" == 0 ]; then
+ phpInsNewer=true
+ fi
+ fi
+ # Check if installed php is v 7.0, or newer to determine packages to install
+ if [[ "$phpInsNewer" != true ]]; then
+ # Prefer the php metapackage if it's there
+ if ${PKG_MANAGER} install --dry-run php > /dev/null 2>&1; then
+ phpVer="php"
# fall back on the php5 packages
- phpVer="php5"
+ else
+ phpVer="php5"
+ fi
+ else
+ # Newer php is installed, its common, cgi & sqlite counterparts are deps
+ phpVer="php$phpInsMajor.$phpInsMinor"
fi
# We also need the correct version for `php-sqlite` (which differs across distros)
if ${PKG_MANAGER} install --dry-run ${phpVer}-sqlite3 > /dev/null 2>&1; then
@@ -215,16 +235,73 @@ elif command -v rpm &> /dev/null; then
UPDATE_PKG_CACHE=":"
PKG_INSTALL=(${PKG_MANAGER} install -y)
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
- INSTALLER_DEPS=(dialog git iproute net-tools newt procps-ng)
+ INSTALLER_DEPS=(dialog git iproute net-tools newt procps-ng which)
PIHOLE_DEPS=(bc bind-utils cronie curl findutils nmap-ncat sudo unzip wget libidn2 psmisc)
- PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php php-common php-cli php-pdo)
- # EPEL (https://fedoraproject.org/wiki/EPEL) is required for lighttpd on CentOS
- if grep -qi 'centos' /etc/redhat-release; then
- INSTALLER_DEPS=("${INSTALLER_DEPS[@]}" "epel-release");
+ PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php-common php-cli php-pdo)
+ LIGHTTPD_USER="lighttpd"
+ LIGHTTPD_GROUP="lighttpd"
+ LIGHTTPD_CFG="lighttpd.conf.fedora"
+ # If the host OS is Fedora,
+ if grep -qi 'fedora' /etc/redhat-release; then
+ # all required packages should be available by default with the latest fedora release
+ : # continue
+ # or if host OS is CentOS,
+ elif grep -qi 'centos' /etc/redhat-release; then
+ # Pi-Hole currently supports CentOS 7+ with PHP7+
+ SUPPORTED_CENTOS_VERSION=7
+ SUPPORTED_CENTOS_PHP_VERSION=7
+ # Check current CentOS major release version
+ CURRENT_CENTOS_VERSION=$(rpm -q --queryformat '%{VERSION}' centos-release)
+ # Check if CentOS version is supported
+ if [[ $CURRENT_CENTOS_VERSION -lt $SUPPORTED_CENTOS_VERSION ]]; then
+ echo -e " ${CROSS} CentOS $CURRENT_CENTOS_VERSION is not suported."
+ echo -e " Please update to CentOS release $SUPPORTED_CENTOS_VERSION or later"
+ # exit the installer
+ exit
+ fi
+ # on CentOS we need to add the EPEL repository to gain access to Fedora packages
+ EPEL_PKG="epel-release"
+ rpm -q ${EPEL_PKG} &> /dev/null || rc=$?
+ if [[ $rc -ne 0 ]]; then
+ echo -e " ${INFO} Enabling EPEL package repository (https://fedoraproject.org/wiki/EPEL)"
+ "${PKG_INSTALL[@]}" ${EPEL_PKG} &> /dev/null
+ echo -e " ${TICK} Installed ${EPEL_PKG}"
+ fi
+
+ # The default php on CentOS 7.x is 5.4 which is EOL
+ # Check if the version of PHP available via installed repositories is >= to PHP 7
+ AVAILABLE_PHP_VERSION=$(${PKG_MANAGER} info php | grep -i version | grep -o '[0-9]\+' | head -1)
+ if [[ $AVAILABLE_PHP_VERSION -ge $SUPPORTED_CENTOS_PHP_VERSION ]]; then
+ # Since PHP 7 is available by default, install via default PHP package names
+ : # do nothing as PHP is current
+ else
+ REMI_PKG="remi-release"
+ REMI_REPO="remi-php72"
+ rpm -q ${REMI_PKG} &> /dev/null || rc=$?
+ if [[ $rc -ne 0 ]]; then
+ # The PHP version available via default repositories is older than version 7
+ if ! whiptail --defaultno --title "PHP 7 Update (recommended)" --yesno "PHP 7.x is recommended for both security and language features.\\nWould you like to install PHP7 via Remi's RPM repository?\\n\\nSee: https://rpms.remirepo.net for more information" ${r} ${c}; then
+ # User decided to NOT update PHP from REMI, attempt to install the default available PHP version
+ echo -e " ${INFO} User opt-out of PHP 7 upgrade on CentOS. Deprecated PHP may be in use."
+ : # continue with unsupported php version
+ else
+ echo -e " ${INFO} Enabling Remi's RPM repository (https://rpms.remirepo.net)"
+ "${PKG_INSTALL[@]}" "https://rpms.remirepo.net/enterprise/${REMI_PKG}-$(rpm -E '%{rhel}').rpm" &> /dev/null
+ # enable the PHP 7 repository via yum-config-manager (provided by yum-utils)
+ "${PKG_INSTALL[@]}" "yum-utils" &> /dev/null
+ yum-config-manager --enable ${REMI_REPO} &> /dev/null
+ echo -e " ${TICK} Remi's RPM repository has been enabled for PHP7"
+
+ fi
+ fi
+ fi
+ else
+ # If not a supported version of Fedora or CentOS,
+ echo -e " ${CROSS} Unsupported RPM based distribution"
+ # exit the installer
+ exit
fi
- LIGHTTPD_USER="lighttpd"
- LIGHTTPD_GROUP="lighttpd"
- LIGHTTPD_CFG="lighttpd.conf.fedora"
+
# If neither apt-get or rmp/dnf are found
else
@@ -916,7 +993,7 @@ setLogging() {
local LogChoices
# Ask if the user wants to log queries
- LogToggleCommand=(whiptail --separate-output --radiolist "Do you want to log queries?\\n (Disabling will render graphs on the Admin page useless):" ${r} ${c} 6)
+ LogToggleCommand=(whiptail --separate-output --radiolist "Do you want to log queries?" "${r}" "${c}" 6)
# The default selection is on
LogChooseOptions=("On (Recommended)" "" on
Off "" off)
@@ -1189,6 +1266,44 @@ installConfigs() {
fi
}
+install_manpage() {
+ # Copy Pi-hole man pages and call mandb to update man page database
+ # Default location for man files for /usr/local/bin is /usr/local/share/man
+ # on lightweight systems may not be present, so check before copying.
+ echo -en " ${INFO} Testing man page installation"
+ if ! command -v mandb &>/dev/null; then
+ # if mandb is not present, no manpage support
+ echo -e "${OVER} ${INFO} man not installed"
+ return
+ elif [[ ! -d "/usr/local/share/man" ]]; then
+ # appropriate directory for Pi-hole's man page is not present
+ echo -e "${OVER} ${INFO} man pages not installed"
+ return
+ fi
+ if [[ ! -d "/usr/local/share/man/man8" ]]; then
+ # if not present, create man8 directory
+ mkdir /usr/local/share/man/man8
+ fi
+ if [[ ! -d "/usr/local/share/man/man5" ]]; then
+ # if not present, create man8 directory
+ mkdir /usr/local/share/man/man5
+ fi
+ # Testing complete, copy the files & update the man db
+ cp ${PI_HOLE_LOCAL_REPO}/manpages/pihole.8 /usr/local/share/man/man8/pihole.8
+ cp ${PI_HOLE_LOCAL_REPO}/manpages/pihole-FTL.8 /usr/local/share/man/man8/pihole-FTL.8
+ cp ${PI_HOLE_LOCAL_REPO}/manpages/pihole-FTL.conf.5 /usr/local/share/man/man5/pihole-FTL.conf.5
+ if mandb -q &>/dev/null; then
+ # Updated successfully
+ echo -e "${OVER} ${TICK} man pages installed and database updated"
+ return
+ else
+ # Something is wrong with the system's man installation, clean up
+ # our files, (leave everything how we found it).
+ rm /usr/local/share/man/man8/pihole.8 /usr/local/share/man/man8/pihole-FTL.8 /usr/local/share/man/man5/pihole-FTL.conf.5
+ echo -e "${OVER} ${CROSS} man page db not updated, man pages not installed"
+ fi
+}
+
stop_service() {
# Stop service passed in as argument.
# Can softfail, as process may not be installed when this is called
@@ -1265,6 +1380,30 @@ check_service_active() {
fi
}
+# Systemd-resolved's DNSStubListener and dnsmasq can't share port 53.
+disable_resolved_stublistener() {
+ echo -en " ${INFO} Testing if systemd-resolved is enabled"
+ # Check if Systemd-resolved's DNSStubListener is enabled and active on port 53
+ if check_service_active "systemd-resolved"; then
+ # Check if DNSStubListener is enabled
+ echo -en " ${OVER} ${INFO} Testing if systemd-resolved DNSStub-Listener is active"
+ if ( grep -E '#?DNSStubListener=yes' /etc/systemd/resolved.conf &> /dev/null ); then
+ # Disable the DNSStubListener to unbind it from port 53
+ # Note that this breaks dns functionality on host until dnsmasq/ftl are up and running
+ echo -en "${OVER} ${TICK} Disabling systemd-resolved DNSStubListener"
+ # Make a backup of the original /etc/systemd/resolved.conf
+ # (This will need to be restored on uninstallation)
+ sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf
+ echo -e " and restarting systemd-resolved"
+ systemctl reload-or-restart systemd-resolved
+ else
+ echo -e "${OVER} ${INFO} Systemd-resolved does not need to be restarted"
+ fi
+ else
+ echo -e "${OVER} ${INFO} Systemd-resolved is not enabled"
+ fi
+}
+
update_package_cache() {
# Running apt-get update/upgrade with minimal output can cause some issues with
# requiring user input (e.g password for phpmyadmin see #218)
@@ -1667,6 +1806,9 @@ installPihole() {
configureFirewall
fi
+ # install a man page entry for pihole
+ install_manpage
+
# Update setupvars.conf with any variables that may or may not have been changed during the install
finalExports
}
@@ -1902,7 +2044,6 @@ FTLinstall() {
local ftlBranch
local url
- local ftlBranch
if [[ -f "/etc/pihole/ftlbranch" ]];then
ftlBranch=$( /dev/null)
+
+ # Special case: This is a 32 bit OS, installed on a 64 bit machine
+ # -> change machine architecture to download the 32 bit executable
+ if [[ "${dpkgarch}" == "i386" ]]; then
+ echo -e "${OVER} ${TICK} Detected 32bit (i686) architecture"
+ binary="pihole-FTL-linux-x86_32"
+ else
+ # 64bit
+ echo -e "${OVER} ${TICK} Detected x86_64 architecture"
+ # set the binary to be used
+ binary="pihole-FTL-linux-x86_64"
+ fi
else
# Something else - we try to use 32bit executable and warn the user
if [[ ! "${machine}" == "i686" ]]; then
@@ -2262,13 +2413,11 @@ main() {
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
enable_service lighttpd
fi
-
- if [[ -x "$(command -v systemctl)" ]]; then
- # Value will either be 1, if true, or 0
- LIGHTTPD_ENABLED=$(systemctl is-enabled lighttpd | grep -c 'enabled' || true)
- else
- # Value will either be 1, if true, or 0
- LIGHTTPD_ENABLED=$(service lighttpd status | awk '/Loaded:/ {print $0}' | grep -c 'enabled' || true)
+ # Determine if lighttpd is correctly enabled
+ if check_service_active "lighttpd"; then
+ LIGHTTPD_ENABLED=true
+ else
+ LIGHTTPD_ENABLED=false
fi
# Install and log everything to a file
@@ -2290,13 +2439,16 @@ main() {
fi
fi
- echo -e " ${INFO} Restarting services..."
- # Start services
+ # Check for and disable systemd-resolved-DNSStubListener before reloading resolved
+ # DNSStubListener needs to remain in place for installer to download needed files,
+ # so this change needs to be made after installation is complete,
+ # but before starting or resarting the dnsmasq or ftl services
+ disable_resolved_stublistener
# If the Web server was installed,
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
- if [[ "${LIGHTTPD_ENABLED}" == "1" ]]; then
+ if [[ "${LIGHTTPD_ENABLED}" == true ]]; then
start_service lighttpd
enable_service lighttpd
else
@@ -2304,6 +2456,9 @@ main() {
fi
fi
+ echo -e " ${INFO} Restarting services..."
+ # Start services
+
# Enable FTL
start_service pihole-FTL
enable_service pihole-FTL
diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh
index 2f4c58a1..9322de92 100755
--- a/automated install/uninstall.sh
+++ b/automated install/uninstall.sh
@@ -11,29 +11,29 @@
source "/opt/pihole/COL_TABLE"
while true; do
- read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " yn
- case ${yn} in
- [Yy]* ) break;;
- [Nn]* ) echo -e "\n ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;;
- * ) echo -e "\n ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;;
- esac
+ read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " yn
+ case ${yn} in
+ [Yy]* ) break;;
+ [Nn]* ) echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;;
+ * ) echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;;
+ esac
done
# Must be root to uninstall
str="Root user check"
if [[ ${EUID} -eq 0 ]]; then
- echo -e " ${TICK} ${str}"
+ echo -e " ${TICK} ${str}"
else
- # Check if sudo is actually installed
- # If it isn't, exit because the uninstall can not complete
- if [ -x "$(command -v sudo)" ]; then
- export SUDO="sudo"
- else
- echo -e " ${CROSS} ${str}
- Script called with non-root privileges
- The Pi-hole requires elevated privleges to uninstall"
- exit 1
- fi
+ # Check if sudo is actually installed
+ # If it isn't, exit because the uninstall can not complete
+ if [ -x "$(command -v sudo)" ]; then
+ export SUDO="sudo"
+ else
+ echo -e " ${CROSS} ${str}
+ Script called with non-root privileges
+ The Pi-hole requires elevated privleges to uninstall"
+ exit 1
+ fi
fi
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
@@ -48,173 +48,170 @@ distro_check
# Install packages used by the Pi-hole
DEPS=("${INSTALLER_DEPS[@]}" "${PIHOLE_DEPS[@]}")
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
- # Install the Web dependencies
- DEPS+=("${PIHOLE_WEB_DEPS[@]}")
+ # Install the Web dependencies
+ DEPS+=("${PIHOLE_WEB_DEPS[@]}")
fi
# Compatability
-if [ -x "$(command -v rpm)" ]; then
- # Fedora Family
- PKG_REMOVE="${PKG_MANAGER} remove -y"
- package_check() {
- rpm -qa | grep ^$1- > /dev/null
- }
- package_cleanup() {
- ${SUDO} ${PKG_MANAGER} -y autoremove
- }
-elif [ -x "$(command -v apt-get)" ]; then
- # Debian Family
- PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
- package_check() {
- dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
- }
- package_cleanup() {
- ${SUDO} ${PKG_MANAGER} -y autoremove
- ${SUDO} ${PKG_MANAGER} -y autoclean
- }
+if [ -x "$(command -v apt-get)" ]; then
+ # Debian Family
+ PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
+ package_check() {
+ dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
+ }
+elif [ -x "$(command -v rpm)" ]; then
+ # Fedora Family
+ PKG_REMOVE="${PKG_MANAGER} remove -y"
+ package_check() {
+ rpm -qa | grep "^$1-" > /dev/null
+ }
else
- echo -e " ${CROSS} OS distribution not supported"
- exit 1
+ echo -e " ${CROSS} OS distribution not supported"
+ exit 1
fi
removeAndPurge() {
- # Purge dependencies
- echo ""
- for i in "${DEPS[@]}"; do
- package_check ${i} > /dev/null
- if [[ "$?" -eq 0 ]]; then
- while true; do
- read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn
- case ${yn} in
- [Yy]* )
- echo -ne " ${INFO} Removing ${i}...";
- ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null;
- echo -e "${OVER} ${INFO} Removed ${i}";
- break;;
- [Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;;
- esac
- done
- else
- echo -e " ${INFO} Package ${i} not installed"
- fi
- done
+ # Purge dependencies
+ echo ""
+ for i in "${DEPS[@]}"; do
+ if package_check "${i}" > /dev/null; then
+ while true; do
+ read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn
+ case ${yn} in
+ [Yy]* )
+ echo -ne " ${INFO} Removing ${i}...";
+ ${SUDO} "${PKG_REMOVE} ${i}" &> /dev/null;
+ echo -e "${OVER} ${INFO} Removed ${i}";
+ break;;
+ [Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;;
+ esac
+ done
+ else
+ echo -e " ${INFO} Package ${i} not installed"
+ fi
+ done
- # Remove dnsmasq config files
- ${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
- echo -e " ${TICK} Removing dnsmasq config files"
+ # Remove dnsmasq config files
+ ${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/*-pihole*.conf &> /dev/null
+ echo -e " ${TICK} Removing dnsmasq config files"
- # Take care of any additional package cleaning
- echo -ne " ${INFO} Removing & cleaning remaining dependencies..."
- package_cleanup &> /dev/null
- echo -e "${OVER} ${TICK} Removed & cleaned up remaining dependencies"
-
- # Call removeNoPurge to remove Pi-hole specific files
- removeNoPurge
+ # Call removeNoPurge to remove Pi-hole specific files
+ removeNoPurge
}
removeNoPurge() {
- # Only web directories/files that are created by Pi-hole should be removed
- echo -ne " ${INFO} Removing Web Interface..."
- ${SUDO} rm -rf /var/www/html/admin &> /dev/null
- ${SUDO} rm -rf /var/www/html/pihole &> /dev/null
- ${SUDO} rm -f /var/www/html/index.lighttpd.orig &> /dev/null
+ # Only web directories/files that are created by Pi-hole should be removed
+ echo -ne " ${INFO} Removing Web Interface..."
+ ${SUDO} rm -rf /var/www/html/admin &> /dev/null
+ ${SUDO} rm -rf /var/www/html/pihole &> /dev/null
+ ${SUDO} rm -f /var/www/html/index.lighttpd.orig &> /dev/null
- # If the web directory is empty after removing these files, then the parent html folder can be removed.
- if [ -d "/var/www/html" ]; then
- if [[ ! "$(ls -A /var/www/html)" ]]; then
- ${SUDO} rm -rf /var/www/html &> /dev/null
- fi
- fi
- echo -e "${OVER} ${TICK} Removed Web Interface"
-
- # 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
- ${SUDO} mv /etc/crontab /etc/crontab.pihole
- ${SUDO} mv /etc/crontab.orig /etc/crontab
- ${SUDO} service cron restart
- echo -e " ${TICK} Restored the default system cron"
- fi
-
- # Attempt to preserve backwards compatibility with older versions
- if [[ -f /etc/cron.d/pihole ]];then
- ${SUDO} rm -f /etc/cron.d/pihole &> /dev/null
- echo -e " ${TICK} Removed /etc/cron.d/pihole"
- fi
-
- package_check lighttpd > /dev/null
- if [[ $? -eq 1 ]]; then
- ${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
- echo -e " ${TICK} Removed lighttpd"
- else
- if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
- ${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
- fi
- fi
-
- ${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null
- ${SUDO} rm -f /etc/dnsmasq.d/01-pihole.conf &> /dev/null
- ${SUDO} rm -rf /var/log/*pihole* &> /dev/null
- ${SUDO} rm -rf /etc/pihole/ &> /dev/null
- ${SUDO} rm -rf /etc/.pihole/ &> /dev/null
- ${SUDO} rm -rf /opt/pihole/ &> /dev/null
- ${SUDO} rm -f /usr/local/bin/pihole &> /dev/null
- ${SUDO} rm -f /etc/bash_completion.d/pihole &> /dev/null
- ${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null
- echo -e " ${TICK} Removed config files"
-
- # Remove FTL
- if command -v pihole-FTL &> /dev/null; then
- echo -ne " ${INFO} Removing pihole-FTL..."
-
- if [[ -x "$(command -v systemctl)" ]]; then
- systemctl stop pihole-FTL
- else
- service pihole-FTL stop
+ # If the web directory is empty after removing these files, then the parent html folder can be removed.
+ if [ -d "/var/www/html" ]; then
+ if [[ ! "$(ls -A /var/www/html)" ]]; then
+ ${SUDO} rm -rf /var/www/html &> /dev/null
+ fi
+ fi
+ echo -e "${OVER} ${TICK} Removed Web Interface"
+
+ # 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
+ ${SUDO} mv /etc/crontab /etc/crontab.pihole
+ ${SUDO} mv /etc/crontab.orig /etc/crontab
+ ${SUDO} service cron restart
+ echo -e " ${TICK} Restored the default system cron"
fi
- ${SUDO} rm -f /etc/init.d/pihole-FTL
- ${SUDO} rm -f /usr/bin/pihole-FTL
- echo -e "${OVER} ${TICK} Removed pihole-FTL"
- fi
-
- # If the pihole user exists, then remove
- if id "pihole" &> /dev/null; then
- ${SUDO} userdel -r pihole 2> /dev/null
- if [[ "$?" -eq 0 ]]; then
- echo -e " ${TICK} Removed 'pihole' user"
- else
- echo -e " ${CROSS} Unable to remove 'pihole' user"
+ # Attempt to preserve backwards compatibility with older versions
+ if [[ -f /etc/cron.d/pihole ]];then
+ ${SUDO} rm -f /etc/cron.d/pihole &> /dev/null
+ echo -e " ${TICK} Removed /etc/cron.d/pihole"
fi
- fi
- echo -e "\n We're sorry to see you go, but thanks for checking out Pi-hole!
- If you need help, reach out to us on Github, Discourse, Reddit or Twitter
- Reinstall at any time: ${COL_WHITE}curl -sSL https://install.pi-hole.net | bash${COL_NC}
+ package_check lighttpd > /dev/null
+ if [[ $? -eq 1 ]]; then
+ ${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
+ echo -e " ${TICK} Removed lighttpd"
+ else
+ if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
+ ${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
+ fi
+ fi
- ${COL_LIGHT_RED}Please reset the DNS on your router/clients to restore internet connectivity
- ${COL_LIGHT_GREEN}Uninstallation Complete! ${COL_NC}"
+ ${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null
+ ${SUDO} rm -f /etc/dnsmasq.d/01-pihole.conf &> /dev/null
+ ${SUDO} rm -rf /var/log/*pihole* &> /dev/null
+ ${SUDO} rm -rf /etc/pihole/ &> /dev/null
+ ${SUDO} rm -rf /etc/.pihole/ &> /dev/null
+ ${SUDO} rm -rf /opt/pihole/ &> /dev/null
+ ${SUDO} rm -f /usr/local/bin/pihole &> /dev/null
+ ${SUDO} rm -f /etc/bash_completion.d/pihole &> /dev/null
+ ${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null
+ echo -e " ${TICK} Removed config files"
+
+ # Restore Resolved
+ if [[ -e /etc/systemd/resolved.conf.orig ]]; then
+ ${SUDO} cp /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf
+ systemctl reload-or-restart systemd-resolved
+ fi
+
+ # Remove FTL
+ if command -v pihole-FTL &> /dev/null; then
+ echo -ne " ${INFO} Removing pihole-FTL..."
+ if [[ -x "$(command -v systemctl)" ]]; then
+ systemctl stop pihole-FTL
+ else
+ service pihole-FTL stop
+ fi
+ ${SUDO} rm -f /etc/init.d/pihole-FTL
+ ${SUDO} rm -f /usr/bin/pihole-FTL
+ echo -e "${OVER} ${TICK} Removed pihole-FTL"
+ fi
+
+ # If the pihole manpage exists, then delete and rebuild man-db
+ if [[ -f /usr/local/share/man/man8/pihole.8 ]]; then
+ ${SUDO} rm -f /usr/local/share/man/man8/pihole.8 /usr/local/share/man/man8/pihole-FTL.8 /usr/local/share/man/man5/pihole-FTL.conf.5
+ ${SUDO} mandb -q &>/dev/null
+ echo -e " ${TICK} Removed pihole man page"
+ fi
+
+ # If the pihole user exists, then remove
+ if id "pihole" &> /dev/null; then
+ if ${SUDO} userdel -r pihole 2> /dev/null; then
+ echo -e " ${TICK} Removed 'pihole' user"
+ else
+ echo -e " ${CROSS} Unable to remove 'pihole' user"
+ fi
+ fi
+
+ echo -e "\\n We're sorry to see you go, but thanks for checking out Pi-hole!
+ If you need help, reach out to us on Github, Discourse, Reddit or Twitter
+ Reinstall at any time: ${COL_WHITE}curl -sSL https://install.pi-hole.net | bash${COL_NC}
+
+ ${COL_LIGHT_RED}Please reset the DNS on your router/clients to restore internet connectivity
+ ${COL_LIGHT_GREEN}Uninstallation Complete! ${COL_NC}"
}
######### SCRIPT ###########
if command -v vcgencmd &> /dev/null; then
- echo -e " ${INFO} All dependencies are safe to remove on Raspbian"
+ echo -e " ${INFO} All dependencies are safe to remove on Raspbian"
else
- echo -e " ${INFO} Be sure to confirm if any dependencies should not be removed"
+ echo -e " ${INFO} Be sure to confirm if any dependencies should not be removed"
fi
while true; do
- echo -e " ${INFO} ${COL_YELLOW}The following dependencies may have been added by the Pi-hole install:"
- echo -n " "
- for i in "${DEPS[@]}"; do
- echo -n "${i} "
- done
- echo "${COL_NC}"
- read -rp " ${QST} Do you wish to go through each dependency for removal? (Choosing No will leave all dependencies installed) [Y/n] " yn
- case ${yn} in
- [Yy]* ) removeAndPurge; break;;
- [Nn]* ) removeNoPurge; break;;
- * ) removeAndPurge; break;;
- esac
+ echo -e " ${INFO} ${COL_YELLOW}The following dependencies may have been added by the Pi-hole install:"
+ echo -n " "
+ for i in "${DEPS[@]}"; do
+ echo -n "${i} "
+ done
+ echo "${COL_NC}"
+ read -rp " ${QST} Do you wish to go through each dependency for removal? (Choosing No will leave all dependencies installed) [Y/n] " yn
+ case ${yn} in
+ [Yy]* ) removeAndPurge; break;;
+ [Nn]* ) removeNoPurge; break;;
+ * ) removeAndPurge; break;;
+ esac
done
diff --git a/gravity.sh b/gravity.sh
index aaab6237..9a5a5fd7 100755
--- a/gravity.sh
+++ b/gravity.sh
@@ -279,9 +279,9 @@ gravity_ParseFileIntoDomains() {
# Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious
# This helps with that and makes it easier to read
# It also helps with debugging so each stage of the script can be researched more in depth
- #Awk -F splits on given IFS, we grab the right hand side (chops trailing #coments and /'s to grab the domain only.
- #Last awk command takes non-commented lines and if they have 2 fields, take the left field (the domain) and leave
- #+ the right (IP address), otherwise grab the single field.
+ # Awk -F splits on given IFS, we grab the right hand side (chops trailing #coments and /'s to grab the domain only.
+ # Last awk command takes non-commented lines and if they have 2 fields, take the right field (the domain) and leave
+ # the left (IP address), otherwise grab the single field.
< ${source} awk -F '#' '{print $1}' | \
awk -F '/' '{print $1}' | \
diff --git a/manpages/pihole-FTL.8 b/manpages/pihole-FTL.8
new file mode 100644
index 00000000..2928f2d8
--- /dev/null
+++ b/manpages/pihole-FTL.8
@@ -0,0 +1,112 @@
+.TH "Pihole-FTL" "8" "pihole-FTL" "Pi-hole" "June 2018"
+.SH "NAME"
+pihole-FTL - Pi-hole : The Faster-Than-Light (FTL) Engine
+.br
+.SH "SYNOPSIS"
+\fBservice pihole-FTL \fR(\fBstart\fR|\fBstop\fR|\fBrestart\fR)
+.br
+
+\fBpihole-FTL debug\fR
+.br
+\fBpihole-FTL test\fR
+.br
+\fBpihole-FTL -v\fR
+.br
+\fBpihole-FTL -t\fR
+.br
+\fBpihole-FTL -b\fR
+.br
+\fBpihole-FTL -f\fR
+.br
+\fBpihole-FTL -h\fR
+.br
+\fBpihole-FTL dnsmasq-test\fR
+.br
+\fBpihole-FTL --\fR (\fBoptions\fR)
+.br
+
+.SH "DESCRIPTION"
+Pi-hole : The Faster-Than-Light (FTL) Engine is a lightweight, purpose-built daemon used to provide statistics needed for the Pi-hole Web Interface, and its API can be easily integrated into your own projects. Although it is an optional component of the Pi-hole ecosystem, it will be installed by default to provide statistics. As the name implies, FTL does its work \fIvery\fR \fIquickly\fR!
+.br
+
+Usage
+.br
+
+\fBservice pihole-FTL start\fR
+.br
+ Start the pihole-FTL daemon
+.br
+
+\fBservice pihole-FTL stop\fR
+.br
+ Stop the pihole-FTL daemon
+.br
+
+\fBservice pihole-FTL restart\fR
+.br
+ If the pihole-FTP daemon is running, stop and then start, otherwise start.
+.br
+
+Command line arguments
+.br
+
+\fBdebug\fR
+.br
+ Don't go into daemon mode (stay in foreground) + more verbose logging
+.br
+
+\fBtest\fR
+.br
+ Start FTL and process everything, but shut down immediately afterwards
+.br
+
+\fB-v, version\fR
+.br
+ Don't start FTL, show only version
+.br
+
+\fB-t, tag\fR
+.br
+ Don't start FTL, show only git tag
+.br
+
+\fB-b, branch\fR
+.br
+ Don't start FTL, show only git branch FTL was compiled from
+.br
+
+\fB-f, no-daemon\fR
+.br
+ Don't go into background (daemon mode)
+.br
+
+\fB-h, help\fR
+.br
+ Don't start FTL, show help
+.br
+
+\fBdnsmasq-test\fR
+.br
+ Test resolver config file syntax
+.br
+
+\fB--\fR (options)
+.br
+ Pass options to internal dnsmasq resolver
+.br
+.SH "EXAMPLE"
+Command line arguments can be arbitrarily combined, e.g:
+.br
+
+\fBpihole-FTL debug test\fR
+.br
+
+Start ftl in foreground with more verbose logging, process everything and shutdown immediately
+.br
+.SH "SEE ALSO"
+\fBpihole\fR(8), \fBpihole-FTL.conf\fR(5)
+.br
+.SH "COLOPHON"
+
+Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net
+.br
diff --git a/manpages/pihole-FTL.conf.5 b/manpages/pihole-FTL.conf.5
new file mode 100644
index 00000000..50536279
--- /dev/null
+++ b/manpages/pihole-FTL.conf.5
@@ -0,0 +1,102 @@
+.TH "pihole-FTL.conf" "5" "pihole-FTL.conf" "pihole-FTL.conf" "June 2018"
+.SH "NAME"
+
+pihole-FTL.conf - FTL's config file
+.br
+.SH "DESCRIPTION"
+
+/etc/pihole/pihole-FTL.conf will be read by \fBpihole-FTL(8)\fR on startup.
+.br
+
+\fBSOCKET_LISTENING=localonly|all\fR
+.br
+ Listen only for local socket connections or permit all connections
+.br
+
+\fBQUERY_DISPLAY=yes|no\fR
+.br
+ Display all queries? Set to no to hide query display
+.br
+
+\fBAAAA_QUERY_ANALYSIS=yes|no\fR
+.br
+ Allow FTL to analyze AAAA queries from pihole.log?
+.br
+
+\fBRESOLVE_IPV6=yes|no\fR
+.br
+ Should FTL try to resolve IPv6 addresses to host names?
+.br
+
+\fBRESOLVE_IPV4=yes|no\fR
+.br
+ Should FTL try to resolve IPv4 addresses to host names?
+.br
+
+\fBMAXDBDAYS=365\fR
+.br
+ How long should queries be stored in the database?
+.br
+ Setting this to 0 disables the database
+.br
+
+\fBDBINTERVAL=1.0\fR
+.br
+ How often do we store queries in FTL's database [minutes]?
+.br
+
+\fBDBFILE=/etc/pihole/pihole-FTL.db\fR
+.br
+ Specify path and filename of FTL's SQLite long-term database.
+.br
+ Setting this to DBFILE= disables the database altogether
+.br
+
+\fBMAXLOGAGE=24.0\fR
+.br
+ Up to how many hours of queries should be imported from the database and logs?
+.br
+ Maximum is 744 (31 days)
+.br
+
+\fBFTLPORT=4711\fR
+.br
+ On which port should FTL be listening?
+.br
+
+\fBPRIVACYLEVEL=0|1|2|3\fR
+.br
+ Which privacy level is used?
+.br
+ 0 - show everything
+.br
+ 1 - hide domains
+.br
+ 2 - hide domains and clients
+.br
+ 3 - paranoia mode (hide everything)
+.br
+
+\fBIGNORE_LOCALHOST=no|yes\fR
+.br
+ Should FTL ignore queries coming from the local machine?
+.br
+
+\fBBLOCKINGMODE=IP|IP-AAAA-NODATA|NXDOMAIN|NULL\fR
+.br
+ How should FTL reply to blocked queries?
+.br
+
+For each setting, the option shown first is the default.
+.br
+.SH "SEE ALSO"
+
+\fBpihole\fR(8), \fBpihole-FTL\fR(8)
+.br
+.SH "COLOPHON"
+
+Pi-hole : The Faster-Than-Light (FTL) Engine is a lightweight, purpose-built daemon used to provide statistics needed for the Pi-hole Web Interface, and its API can be easily integrated into your own projects. Although it is an optional component of the Pi-hole ecosystem, it will be installed by default to provide statistics. As the name implies, FTL does its work \fIvery quickly\fR!
+.br
+
+Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net
+.br
diff --git a/manpages/pihole.8 b/manpages/pihole.8
new file mode 100644
index 00000000..54bf4a31
--- /dev/null
+++ b/manpages/pihole.8
@@ -0,0 +1,321 @@
+.TH "Pi-hole" "8" "Pi-hole" "Pi-hole" "May 2018"
+.SH "NAME"
+
+Pi-hole : A black-hole for internet advertisements
+.br
+.SH "SYNOPSIS"
+
+\fBpihole\fR (\fB-w\fR|\fB-b\fR|\fB-wild\fR) [options] domain(s)
+.br
+\fBpihole -a\fR \fB-p\fR password
+.br
+\fBpihole -a\fR (\fB-c|-f|-k\fR)
+.br
+\fBpihole -a\fR [\fB-r\fR hostrecord]
+.br
+\fBpihole -a -e\fR email
+.br
+\fBpihole -a -i\fR interface
+.br
+\fBpihole -a -l\fR privacylevel
+.br
+\fBpihole -c\fR [-j|-r|-e]
+.br
+\fBpihole\fR \fB-d\fR [-a]
+.br
+\fBpihole -f
+.br
+pihole -r
+.br
+pihole -t
+.br
+pihole -g\fR
+.br
+\fBpihole\fR -\fBq\fR [options]
+.br
+\fBpihole\fR \fB-l\fR (\fBon|off|off noflush\fR)
+.br
+\fBpihole -up \fR[--checkonly]
+.br
+\fBpihole -v\fR [-p|-a|-f] [-c|-l|-hash]
+.br
+\fBpihole uninstall
+.br
+pihole status
+.br
+pihole restartdns\fR
+.br
+\fBpihole\fR (\fBenable\fR|\fBdisable\fR [time])
+.br
+\fBpihole\fR \fBcheckout\fR repo [branch]
+.br
+\fBpihole\fR \fBhelp\fR
+.br
+.SH "DESCRIPTION"
+
+Available commands and options:
+.br
+
+\fB-w, whitelist\fR [options] [