mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-01 02:23:21 +00:00
Added root check and removed sudo statements
This commit is contained in:
parent
93664aeb4e
commit
e9a3ea6508
2 changed files with 74 additions and 63 deletions
|
@ -16,6 +16,12 @@
|
||||||
#
|
#
|
||||||
# curl -L install.pi-hole.net | bash
|
# curl -L install.pi-hole.net | bash
|
||||||
|
|
||||||
|
# Must be root to install
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "ERROR: You must run this script as a root user"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
######## VARIABLES #########
|
######## VARIABLES #########
|
||||||
tmpLog=/tmp/pihole-install.log
|
tmpLog=/tmp/pihole-install.log
|
||||||
instalLogLoc=/etc/pihole/install.log
|
instalLogLoc=/etc/pihole/install.log
|
||||||
|
@ -41,13 +47,13 @@ backupLegacyPihole()
|
||||||
{
|
{
|
||||||
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
|
||||||
|
@ -121,8 +127,8 @@ 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 mkdir -p /etc/pihole/
|
mkdir -p /etc/pihole/
|
||||||
sudo touch /etc/pihole/.useIPv6
|
touch /etc/pihole/.useIPv6
|
||||||
}
|
}
|
||||||
|
|
||||||
getStaticIPv4Settings()
|
getStaticIPv4Settings()
|
||||||
|
@ -189,7 +195,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(){
|
||||||
|
@ -198,75 +204,75 @@ if grep -q $IPv4addr $dhcpcdFile; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
setDHCPCD
|
setDHCPCD
|
||||||
sudo ip addr replace dev $piholeInterface $IPv4addr
|
ip addr replace dev $piholeInterface $IPv4addr
|
||||||
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."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
installScripts(){
|
installScripts(){
|
||||||
sudo curl -o /usr/local/bin/gravity.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh
|
curl -o /usr/local/bin/gravity.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh
|
||||||
sudo curl -o /usr/local/bin/chronometer.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh
|
curl -o /usr/local/bin/chronometer.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh
|
||||||
sudo curl -o /usr/local/bin/whitelist.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/whitelist.sh
|
curl -o /usr/local/bin/whitelist.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/whitelist.sh
|
||||||
sudo curl -o /usr/local/bin/piholeLogFlush.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/piholeLogFlush.sh
|
curl -o /usr/local/bin/piholeLogFlush.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/piholeLogFlush.sh
|
||||||
sudo chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,piholeLogFlush}.sh
|
chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,piholeLogFlush}.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
installConfigs(){
|
installConfigs(){
|
||||||
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
||||||
sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
||||||
sudo curl -o /etc/dnsmasq.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf
|
curl -o /etc/dnsmasq.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf
|
||||||
sudo curl -o /etc/lighttpd/lighttpd.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf
|
curl -o /etc/lighttpd/lighttpd.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf
|
||||||
sudo sed -i "s/@INT@/$piholeInterface/" /etc/dnsmasq.conf
|
sed -i "s/@INT@/$piholeInterface/" /etc/dnsmasq.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
stopServices(){
|
stopServices(){
|
||||||
sudo service dnsmasq stop || true
|
service dnsmasq stop || true
|
||||||
sudo service lighttpd stop || true
|
service lighttpd stop || true
|
||||||
}
|
}
|
||||||
|
|
||||||
installDependencies(){
|
installDependencies(){
|
||||||
sudo apt-get update
|
apt-get update
|
||||||
sudo apt-get -y upgrade
|
apt-get -y upgrade
|
||||||
sudo apt-get -y install dnsutils bc toilet
|
apt-get -y install dnsutils bc toilet
|
||||||
sudo apt-get -y install dnsmasq
|
apt-get -y install dnsmasq
|
||||||
sudo apt-get -y install lighttpd php5-common php5-cgi php5
|
apt-get -y install lighttpd php5-common php5-cgi php5
|
||||||
}
|
}
|
||||||
|
|
||||||
installWebAdmin(){
|
installWebAdmin(){
|
||||||
sudo wget https://github.com/jacobsalmela/AdminLTE/archive/master.zip -O /var/www/master.zip
|
wget https://github.com/jacobsalmela/AdminLTE/archive/master.zip -O /var/www/master.zip
|
||||||
sudo unzip -oq /var/www/master.zip -d /var/www/html/
|
unzip -oq /var/www/master.zip -d /var/www/html/
|
||||||
sudo mv /var/www/html/AdminLTE-master /var/www/html/admin
|
mv /var/www/html/AdminLTE-master /var/www/html/admin
|
||||||
sudo rm /var/www/master.zip 2>/dev/null
|
rm /var/www/master.zip 2>/dev/null
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
installPiholeWeb(){
|
installPiholeWeb(){
|
||||||
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 curl -o /var/www/html/pihole/index.html https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/index.html
|
curl -o /var/www/html/pihole/index.html https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/index.html
|
||||||
}
|
}
|
||||||
|
|
||||||
installCron(){
|
installCron(){
|
||||||
sudo mv /etc/crontab /etc/crontab.orig
|
mv /etc/crontab /etc/crontab.orig
|
||||||
sudo curl -o /etc/crontab https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/pihole.cron
|
curl -o /etc/crontab https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/pihole.cron
|
||||||
}
|
}
|
||||||
|
|
||||||
installPihole()
|
installPihole()
|
||||||
{
|
{
|
||||||
installDependencies
|
installDependencies
|
||||||
stopServices
|
stopServices
|
||||||
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 pi
|
usermod -a -G www-data pi
|
||||||
sudo lighty-enable-mod fastcgi fastcgi-php
|
lighty-enable-mod fastcgi fastcgi-php
|
||||||
installScripts
|
installScripts
|
||||||
installConfigs
|
installConfigs
|
||||||
installWebAdmin
|
installWebAdmin
|
||||||
installPiholeWeb
|
installPiholeWeb
|
||||||
installCron
|
installCron
|
||||||
sudo /usr/local/bin/gravity.sh
|
/usr/local/bin/gravity.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
displayFinalMessage(){
|
displayFinalMessage(){
|
||||||
|
@ -317,9 +323,9 @@ fi
|
||||||
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
|
||||||
|
|
||||||
sudo service dnsmasq start
|
service dnsmasq start
|
||||||
sudo service lighttpd start
|
service lighttpd start
|
||||||
|
|
|
@ -8,20 +8,25 @@
|
||||||
# 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
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "ERROR: You must run this script as a root user"
|
||||||
|
exit 1
|
||||||
|
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
|
||||||
sudo rm -rf /var/www/html
|
rm -rf /var/www/html
|
||||||
sudo rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
||||||
sudo rm /etc/crontab
|
rm /etc/crontab
|
||||||
sudo mv /etc/crontab.orig /etc/crontab
|
mv /etc/crontab.orig /etc/crontab
|
||||||
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