mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Style/Tabs to spaces
uninstall.sh contains a mix of tabs and spaces for indentation in different parts of the file. Everywhere that used tabs has been converted to spaces, compatible with the indentation style used in basic_install.sh No code has been altered, only the use of tabs and spaces in indention. Signed-off-by: Rob Gill <rrobgill@protonmail.com>
This commit is contained in:
parent
b1ab7f46e0
commit
1911c3690d
1 changed files with 104 additions and 104 deletions
|
@ -11,29 +11,29 @@
|
||||||
source "/opt/pihole/COL_TABLE"
|
source "/opt/pihole/COL_TABLE"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " yn
|
read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " yn
|
||||||
case ${yn} in
|
case ${yn} in
|
||||||
[Yy]* ) break;;
|
[Yy]* ) break;;
|
||||||
[Nn]* ) echo -e "\n ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;;
|
[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;;
|
* ) echo -e "\n ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Must be root to uninstall
|
# Must be root to uninstall
|
||||||
str="Root user check"
|
str="Root user check"
|
||||||
if [[ ${EUID} -eq 0 ]]; then
|
if [[ ${EUID} -eq 0 ]]; then
|
||||||
echo -e " ${TICK} ${str}"
|
echo -e " ${TICK} ${str}"
|
||||||
else
|
else
|
||||||
# Check if sudo is actually installed
|
# Check if sudo is actually installed
|
||||||
# If it isn't, exit because the uninstall can not complete
|
# If it isn't, exit because the uninstall can not complete
|
||||||
if [ -x "$(command -v sudo)" ]; then
|
if [ -x "$(command -v sudo)" ]; then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} ${str}
|
echo -e " ${CROSS} ${str}
|
||||||
Script called with non-root privileges
|
Script called with non-root privileges
|
||||||
The Pi-hole requires elevated privleges to uninstall"
|
The Pi-hole requires elevated privleges to uninstall"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
||||||
|
@ -54,115 +54,115 @@ fi
|
||||||
|
|
||||||
# Compatability
|
# Compatability
|
||||||
if [ -x "$(command -v rpm)" ]; then
|
if [ -x "$(command -v rpm)" ]; then
|
||||||
# Fedora Family
|
# Fedora Family
|
||||||
PKG_REMOVE="${PKG_MANAGER} remove -y"
|
PKG_REMOVE="${PKG_MANAGER} remove -y"
|
||||||
package_check() {
|
package_check() {
|
||||||
rpm -qa | grep ^$1- > /dev/null
|
rpm -qa | grep ^$1- > /dev/null
|
||||||
}
|
}
|
||||||
package_cleanup() {
|
package_cleanup() {
|
||||||
${SUDO} ${PKG_MANAGER} -y autoremove
|
${SUDO} ${PKG_MANAGER} -y autoremove
|
||||||
}
|
}
|
||||||
elif [ -x "$(command -v apt-get)" ]; then
|
elif [ -x "$(command -v apt-get)" ]; then
|
||||||
# Debian Family
|
# Debian Family
|
||||||
PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
|
PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
|
||||||
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"
|
||||||
}
|
}
|
||||||
package_cleanup() {
|
package_cleanup() {
|
||||||
${SUDO} ${PKG_MANAGER} -y autoremove
|
${SUDO} ${PKG_MANAGER} -y autoremove
|
||||||
${SUDO} ${PKG_MANAGER} -y autoclean
|
${SUDO} ${PKG_MANAGER} -y autoclean
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} OS distribution not supported"
|
echo -e " ${CROSS} OS distribution not supported"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
removeAndPurge() {
|
removeAndPurge() {
|
||||||
# Purge dependencies
|
# Purge dependencies
|
||||||
echo ""
|
echo ""
|
||||||
for i in "${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
|
||||||
read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn
|
read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn
|
||||||
case ${yn} in
|
case ${yn} in
|
||||||
[Yy]* )
|
[Yy]* )
|
||||||
echo -ne " ${INFO} Removing ${i}...";
|
echo -ne " ${INFO} Removing ${i}...";
|
||||||
${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null;
|
${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null;
|
||||||
echo -e "${OVER} ${INFO} Removed ${i}";
|
echo -e "${OVER} ${INFO} Removed ${i}";
|
||||||
break;;
|
break;;
|
||||||
[Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;;
|
[Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo -e " ${INFO} Package ${i} not installed"
|
echo -e " ${INFO} Package ${i} not installed"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove dnsmasq config files
|
# Remove dnsmasq config files
|
||||||
${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
${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"
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
removeNoPurge() {
|
removeNoPurge() {
|
||||||
# Only web directories/files that are created by Pi-hole should be removed
|
# Only web directories/files that are created by Pi-hole should be removed
|
||||||
echo -ne " ${INFO} Removing Web Interface..."
|
echo -ne " ${INFO} Removing Web Interface..."
|
||||||
${SUDO} rm -rf /var/www/html/admin &> /dev/null
|
${SUDO} rm -rf /var/www/html/admin &> /dev/null
|
||||||
${SUDO} rm -rf /var/www/html/pihole &> /dev/null
|
${SUDO} rm -rf /var/www/html/pihole &> /dev/null
|
||||||
${SUDO} rm -f /var/www/html/index.lighttpd.orig &> /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 the web directory is empty after removing these files, then the parent html folder can be removed.
|
||||||
if [ -d "/var/www/html" ]; then
|
if [ -d "/var/www/html" ]; then
|
||||||
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
||||||
${SUDO} rm -rf /var/www/html &> /dev/null
|
${SUDO} rm -rf /var/www/html &> /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo -e "${OVER} ${TICK} Removed Web Interface"
|
echo -e "${OVER} ${TICK} Removed Web Interface"
|
||||||
|
|
||||||
# Attempt to preserve backwards compatibility with older versions
|
# Attempt to preserve backwards compatibility with older versions
|
||||||
# to guarantee no additional changes were made to /etc/crontab after
|
# to guarantee no additional changes were made to /etc/crontab after
|
||||||
# the installation of pihole, /etc/crontab.pihole should be permanently
|
# the installation of pihole, /etc/crontab.pihole should be permanently
|
||||||
# preserved.
|
# preserved.
|
||||||
if [[ -f /etc/crontab.orig ]]; then
|
if [[ -f /etc/crontab.orig ]]; then
|
||||||
${SUDO} mv /etc/crontab /etc/crontab.pihole
|
${SUDO} mv /etc/crontab /etc/crontab.pihole
|
||||||
${SUDO} mv /etc/crontab.orig /etc/crontab
|
${SUDO} mv /etc/crontab.orig /etc/crontab
|
||||||
${SUDO} service cron restart
|
${SUDO} service cron restart
|
||||||
echo -e " ${TICK} Restored the default system cron"
|
echo -e " ${TICK} Restored the default system cron"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Attempt to preserve backwards compatibility with older versions
|
# Attempt to preserve backwards compatibility with older versions
|
||||||
if [[ -f /etc/cron.d/pihole ]];then
|
if [[ -f /etc/cron.d/pihole ]];then
|
||||||
${SUDO} rm -f /etc/cron.d/pihole &> /dev/null
|
${SUDO} rm -f /etc/cron.d/pihole &> /dev/null
|
||||||
echo -e " ${TICK} Removed /etc/cron.d/pihole"
|
echo -e " ${TICK} Removed /etc/cron.d/pihole"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
package_check lighttpd > /dev/null
|
package_check lighttpd > /dev/null
|
||||||
if [[ $? -eq 1 ]]; then
|
if [[ $? -eq 1 ]]; then
|
||||||
${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
|
${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
|
||||||
echo -e " ${TICK} Removed lighttpd"
|
echo -e " ${TICK} Removed lighttpd"
|
||||||
else
|
else
|
||||||
if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
|
if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
|
||||||
${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 -f /etc/dnsmasq.d/adList.conf &> /dev/null
|
${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null
|
||||||
${SUDO} rm -f /etc/dnsmasq.d/01-pihole.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 /var/log/*pihole* &> /dev/null
|
||||||
${SUDO} rm -rf /etc/pihole/ &> /dev/null
|
${SUDO} rm -rf /etc/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 -rf /opt/pihole/ &> /dev/null
|
||||||
${SUDO} rm -f /usr/local/bin/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/bash_completion.d/pihole &> /dev/null
|
||||||
${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null
|
${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null
|
||||||
echo -e " ${TICK} Removed config files"
|
echo -e " ${TICK} Removed config files"
|
||||||
|
|
||||||
# Remove FTL
|
# Remove FTL
|
||||||
|
@ -180,15 +180,15 @@ removeNoPurge() {
|
||||||
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
|
||||||
if [[ "$?" -eq 0 ]]; then
|
if [[ "$?" -eq 0 ]]; then
|
||||||
echo -e " ${TICK} Removed 'pihole' user"
|
echo -e " ${TICK} Removed 'pihole' user"
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} Unable to remove 'pihole' user"
|
echo -e " ${CROSS} Unable to remove 'pihole' user"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\n We're sorry to see you go, but thanks for checking out Pi-hole!
|
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
|
If you need help, reach out to us on Github, Discourse, Reddit or Twitter
|
||||||
|
@ -211,10 +211,10 @@ while true; do
|
||||||
echo -n "${i} "
|
echo -n "${i} "
|
||||||
done
|
done
|
||||||
echo "${COL_NC}"
|
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
|
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
|
case ${yn} in
|
||||||
[Yy]* ) removeAndPurge; break;;
|
[Yy]* ) removeAndPurge; break;;
|
||||||
[Nn]* ) removeNoPurge; break;;
|
[Nn]* ) removeNoPurge; break;;
|
||||||
* ) removeAndPurge; break;;
|
* ) removeAndPurge; break;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue