From 5442954db6cd63a81eddc3e66d5cd48179102d52 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 27 Mar 2016 01:53:48 -0500 Subject: [PATCH] Prompt user to remove each dependent package if they do choose to remove packages at all. --- automated install/basic-install.sh | 11 +++++-- automated install/uninstall.sh | 51 +++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d3ba437f..7833c7e4 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -75,9 +75,9 @@ fi spinner() { local pid=$1 - local delay=0.75 + local delay=0.50 local spinstr='|/-\' - while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do + while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do local temp=${spinstr#?} printf " [%c] " "$spinstr" local spinstr=$temp${spinstr%"$temp"} @@ -486,6 +486,10 @@ installConfigs() { $SUDO echo ":::" $SUDO echo "::: Installing configs..." versionCheckDNSmasq + if [ ! -d "/etc/lighttpd" ]; then + $SUDO mkdir /etc/lighttpd + $SUDO chown "$USER":root /etc/lighttpds + fi $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig $SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf } @@ -664,6 +668,9 @@ installPihole() { stopServices setUser $SUDO mkdir -p /etc/pihole/ + if [ ! -d "/var/www/html" ]; then + $SUDO mkdir /var/www/html + fi $SUDO chown www-data:www-data /var/www/html $SUDO chmod 775 /var/www/html $SUDO usermod -a -G www-data pihole diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 9c47ce44..8467256f 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -14,7 +14,7 @@ if [[ $EUID -eq 0 ]];then echo "You are root." else - echo "sudo will be used for the install." + echo "sudo will be used for the uninstall." # Check if it is actually installed # If it isn't, exit because the unnstall cannot complete if [[ $(dpkg-query -s sudo) ]];then @@ -27,15 +27,49 @@ fi function removeAndPurge { # Purge dependencies - echo "Purging dependencies!" - $SUDO apt-get -y remove --purge dnsutils bc toilet - $SUDO apt-get -y remove --purge dnsmasq - $SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5 + read -p "Do you wish to purge dnsutils?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge dnsutils + fi + + read -p "Do you wish to purge bc?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge bc + fi + + read -p "Do you wish to purge toilet?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge toilet + fi + + read -p "Do you wish to purge dnsmasq?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge dnsmasq + fi + + read -p "Do you wish to purge lighttpd?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge lighttpd + fi + + read -p "Do you wish to purge php5?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge php5-common php5-cgi php5 + fi # Remove dependency config files echo "Removing dnsmasq config files..." $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null + # Take care of any additional package cleaning + $SUDO apt-get -y autoremove + # Call removeNoPurge to remove PiHole specific files removeNoPurge } @@ -86,13 +120,14 @@ function removeNoPurge { } ######### SCRIPT ########### -echo "WARNING: This is destructive if run on any non-Debian based OS" -echo "(SAFE TO RUN ON RASPBIAN)" +echo "Preparing to remove packages, be sure that each may be safely removed depending on your operating system." +echo "(SAFE TO REMOVE ALL ON RASPBIAN)" while true; do - read -p "Do you wish to purge PiHole's dependencies from your OS?" yn + read -rp "Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package)" yn case $yn in [Yy]* ) removeAndPurge; break;; [Nn]* ) removeNoPurge; break;; esac done +