1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 14:58:08 +00:00

Changes from #2167 converted to spaces

Signed-Off-By: Rob Gill <rrobgill@protonmail.com>
This commit is contained in:
Rob Gill 2018-05-31 13:37:52 +10:00 committed by GitHub
parent 552138e851
commit f2bedddce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,24 +53,17 @@ if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
fi fi
# Compatability # Compatability
if [ -x "$(command -v rpm)" ]; then if [ -x "$(command -v apt-get)" ]; 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 # 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() { elif [ -x "$(command -v rpm)" ]; then
"${SUDO}" "${PKG_MANAGER}" -y autoremove # Fedora Family
"${SUDO}" "${PKG_MANAGER}" -y autoclean PKG_REMOVE="${PKG_MANAGER} remove -y"
package_check() {
rpm -qa | grep "^$1-" > /dev/null
} }
else else
echo -e " ${CROSS} OS distribution not supported" echo -e " ${CROSS} OS distribution not supported"
@ -81,13 +74,14 @@ removeAndPurge() {
# Purge dependencies # Purge dependencies
echo "" echo ""
for i in "${DEPS[@]}"; do for i in "${DEPS[@]}"; do
if package_check "${i}" > /dev/null; then package_check ${i} > /dev/null
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;;
@ -95,18 +89,13 @@ removeAndPurge() {
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/*-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
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 # Call removeNoPurge to remove Pi-hole specific files
removeNoPurge removeNoPurge
} }