mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-24 23:23:42 +00:00
Installer and uninstaller now rerun themselves as root using sudo at the start of the script, rather than run individual commands with sudo.
This commit is contained in:
parent
6c58ea18dc
commit
3eb6739263
2 changed files with 135 additions and 122 deletions
|
@ -16,6 +16,28 @@
|
||||||
#
|
#
|
||||||
# curl -L install.pi-hole.net | bash
|
# curl -L install.pi-hole.net | bash
|
||||||
|
|
||||||
|
######## ROOT #########
|
||||||
|
# Check if root, and if not then rerun with sudo.
|
||||||
|
echo ":::"
|
||||||
|
if [[ $EUID -eq 0 ]];then
|
||||||
|
echo "::: You are root."
|
||||||
|
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
||||||
|
# rather than rerunning as sudo. Just in case it turns up by accident,
|
||||||
|
# explicitly set the $SUDO variable to an empty string.
|
||||||
|
SUDO=""
|
||||||
|
else
|
||||||
|
echo "::: sudo will be used."
|
||||||
|
# Check if it is actually installed
|
||||||
|
# If it isn't, exit because the install cannot complete
|
||||||
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
|
echo "::: Running sudo $@"
|
||||||
|
sudo "$@"
|
||||||
|
exit $?
|
||||||
|
else
|
||||||
|
echo "::: Please install sudo or run this script as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
######## VARIABLES #########
|
######## VARIABLES #########
|
||||||
|
|
||||||
|
@ -47,22 +69,6 @@ availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -
|
||||||
dhcpcdFile=/etc/dhcpcd.conf
|
dhcpcdFile=/etc/dhcpcd.conf
|
||||||
|
|
||||||
######## FIRST CHECK ########
|
######## FIRST CHECK ########
|
||||||
# Must be root to install
|
|
||||||
echo ":::"
|
|
||||||
if [[ $EUID -eq 0 ]];then
|
|
||||||
echo "::: You are root."
|
|
||||||
else
|
|
||||||
echo "::: sudo will be used for the install."
|
|
||||||
# Check if it is actually installed
|
|
||||||
# If it isn't, exit because the install cannot complete
|
|
||||||
if [[ $(dpkg-query -s sudo) ]];then
|
|
||||||
export SUDO="sudo"
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo or run this as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ -d "/etc/pihole" ]; then
|
if [ -d "/etc/pihole" ]; then
|
||||||
# Likely an existing install
|
# Likely an existing install
|
||||||
|
@ -78,7 +84,7 @@ spinner() {
|
||||||
|
|
||||||
spin='-\|/'
|
spin='-\|/'
|
||||||
i=0
|
i=0
|
||||||
while $SUDO kill -0 $pid 2>/dev/null
|
while kill -0 $pid 2>/dev/null
|
||||||
do
|
do
|
||||||
i=$(( (i+1) %4 ))
|
i=$(( (i+1) %4 ))
|
||||||
printf "\b${spin:$i:1}"
|
printf "\b${spin:$i:1}"
|
||||||
|
@ -91,13 +97,13 @@ backupLegacyPihole() {
|
||||||
# This function detects and backups the pi-hole v1 files. It will not do anything to the current version files.
|
# This function detects and backups the pi-hole v1 files. It will not do anything to the current version files.
|
||||||
if [[ -f /etc/dnsmasq.d/adList.conf ]];then
|
if [[ -f /etc/dnsmasq.d/adList.conf ]];then
|
||||||
echo "::: Original Pi-hole detected. Initiating sub space transport"
|
echo "::: Original Pi-hole detected. Initiating sub space transport"
|
||||||
$SUDO mkdir -p /etc/pihole/original/
|
mkdir -p /etc/pihole/original/
|
||||||
$SUDO mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d")
|
mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d")
|
||||||
$SUDO mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d")
|
mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d")
|
||||||
$SUDO mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d")
|
mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d")
|
||||||
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d")
|
mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d")
|
||||||
$SUDO mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d")
|
mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d")
|
||||||
$SUDO mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d")
|
mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d")
|
||||||
else
|
else
|
||||||
:
|
:
|
||||||
fi
|
fi
|
||||||
|
@ -224,7 +230,7 @@ useIPv6dialog() {
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||||
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." $r $c
|
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." $r $c
|
||||||
|
|
||||||
$SUDO touch /etc/pihole/.useIPv6
|
touch /etc/pihole/.useIPv6
|
||||||
}
|
}
|
||||||
|
|
||||||
getStaticIPv4Settings() {
|
getStaticIPv4Settings() {
|
||||||
|
@ -287,7 +293,7 @@ setDHCPCD() {
|
||||||
echo "::: interface $piholeInterface
|
echo "::: interface $piholeInterface
|
||||||
static ip_address=$IPv4addr
|
static ip_address=$IPv4addr
|
||||||
static routers=$IPv4gw
|
static routers=$IPv4gw
|
||||||
static domain_name_servers=$IPv4gw" | $SUDO tee -a $dhcpcdFile >/dev/null
|
static domain_name_servers=$IPv4gw" | tee -a $dhcpcdFile >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
setStaticIPv4() {
|
setStaticIPv4() {
|
||||||
|
@ -297,7 +303,7 @@ setStaticIPv4() {
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
setDHCPCD
|
setDHCPCD
|
||||||
$SUDO ip addr replace dev $piholeInterface $IPv4addr
|
ip addr replace dev $piholeInterface $IPv4addr
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete."
|
echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete."
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
@ -437,66 +443,66 @@ versionCheckDNSmasq(){
|
||||||
if grep -q $dnsSearch $dnsFile1; then
|
if grep -q $dnsSearch $dnsFile1; then
|
||||||
echo " it is from a previous pi-hole install."
|
echo " it is from a previous pi-hole install."
|
||||||
echo -n "::: Backing up dnsmasq.conf to dnsmasq.conf.orig..."
|
echo -n "::: Backing up dnsmasq.conf to dnsmasq.conf.orig..."
|
||||||
$SUDO mv -f $dnsFile1 $dnsFile2
|
mv -f $dnsFile1 $dnsFile2
|
||||||
echo " done."
|
echo " done."
|
||||||
echo -n "::: Restoring default dnsmasq.conf..."
|
echo -n "::: Restoring default dnsmasq.conf..."
|
||||||
$SUDO cp $defaultFile $dnsFile1
|
cp $defaultFile $dnsFile1
|
||||||
echo " done."
|
echo " done."
|
||||||
else
|
else
|
||||||
echo " it is not a pi-hole file, leaving alone!"
|
echo " it is not a pi-hole file, leaving alone!"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -n "::: No dnsmasq.conf found.. restoring default dnsmasq.conf..."
|
echo -n "::: No dnsmasq.conf found.. restoring default dnsmasq.conf..."
|
||||||
$SUDO cp $defaultFile $dnsFile1
|
cp $defaultFile $dnsFile1
|
||||||
echo " done."
|
echo " done."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "::: Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf..."
|
echo -n "::: Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf..."
|
||||||
$SUDO cp $newFileToInstall $newFileFinalLocation
|
cp $newFileToInstall $newFileFinalLocation
|
||||||
echo " done."
|
echo " done."
|
||||||
$SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation
|
sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation
|
||||||
if [[ "$piholeDNS1" != "" ]]; then
|
if [[ "$piholeDNS1" != "" ]]; then
|
||||||
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation
|
sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation
|
||||||
else
|
else
|
||||||
$SUDO sed -i '/^server=@DNS1@/d' $newFileFinalLocation
|
sed -i '/^server=@DNS1@/d' $newFileFinalLocation
|
||||||
fi
|
fi
|
||||||
if [[ "$piholeDNS2" != "" ]]; then
|
if [[ "$piholeDNS2" != "" ]]; then
|
||||||
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation
|
sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation
|
||||||
else
|
else
|
||||||
$SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation
|
sed -i '/^server=@DNS2@/d' $newFileFinalLocation
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
installScripts() {
|
installScripts() {
|
||||||
# Install the scripts from /etc/.pihole to their various locations
|
# Install the scripts from /etc/.pihole to their various locations
|
||||||
$SUDO echo ":::"
|
echo ":::"
|
||||||
$SUDO echo -n "::: Installing scripts..."
|
echo -n "::: Installing scripts..."
|
||||||
$SUDO cp /etc/.pihole/gravity.sh /usr/local/bin/gravity.sh
|
cp /etc/.pihole/gravity.sh /usr/local/bin/gravity.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /usr/local/bin/chronometer.sh
|
cp /etc/.pihole/advanced/Scripts/chronometer.sh /usr/local/bin/chronometer.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /usr/local/bin/whitelist.sh
|
cp /etc/.pihole/advanced/Scripts/whitelist.sh /usr/local/bin/whitelist.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /usr/local/bin/blacklist.sh
|
cp /etc/.pihole/advanced/Scripts/blacklist.sh /usr/local/bin/blacklist.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /usr/local/bin/piholeLogFlush.sh
|
cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /usr/local/bin/piholeLogFlush.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /usr/local/bin/updateDashboard.sh
|
cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /usr/local/bin/updateDashboard.sh
|
||||||
$SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh
|
chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh
|
||||||
$SUDO echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
installConfigs() {
|
installConfigs() {
|
||||||
# Install the configs from /etc/.pihole to their various locations
|
# Install the configs from /etc/.pihole to their various locations
|
||||||
$SUDO echo ":::"
|
echo ":::"
|
||||||
$SUDO echo "::: Installing configs..."
|
echo "::: Installing configs..."
|
||||||
versionCheckDNSmasq
|
versionCheckDNSmasq
|
||||||
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
||||||
$SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf
|
cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
stopServices() {
|
stopServices() {
|
||||||
# Stop dnsmasq and lighttpd
|
# Stop dnsmasq and lighttpd
|
||||||
$SUDO echo ":::"
|
echo ":::"
|
||||||
$SUDO echo -n "::: Stopping services..."
|
echo -n "::: Stopping services..."
|
||||||
#$SUDO service dnsmasq stop & spinner $! || true
|
#service dnsmasq stop & spinner $! || true
|
||||||
$SUDO service lighttpd stop & spinner $! || true
|
service lighttpd stop & spinner $! || true
|
||||||
$SUDO echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForDependencies() {
|
checkForDependencies() {
|
||||||
|
@ -516,12 +522,12 @@ checkForDependencies() {
|
||||||
#update package lists
|
#update package lists
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: apt-get update has not been run today. Running now..."
|
echo -n "::: apt-get update has not been run today. Running now..."
|
||||||
$SUDO apt-get -qq update & spinner $!
|
apt-get -qq update & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Checking apt-get for upgraded packages...."
|
echo -n "::: Checking apt-get for upgraded packages...."
|
||||||
updatesToInstall=$($SUDO apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
|
updatesToInstall=$(apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
|
||||||
echo " done!"
|
echo " done!"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
if [[ $updatesToInstall -eq "0" ]]; then
|
if [[ $updatesToInstall -eq "0" ]]; then
|
||||||
|
@ -541,7 +547,7 @@ checkForDependencies() {
|
||||||
echo -n "::: Checking for $i..."
|
echo -n "::: Checking for $i..."
|
||||||
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
||||||
echo -n " Not found! Installing...."
|
echo -n " Not found! Installing...."
|
||||||
$SUDO apt-get -y -qq install $i > /dev/null & spinner $!
|
apt-get -y -qq install $i > /dev/null & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
echo " already installed!"
|
echo " already installed!"
|
||||||
|
@ -582,8 +588,8 @@ is_repo() {
|
||||||
make_repo() {
|
make_repo() {
|
||||||
# Remove the non-repod interface and clone the interface
|
# Remove the non-repod interface and clone the interface
|
||||||
echo -n "::: Cloning $2 into $1..."
|
echo -n "::: Cloning $2 into $1..."
|
||||||
$SUDO rm -rf $1
|
rm -rf $1
|
||||||
$SUDO git clone -q "$2" "$1" > /dev/null & spinner $!
|
git clone -q "$2" "$1" > /dev/null & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,7 +597,7 @@ update_repo() {
|
||||||
# Pull the latest commits
|
# Pull the latest commits
|
||||||
echo -n "::: Updating repo in $1..."
|
echo -n "::: Updating repo in $1..."
|
||||||
cd "$1"
|
cd "$1"
|
||||||
$SUDO git pull -q > /dev/null & spinner $!
|
git pull -q > /dev/null & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,46 +605,46 @@ update_repo() {
|
||||||
CreateLogFile() {
|
CreateLogFile() {
|
||||||
# Create logfiles if necessary
|
# Create logfiles if necessary
|
||||||
echo ":::"
|
echo ":::"
|
||||||
$SUDO echo -n "::: Creating log file and changing owner to dnsmasq..."
|
echo -n "::: Creating log file and changing owner to dnsmasq..."
|
||||||
if [ ! -f /var/log/pihole.log ]; then
|
if [ ! -f /var/log/pihole.log ]; then
|
||||||
$SUDO touch /var/log/pihole.log
|
touch /var/log/pihole.log
|
||||||
$SUDO chmod 644 /var/log/pihole.log
|
chmod 644 /var/log/pihole.log
|
||||||
$SUDO chown dnsmasq:root /var/log/pihole.log
|
chown dnsmasq:root /var/log/pihole.log
|
||||||
$SUDO echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
$SUDO echo " already exists!"
|
echo " already exists!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
installPiholeWeb() {
|
installPiholeWeb() {
|
||||||
# Install the web interface
|
# Install the web interface
|
||||||
$SUDO echo ":::"
|
echo ":::"
|
||||||
$SUDO echo -n "::: Installing pihole custom index page..."
|
echo -n "::: Installing pihole custom index page..."
|
||||||
if [ -d "/var/www/html/pihole" ]; then
|
if [ -d "/var/www/html/pihole" ]; then
|
||||||
$SUDO echo " Existing page detected, not overwriting"
|
echo " Existing page detected, not overwriting"
|
||||||
else
|
else
|
||||||
$SUDO mkdir /var/www/html/pihole
|
mkdir /var/www/html/pihole
|
||||||
$SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
||||||
$SUDO cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html
|
cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html
|
||||||
$SUDO echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
installCron() {
|
installCron() {
|
||||||
# Install the cron job
|
# Install the cron job
|
||||||
$SUDO echo ":::"
|
echo ":::"
|
||||||
$SUDO echo -n "::: Installing latest Cron script..."
|
echo -n "::: Installing latest Cron script..."
|
||||||
$SUDO cp /etc/.pihole/advanced/pihole.cron /etc/cron.d/pihole
|
cp /etc/.pihole/advanced/pihole.cron /etc/cron.d/pihole
|
||||||
$SUDO echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
runGravity() {
|
runGravity() {
|
||||||
# Rub gravity.sh to build blacklists
|
# Rub gravity.sh to build blacklists
|
||||||
$SUDO echo ":::"
|
echo ":::"
|
||||||
$SUDO echo "::: Preparing to run gravity.sh to refresh hosts..."
|
echo "::: Preparing to run gravity.sh to refresh hosts..."
|
||||||
if ls /etc/pihole/list* 1> /dev/null 2>&1; then
|
if ls /etc/pihole/list* 1> /dev/null 2>&1; then
|
||||||
echo "::: Cleaning up previous install (preserving whitelist/blacklist)"
|
echo "::: Cleaning up previous install (preserving whitelist/blacklist)"
|
||||||
$SUDO rm /etc/pihole/list.*
|
rm /etc/pihole/list.*
|
||||||
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"
|
||||||
|
@ -654,7 +660,7 @@ setUser(){
|
||||||
echo "::: User 'pihole' already exists"
|
echo "::: User 'pihole' already exists"
|
||||||
else
|
else
|
||||||
echo "::: User 'pihole' doesn't exist. Creating..."
|
echo "::: User 'pihole' doesn't exist. Creating..."
|
||||||
$SUDO useradd -r -s /usr/sbin/nologin pihole
|
useradd -r -s /usr/sbin/nologin pihole
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,11 +669,11 @@ installPihole() {
|
||||||
checkForDependencies # done
|
checkForDependencies # done
|
||||||
stopServices
|
stopServices
|
||||||
setUser
|
setUser
|
||||||
$SUDO mkdir -p /etc/pihole/
|
mkdir -p /etc/pihole/
|
||||||
$SUDO chown www-data:www-data /var/www/html
|
chown www-data:www-data /var/www/html
|
||||||
$SUDO chmod 775 /var/www/html
|
chmod 775 /var/www/html
|
||||||
$SUDO usermod -a -G www-data pihole
|
usermod -a -G www-data pihole
|
||||||
$SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
||||||
|
|
||||||
getGitFiles
|
getGitFiles
|
||||||
installScripts
|
installScripts
|
||||||
|
@ -692,7 +698,7 @@ The install log is in /etc/pihole." $r $c
|
||||||
|
|
||||||
######## SCRIPT ############
|
######## SCRIPT ############
|
||||||
# Start the installer
|
# Start the installer
|
||||||
$SUDO mkdir -p /etc/pihole/
|
mkdir -p /etc/pihole/
|
||||||
welcomeDialogs
|
welcomeDialogs
|
||||||
|
|
||||||
# Verify there is enough disk space for the install
|
# Verify there is enough disk space for the install
|
||||||
|
@ -712,14 +718,14 @@ setDNS
|
||||||
installPihole | tee $tmpLog
|
installPihole | tee $tmpLog
|
||||||
|
|
||||||
# Move the log file into /etc/pihole for storage
|
# Move the log file into /etc/pihole for storage
|
||||||
$SUDO mv $tmpLog $instalLogLoc
|
mv $tmpLog $instalLogLoc
|
||||||
|
|
||||||
displayFinalMessage
|
displayFinalMessage
|
||||||
|
|
||||||
echo -n "::: Restarting services..."
|
echo -n "::: Restarting services..."
|
||||||
# Start services
|
# Start services
|
||||||
$SUDO service dnsmasq restart
|
service dnsmasq restart
|
||||||
$SUDO service lighttpd start
|
service lighttpd start
|
||||||
echo " done."
|
echo " done."
|
||||||
|
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
|
@ -10,40 +10,47 @@
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# Must be root to uninstall
|
# Check if root, and if not then rerun with sudo.
|
||||||
|
echo ":::"
|
||||||
if [[ $EUID -eq 0 ]];then
|
if [[ $EUID -eq 0 ]];then
|
||||||
echo "You are root."
|
echo "::: You are root."
|
||||||
|
# Older versions of Pi-hole set $SUDO="sudo" and prefixed commands with it,
|
||||||
|
# rather than rerunning as sudo. Just in case it turns up by accident,
|
||||||
|
# explicitly set the $SUDO variable to an empty string.
|
||||||
|
SUDO=""
|
||||||
else
|
else
|
||||||
echo "sudo will be used for the install."
|
echo "::: sudo will be used."
|
||||||
# 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 install cannot complete
|
||||||
if [[ $(dpkg-query -s sudo) ]];then
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
export SUDO="sudo"
|
echo "::: Running sudo $@"
|
||||||
else
|
sudo "$@"
|
||||||
echo "Please install sudo or run this as root."
|
exit $?
|
||||||
exit 1
|
else
|
||||||
fi
|
echo "::: Please install sudo or run this script as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
######### SCRIPT ###########
|
######### SCRIPT ###########
|
||||||
$SUDO apt-get -y remove --purge dnsutils bc toilet
|
apt-get -y remove --purge dnsutils bc toilet
|
||||||
$SUDO apt-get -y remove --purge dnsmasq
|
apt-get -y remove --purge dnsmasq
|
||||||
$SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5
|
apt-get -y remove --purge lighttpd php5-common php5-cgi php5
|
||||||
|
|
||||||
# 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
|
rm -rf /var/www/html/admin
|
||||||
$SUDO rm -rf /var/www/html/pihole
|
rm -rf /var/www/html/pihole
|
||||||
$SUDO rm /var/www/html/index.lighttpd.orig
|
rm /var/www/html/index.lighttpd.orig
|
||||||
|
|
||||||
# If the web directory is empty after removing these files, then the parent html folder can be removed.
|
# If the web directory is empty after removing these files, then the parent html folder can be removed.
|
||||||
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
||||||
$SUDO rm -rf /var/www/html
|
rm -rf /var/www/html
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Removing dnsmasq config files..."
|
echo "Removing dnsmasq config files..."
|
||||||
$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
||||||
|
|
||||||
# Attempt to preserve backwards compatibility with older versions
|
# Attempt to preserve backwards compatibility with older versions
|
||||||
# to guarantee no additional changes were made to /etc/crontab after
|
# to guarantee no additional changes were made to /etc/crontab after
|
||||||
|
@ -51,23 +58,23 @@ $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
||||||
# 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
|
mv /etc/crontab /etc/crontab.pihole
|
||||||
$SUDO mv /etc/crontab.orig /etc/crontab
|
mv /etc/crontab.orig /etc/crontab
|
||||||
$SUDO service cron restart
|
service cron restart
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 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
|
rm /etc/cron.d/pihole
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Removing config files and scripts..."
|
echo "Removing config files and scripts..."
|
||||||
$SUDO rm /etc/dnsmasq.conf
|
rm /etc/dnsmasq.conf
|
||||||
$SUDO rm -rf /etc/lighttpd/
|
rm -rf /etc/lighttpd/
|
||||||
$SUDO rm /var/log/pihole.log
|
rm /var/log/pihole.log
|
||||||
$SUDO rm /usr/local/bin/gravity.sh
|
rm /usr/local/bin/gravity.sh
|
||||||
$SUDO rm /usr/local/bin/chronometer.sh
|
rm /usr/local/bin/chronometer.sh
|
||||||
$SUDO rm /usr/local/bin/whitelist.sh
|
rm /usr/local/bin/whitelist.sh
|
||||||
$SUDO rm /usr/local/bin/piholeLogFlush.sh
|
rm /usr/local/bin/piholeLogFlush.sh
|
||||||
$SUDO rm -rf /etc/pihole/
|
rm -rf /etc/pihole/
|
||||||
|
|
Loading…
Reference in a new issue