mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-28 09:03:17 +00:00
Checks if the script is being run as root
These changes check to see if it installer is invoked by the root and sets the sudo variable to handle root and non-root runs.
This commit is contained in:
parent
fd21237b27
commit
d756f430d8
1 changed files with 47 additions and 42 deletions
|
@ -24,70 +24,75 @@ echo " Press Enter when ready "
|
||||||
echo " "
|
echo " "
|
||||||
read
|
read
|
||||||
|
|
||||||
|
#Checks if the script is being run as root and sets sudo accordingly
|
||||||
|
SUDO=''
|
||||||
|
if (( $EUID !=0 )); then SUDO='sudo'
|
||||||
|
fi
|
||||||
|
|
||||||
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/
|
$SUDO mkdir -p /etc/pihole/original/
|
||||||
sudo mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d")
|
$SUDO 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")
|
$SUDO 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")
|
$SUDO 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")
|
$SUDO 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")
|
$SUDO 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")
|
$SUDO mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d")
|
||||||
else
|
else
|
||||||
:
|
:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Updating the Pi..."
|
echo "Updating the Pi..."
|
||||||
sudo apt-get update
|
$SUDO apt-get update
|
||||||
sudo apt-get -y upgrade
|
$SUDO apt-get -y upgrade
|
||||||
|
|
||||||
echo "Installing tools..."
|
echo "Installing tools..."
|
||||||
sudo apt-get -y install dnsutils
|
$SUDO apt-get -y install dnsutils
|
||||||
sudo apt-get -y install bc
|
$SUDO apt-get -y install bc
|
||||||
sudo apt-get -y install toilet
|
$SUDO apt-get -y install toilet
|
||||||
|
|
||||||
echo "Installing DNS..."
|
echo "Installing DNS..."
|
||||||
sudo apt-get -y install dnsmasq
|
$SUDO apt-get -y install dnsmasq
|
||||||
sudo update-rc.d dnsmasq enable
|
$SUDO update-rc.d dnsmasq enable
|
||||||
|
|
||||||
echo "Installing a Web server"
|
echo "Installing a Web server"
|
||||||
sudo apt-get -y install lighttpd php5-common php5-cgi php5
|
$SUDO apt-get -y install lighttpd php5-common php5-cgi php5
|
||||||
sudo mkdir /var/www/html
|
$SUDO mkdir /var/www/html
|
||||||
sudo chown www-data:www-data /var/www/html
|
$SUDO chown www-data:www-data /var/www/html
|
||||||
sudo chmod 775 /var/www/html
|
$SUDO chmod 775 /var/www/html
|
||||||
sudo usermod -a -G www-data pi
|
$SUDO usermod -a -G www-data pi
|
||||||
|
|
||||||
echo "Stopping services to modify them..."
|
echo "Stopping services to modify them..."
|
||||||
sudo service dnsmasq stop
|
$SUDO service dnsmasq stop
|
||||||
sudo service lighttpd stop
|
$SUDO service lighttpd stop
|
||||||
|
|
||||||
echo "Backing up original config files and downloading Pi-hole ones..."
|
echo "Backing up original config files and downloading Pi-hole ones..."
|
||||||
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
$SUDO mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
||||||
sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
$SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
||||||
sudo mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
$SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
||||||
sudo curl -o /etc/dnsmasq.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf"
|
$SUDO 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"
|
$SUDO curl -o /etc/lighttpd/lighttpd.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf"
|
||||||
sudo lighty-enable-mod fastcgi fastcgi-php
|
$SUDO lighty-enable-mod fastcgi fastcgi-php
|
||||||
sudo mkdir /var/www/html/pihole
|
$SUDO mkdir /var/www/html/pihole
|
||||||
sudo curl -o /var/www/html/pihole/index.html "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/index.html"
|
$SUDO curl -o /var/www/html/pihole/index.html "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/index.html"
|
||||||
|
|
||||||
echo "Installing the Web interface..."
|
echo "Installing the Web interface..."
|
||||||
sudo wget https://github.com/jacobsalmela/AdminLTE/archive/master.zip -O /var/www/master.zip
|
$SUDO wget https://github.com/jacobsalmela/AdminLTE/archive/master.zip -O /var/www/master.zip
|
||||||
sudo unzip /var/www/master.zip -d /var/www/html/
|
$SUDO unzip /var/www/master.zip -d /var/www/html/
|
||||||
sudo mv /var/www/html/AdminLTE-master /var/www/html/admin
|
$SUDO mv /var/www/html/AdminLTE-master /var/www/html/admin
|
||||||
sudo rm /var/www/master.zip 2>/dev/null
|
$SUDO rm /var/www/master.zip 2>/dev/null
|
||||||
sudo touch /var/log/pihole.log
|
$SUDO touch /var/log/pihole.log
|
||||||
sudo chmod 644 /var/log/pihole.log
|
$SUDO chmod 644 /var/log/pihole.log
|
||||||
sudo chown dnsmasq:root /var/log/pihole.log
|
$SUDO chown dnsmasq:root /var/log/pihole.log
|
||||||
|
|
||||||
echo "Locating the Pi-hole..."
|
echo "Locating the Pi-hole..."
|
||||||
sudo curl -o /usr/local/bin/gravity.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh"
|
$SUDO 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"
|
$SUDO curl -o /usr/local/bin/chronometer.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh"
|
||||||
sudo chmod 755 /usr/local/bin/gravity.sh
|
$SUDO chmod 755 /usr/local/bin/gravity.sh
|
||||||
sudo chmod 755 /usr/local/bin/chronometer.sh
|
$SUDO chmod 755 /usr/local/bin/chronometer.sh
|
||||||
|
|
||||||
echo "Entering the event horizon..."
|
echo "Entering the event horizon..."
|
||||||
sudo /usr/local/bin/gravity.sh
|
$SUDO /usr/local/bin/gravity.sh
|
||||||
|
|
||||||
echo "Restarting..."
|
echo "Restarting..."
|
||||||
sudo reboot
|
$SUDO reboot
|
||||||
|
|
Loading…
Reference in a new issue