mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 23:08:07 +00:00
Loop through dependencies for future expansion.
Syntax of uninstall script now matches basic-install.sh. More error handling of missing default files. Force user prompt for removing packages when uninstalling.
This commit is contained in:
parent
2b5cee05e6
commit
8c45bd32b7
@ -489,8 +489,8 @@ installConfigs() {
|
|||||||
if [ ! -d "/etc/lighttpd" ]; then
|
if [ ! -d "/etc/lighttpd" ]; then
|
||||||
$SUDO mkdir /etc/lighttpd
|
$SUDO mkdir /etc/lighttpd
|
||||||
$SUDO chown "$USER":root /etc/lighttpd
|
$SUDO chown "$USER":root /etc/lighttpd
|
||||||
|
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
||||||
fi
|
fi
|
||||||
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
|
||||||
$SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf
|
$SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,9 +622,13 @@ installPiholeWeb() {
|
|||||||
$SUDO echo " Existing page detected, not overwriting"
|
$SUDO echo " Existing page detected, not overwriting"
|
||||||
else
|
else
|
||||||
$SUDO mkdir /var/www/html/pihole
|
$SUDO mkdir /var/www/html/pihole
|
||||||
$SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
if [ -f /var/www/html/index.lighttpd.html ]; then
|
||||||
|
$SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
||||||
|
else
|
||||||
|
printf "\n:::\tNo default index.lighttpd.html file found... not backing up"
|
||||||
|
fi
|
||||||
$SUDO cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html
|
$SUDO cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html
|
||||||
$SUDO echo " done!"
|
$SUDO echo "::: done!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,7 +650,6 @@ runGravity() {
|
|||||||
fi
|
fi
|
||||||
#Don't run as SUDO, this was causing issues
|
#Don't run as SUDO, this was causing issues
|
||||||
echo "::: Running gravity.sh"
|
echo "::: Running gravity.sh"
|
||||||
echo ":::"
|
|
||||||
|
|
||||||
/usr/local/bin/gravity.sh
|
/usr/local/bin/gravity.sh
|
||||||
}
|
}
|
||||||
|
@ -12,71 +12,71 @@
|
|||||||
|
|
||||||
# Must be root to uninstall
|
# Must be root to uninstall
|
||||||
if [[ $EUID -eq 0 ]];then
|
if [[ $EUID -eq 0 ]];then
|
||||||
echo "You are root."
|
echo "::: You are root."
|
||||||
else
|
else
|
||||||
echo "sudo will be used for the uninstall."
|
echo "::: Sudo will be used for the uninstall."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the unnstall cannot complete
|
# If it isn't, exit because the unnstall cannot complete
|
||||||
if [[ $(dpkg-query -s sudo) ]];then
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "Please install sudo or run this as root."
|
echo "::: Please install sudo or run this as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
spinner()
|
||||||
|
{
|
||||||
|
local pid=$1
|
||||||
|
local delay=0.50
|
||||||
|
local spinstr='|/-\'
|
||||||
|
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
|
||||||
|
local temp=${spinstr#?}
|
||||||
|
printf " [%c] " "$spinstr"
|
||||||
|
local spinstr=$temp${spinstr%"$temp"}
|
||||||
|
sleep $delay
|
||||||
|
printf "\b\b\b\b\b\b"
|
||||||
|
done
|
||||||
|
printf " \b\b\b\b"
|
||||||
|
}
|
||||||
|
|
||||||
function removeAndPurge {
|
function removeAndPurge {
|
||||||
# Purge dependencies
|
# Purge dependencies
|
||||||
read -p "Do you wish to purge dnsutils?" -n 1 -r
|
echo ":::"
|
||||||
echo
|
dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget )
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
for i in "${dependencies[@]}"; do
|
||||||
$SUDO apt-get -y remove --purge dnsutils
|
if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" | grep -c "ok installed")" -eq 1 ]; then
|
||||||
fi
|
while true; do
|
||||||
|
read -rp "::: Do you wish to remove $i from your system? (y/n): " yn
|
||||||
read -p "Do you wish to purge bc?" -n 1 -r
|
case $yn in
|
||||||
echo
|
[Yy]* ) echo "::: Removing $i..."; $SUDO apt-get -y remove --purge "$i" > /dev/null & spinner $!; echo "DONE!"; break;;
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
[Nn]* ) echo "::: Skipping $i"; break;;
|
||||||
$SUDO apt-get -y remove --purge bc
|
* ) echo "::: You must answer yes or no!";;
|
||||||
fi
|
esac
|
||||||
|
done
|
||||||
read -p "Do you wish to purge toilet?" -n 1 -r
|
else
|
||||||
echo
|
echo "IF FAILED ***"
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
fi
|
||||||
$SUDO apt-get -y remove --purge toilet
|
done
|
||||||
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
|
# Remove dependency config files
|
||||||
echo "Removing dnsmasq config files..."
|
echo "::: Removing dnsmasq config files..."
|
||||||
$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
||||||
|
|
||||||
# Take care of any additional package cleaning
|
# Take care of any additional package cleaning
|
||||||
$SUDO apt-get -y autoremove
|
echo "::: Auto removing remaining dependencies"
|
||||||
|
$SUDO apt-get -y autoremove &> /dev/null & spinner $!; echo "DONE!";
|
||||||
|
echo "::: Auto cleaning remaining dependencies"
|
||||||
|
$SUDO apt-get -y autoclean &> /dev/null & spinner $!; echo "DONE!";
|
||||||
|
|
||||||
# Call removeNoPurge to remove PiHole specific files
|
# Call removeNoPurge to remove PiHole specific files
|
||||||
removeNoPurge
|
removeNoPurge
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeNoPurge {
|
function removeNoPurge {
|
||||||
|
echo ":::"
|
||||||
# Only web directories/files that are created by pihole should be removed.
|
# Only web directories/files that are created by pihole should be removed.
|
||||||
echo "Removing the Pi-hole Web server files..."
|
echo "::: Removing the Pi-hole Web server files..."
|
||||||
$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 /var/www/html/index.lighttpd.orig &> /dev/null
|
$SUDO rm /var/www/html/index.lighttpd.orig &> /dev/null
|
||||||
@ -93,7 +93,7 @@ function removeNoPurge {
|
|||||||
# 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
|
||||||
echo "Initial Pi-hole cron detected. Restoring the default system cron..."
|
echo "::: Initial Pi-hole cron detected. Restoring the default system cron..."
|
||||||
$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
|
||||||
@ -101,11 +101,11 @@ function removeNoPurge {
|
|||||||
|
|
||||||
# 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
|
||||||
echo "Removing cron.d/pihole..."
|
echo "::: Removing cron.d/pihole..."
|
||||||
$SUDO rm /etc/cron.d/pihole &> /dev/null
|
$SUDO rm /etc/cron.d/pihole &> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Removing config files and scripts..."
|
echo "::: Removing config files and scripts..."
|
||||||
$SUDO rm -rf /etc/lighttpd/ &> /dev/null
|
$SUDO rm -rf /etc/lighttpd/ &> /dev/null
|
||||||
$SUDO rm /var/log/pihole.log &> /dev/null
|
$SUDO rm /var/log/pihole.log &> /dev/null
|
||||||
$SUDO rm /usr/local/bin/gravity.sh &> /dev/null
|
$SUDO rm /usr/local/bin/gravity.sh &> /dev/null
|
||||||
@ -116,14 +116,18 @@ function removeNoPurge {
|
|||||||
$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
|
||||||
|
|
||||||
|
echo ":::"
|
||||||
|
printf "::: Finished removing PiHole from your system. Sorry to see you go!\n"
|
||||||
|
printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n"
|
||||||
|
printf "::: Reinstall by simpling running\n:::\n:::\tcurl -L install.pi-hole.net | bash\n:::\n::: at any time!\n:::\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
######### SCRIPT ###########
|
######### SCRIPT ###########
|
||||||
echo "Preparing to remove packages, be sure that each may be safely removed depending on your operating system."
|
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)"
|
echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)"
|
||||||
while true; do
|
while true; do
|
||||||
read -rp "Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package)" 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
|
case $yn in
|
||||||
[Yy]* ) removeAndPurge; break;;
|
[Yy]* ) removeAndPurge; break;;
|
||||||
|
|
||||||
@ -131,3 +135,4 @@ while true; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user