Initial overhaul of uninstall script sourcing distro_check() from basic-install.sh Totally untested as yet...

Signed-off-by: Adam Warner <adamw@rner.email>
This commit is contained in:
Adam Warner 2017-08-17 19:53:43 +01:00
parent d45695a088
commit 95e3a5944d
No known key found for this signature in database
GPG key ID: 03843F6C65554B22

View file

@ -36,6 +36,24 @@ else
fi fi
fi fi
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
# setupVars set in basic-install.sh
source "${setupVars}"
# distro_check() sourced from basic-install.sh
distro_check
# Install packages used by the Pi-hole
if [[ "${INSTALL_WEB}" == true ]]; then
# Install the Web dependencies
DEPS=("${PIHOLE_DEPS[@]}" "${PIHOLE_WEB_DEPS[@]}")
# Otherwise,
else
# just install the Core dependencies
DEPS=("${PIHOLE_DEPS[@]}")
fi
# Compatability # Compatability
if [ -x "$(command -v rpm)" ]; then if [ -x "$(command -v rpm)" ]; then
# Fedora Family # Fedora Family
@ -45,7 +63,6 @@ if [ -x "$(command -v rpm)" ]; then
PKG_MANAGER="yum" PKG_MANAGER="yum"
fi fi
PKG_REMOVE="${PKG_MANAGER} remove -y" PKG_REMOVE="${PKG_MANAGER} remove -y"
PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common git curl unzip wget findutils )
package_check() { package_check() {
rpm -qa | grep ^$1- > /dev/null rpm -qa | grep ^$1- > /dev/null
} }
@ -56,7 +73,6 @@ elif [ -x "$(command -v apt-get)" ]; then
# Debian Family # Debian Family
PKG_MANAGER="apt-get" PKG_MANAGER="apt-get"
PKG_REMOVE="${PKG_MANAGER} -y remove --purge" PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common git curl unzip wget )
package_check() { package_check() {
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
} }
@ -72,7 +88,7 @@ fi
removeAndPurge() { removeAndPurge() {
# Purge dependencies # Purge dependencies
echo "" echo ""
for i in "${PIHOLE_DEPS[@]}"; do for i in "${DEPS[@]}"; do
package_check ${i} > /dev/null package_check ${i} > /dev/null
if [[ "$?" -eq 0 ]]; then if [[ "$?" -eq 0 ]]; then
while true; do while true; do
@ -94,12 +110,12 @@ removeAndPurge() {
# Remove dnsmasq config files # Remove dnsmasq config files
${SUDO} rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null ${SUDO} rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
echo -e " ${TICK} Removing dnsmasq config files" echo -e " ${TICK} Removing dnsmasq config files"
# Take care of any additional package cleaning # Take care of any additional package cleaning
echo -ne " ${INFO} Removing & cleaning remaining dependencies..." echo -ne " ${INFO} Removing & cleaning remaining dependencies..."
package_cleanup &> /dev/null package_cleanup &> /dev/null
echo -e "${OVER} ${TICK} Removed & cleaned up remaining dependencies" echo -e "${OVER} ${TICK} Removed & cleaned up remaining dependencies"
# Call removeNoPurge to remove Pi-hole specific files # Call removeNoPurge to remove Pi-hole specific files
removeNoPurge removeNoPurge
} }
@ -145,7 +161,7 @@ removeNoPurge() {
${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf ${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
fi fi
fi fi
${SUDO} rm /etc/dnsmasq.d/adList.conf &> /dev/null ${SUDO} rm /etc/dnsmasq.d/adList.conf &> /dev/null
${SUDO} rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null ${SUDO} rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null
${SUDO} rm -rf /var/log/*pihole* &> /dev/null ${SUDO} rm -rf /var/log/*pihole* &> /dev/null
@ -156,23 +172,23 @@ removeNoPurge() {
${SUDO} rm /etc/bash_completion.d/pihole &> /dev/null ${SUDO} rm /etc/bash_completion.d/pihole &> /dev/null
${SUDO} rm /etc/sudoers.d/pihole &> /dev/null ${SUDO} rm /etc/sudoers.d/pihole &> /dev/null
echo -e " ${TICK} Removed config files" echo -e " ${TICK} Removed config files"
# Remove FTL # Remove FTL
if command -v pihole-FTL &> /dev/null; then if command -v pihole-FTL &> /dev/null; then
echo -ne " ${INFO} Removing pihole-FTL..." echo -ne " ${INFO} Removing pihole-FTL..."
if [[ -x "$(command -v systemctl)" ]]; then if [[ -x "$(command -v systemctl)" ]]; then
systemctl stop pihole-FTL systemctl stop pihole-FTL
else else
service pihole-FTL stop service pihole-FTL stop
fi fi
${SUDO} rm /etc/init.d/pihole-FTL ${SUDO} rm /etc/init.d/pihole-FTL
${SUDO} rm /usr/bin/pihole-FTL ${SUDO} rm /usr/bin/pihole-FTL
echo -e "${OVER} ${TICK} Removed pihole-FTL" echo -e "${OVER} ${TICK} Removed pihole-FTL"
fi fi
# If the pihole user exists, then remove # If the pihole user exists, then remove
if id "pihole" &> /dev/null; then if id "pihole" &> /dev/null; then
${SUDO} userdel -r pihole 2> /dev/null ${SUDO} userdel -r pihole 2> /dev/null