From 32dd594f06ecb3ca24a7881eeb8e890bcafedf9c Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 17:08:19 -0500 Subject: [PATCH] Check if lighttpd has been uninstalled before removing conf files If is still installed, then restore the original lighttpd.conf file. --- automated install/uninstall.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index cef36dd6..786e8cea 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -107,8 +107,13 @@ function removeNoPurge { fi echo "::: Removing config files and scripts..." - $SUDO rm -rf /etc/lighttpd/ &> /dev/null - $SUDO rm /var/log/pihole.log &> /dev/null + if [ ! "$(dpkg-query -W --showformat='${Status}\n' lighttpd 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then + $SUDO rm -rf /etc/lighttpd/ &> /dev/null + else + if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then + $SUDO mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf + fi + fi $SUDO rm /usr/local/bin/gravity.sh &> /dev/null $SUDO rm /usr/local/bin/chronometer.sh &> /dev/null $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null