Merge pull request #2808 from pi-hole/fix/uninstall

Fix uninstall causing 403 errors and not removing packages
This commit is contained in:
Mark Drobnak 2019-06-27 12:51:07 -04:00 committed by GitHub
commit 092957c14a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,13 +55,13 @@ fi
# Compatability # Compatability
if [ -x "$(command -v apt-get)" ]; then if [ -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"
} }
elif [ -x "$(command -v rpm)" ]; then elif [ -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
} }
@ -80,7 +80,7 @@ removeAndPurge() {
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;;
@ -132,12 +132,15 @@ removeNoPurge() {
fi fi
if package_check lighttpd > /dev/null; then if package_check lighttpd > /dev/null; then
${SUDO} rm -rf /etc/lighttpd/ &> /dev/null if [[ -f /etc/lighttpd/lighttpd.conf.orig ]]; then
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 ${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
fi fi
if [[ -f /etc/lighttpd/external.conf ]]; then
${SUDO} rm /etc/lighttpd/external.conf
fi
echo -e " ${TICK} Removed lighttpd configs"
fi fi
${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null ${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null