Huge update! Base files now cloned from github (or updated if already existing) and copied out to the correct directories. Web admin interface is now cloned from hithub (or updated if already existing). Packages are checked before we go ahead and try to install them anyway.
This commit is contained in:
parent
206717828b
commit
6cea480210
|
@ -20,10 +20,10 @@
|
||||||
tmpLog=/tmp/pihole-install.log
|
tmpLog=/tmp/pihole-install.log
|
||||||
instalLogLoc=/etc/pihole/install.log
|
instalLogLoc=/etc/pihole/install.log
|
||||||
|
|
||||||
WEB_INTERFACE_GIT_URL="https://github.com/jacobsalmela/AdminLTE.git"
|
webInterfaceGitUrl="https://github.com/pi-hole/AdminLTE.git"
|
||||||
WEB_INTERFACE_DIR="/var/www/html/admin"
|
webInterfaceDir="/var/www/html/admin"
|
||||||
PIHOLE_GIT_URL="https://github.com/jacobsalmela/AdminLTE.git"
|
piholeGitUrl="https://github.com/pi-hole/pi-hole.git"
|
||||||
PIHOLE_FILES_DIR="/var/www/html/admin"
|
piholeFilesDir="/etc/.pihole"
|
||||||
|
|
||||||
|
|
||||||
# Find the rows and columns
|
# Find the rows and columns
|
||||||
|
@ -71,17 +71,21 @@ spinner(){
|
||||||
local pid=$1
|
local pid=$1
|
||||||
local delay=0.001
|
local delay=0.001
|
||||||
local spinstr='/-\|'
|
local spinstr='/-\|'
|
||||||
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
|
|
||||||
local temp=${spinstr#?}
|
spin='-\|/'
|
||||||
printf " [%c] " "$spinstr"
|
i=0
|
||||||
local spinstr=$temp${spinstr%"$temp"}
|
while kill -0 $pid 2>/dev/null
|
||||||
sleep $delay
|
do
|
||||||
printf "\b\b\b\b\b\b"
|
i=$(( (i+1) %4 ))
|
||||||
|
printf "\b${spin:$i:1}"
|
||||||
|
sleep .1
|
||||||
done
|
done
|
||||||
printf " \b\b\b\b"
|
printf "\b"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
backupLegacyPihole(){
|
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"
|
||||||
|
@ -258,106 +262,159 @@ setStaticIPv4(){
|
||||||
}
|
}
|
||||||
|
|
||||||
installScripts(){
|
installScripts(){
|
||||||
$SUDO echo " "
|
$SUDO echo ":::"
|
||||||
$SUDO echo "::: Installing scripts..."
|
$SUDO echo -n "::: Installing scripts..."
|
||||||
$SUDO curl -o /usr/local/bin/gravity.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh
|
$SUDO cp /etc/.pihole/gravity.sh /usr/local/bin/gravity.sh
|
||||||
$SUDO curl -o /usr/local/bin/chronometer.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /usr/local/bin/chronometer.sh
|
||||||
$SUDO curl -o /usr/local/bin/whitelist.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/whitelist.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /usr/local/bin/whitelist.sh
|
||||||
$SUDO curl -o /usr/local/bin/blacklist.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/blacklist.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /usr/local/bin/blacklist.sh
|
||||||
$SUDO curl -o /usr/local/bin/piholeLogFlush.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/piholeLogFlush.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /usr/local/bin/piholeLogFlush.sh
|
||||||
$SUDO curl -o /usr/local/bin/updateDashboard.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/updateDashboard.sh
|
$SUDO 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
|
$SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh
|
||||||
$SUDO echo "::: ...done."
|
$SUDO echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
installConfigs(){
|
installConfigs(){
|
||||||
$SUDO echo " "
|
$SUDO echo ":::"
|
||||||
$SUDO echo "::: Installing configs..."
|
$SUDO echo -n "::: Installing configs..."
|
||||||
$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 curl -o /etc/dnsmasq.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf
|
$SUDO cp /etc/.pihole/advanced/dnsmasq.conf /etc/dnsmasq.conf
|
||||||
$SUDO curl -o /etc/lighttpd/lighttpd.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf
|
$SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf
|
||||||
$SUDO sed -i "s/@INT@/$piholeInterface/" /etc/dnsmasq.conf
|
$SUDO sed -i "s/@INT@/$piholeInterface/" /etc/dnsmasq.conf
|
||||||
$SUDO echo "::: ...done."
|
$SUDO echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
stopServices(){
|
stopServices(){
|
||||||
$SUDO echo " "
|
$SUDO echo ":::"
|
||||||
$SUDO echo "::: Stopping services..."
|
$SUDO echo -n "::: Stopping services..."
|
||||||
$SUDO service dnsmasq stop || true
|
$SUDO service dnsmasq stop & spinner $! || true
|
||||||
$SUDO service lighttpd stop || true
|
$SUDO service lighttpd stop & spinner $! || true
|
||||||
$SUDO echo "::: ...done."
|
$SUDO echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
installDependencies(){
|
|
||||||
$SUDO echo " "
|
checkForDependencies(){
|
||||||
$SUDO echo "::: Updating apt-get package list"
|
echo ":::"
|
||||||
$SUDO apt-get -qq update & spinner $!
|
#update package lists
|
||||||
$SUDO echo "::: Upgrading apt-get packages"
|
echo -n "::: Updating package list before install...."
|
||||||
$SUDO apt-get -yqq upgrade & spinner $!
|
#$SUDO apt-get -qq update & spinner $!
|
||||||
$SUDO echo "::: ...done."
|
echo " done!"
|
||||||
$SUDO echo "::: installing dnsutils, bc, toilet, and figlet..."
|
echo -n "::: Upgrading installed apt-get packages...."
|
||||||
$SUDO apt-get -yqq install dnsutils bc toilet figlet & spinner $!
|
#$SUDO apt-get -y -qq upgrade & spinner $!
|
||||||
$SUDO echo "::: ...done."
|
echo " done!"
|
||||||
$SUDO echo "::: Installing dnsmasq..."
|
|
||||||
$SUDO apt-get -yqq install dnsmasq & spinner $!
|
echo ":::"
|
||||||
$SUDO echo "::: ...done."
|
echo "::: Checking dependencies:"
|
||||||
$SUDO echo "::: Installing lighttpd, php5-common, php5-cgi, and php5..."
|
|
||||||
$SUDO apt-get -yqq install lighttpd php5-common php5-cgi php5 & spinner $!
|
dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget )
|
||||||
$SUDO echo "::: ...done."
|
for i in "${dependencies[@]}"
|
||||||
$SUDO echo "::: Installing git..."
|
do
|
||||||
$SUDO apt-get -yqq install git & spinner $!
|
:
|
||||||
$SUDO echo "::: ...done."
|
echo -n "::: Checking for $i..."
|
||||||
|
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
||||||
|
echo -n " Not found! Installing...."
|
||||||
|
apt-get -y -qq install $i > /dev/null & spinner $!
|
||||||
|
echo " done!"
|
||||||
|
else
|
||||||
|
echo " already installed!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
installWebAdmin(){
|
getGitFiles(){
|
||||||
$SUDO echo " "
|
|
||||||
$SUDO echo "::: Downloading and installing latest WebAdmin files..."
|
|
||||||
if [ -d "/var/www/html/admin" ]; then
|
|
||||||
$SUDO rm -rf /var/www/html/admin
|
|
||||||
fi
|
|
||||||
if [ -d "/var/www/html/AdminLTE-master" ]; then
|
|
||||||
$SUDO rm -rf /var/www/html/AdminLTE-master
|
|
||||||
fi
|
|
||||||
$SUDO wget -nv https://github.com/jacobsalmela/AdminLTE/archive/master.zip -O /var/www/master.zip & spinner $!
|
|
||||||
$SUDO unzip -oq /var/www/master.zip -d /var/www/html/
|
|
||||||
$SUDO mv /var/www/html/AdminLTE-master /var/www/html/admin
|
|
||||||
$SUDO rm /var/www/master.zip 2>/dev/null
|
|
||||||
$SUDO echo "::: ...Done."
|
|
||||||
|
|
||||||
$SUDO echo "::: Creating log file and changing owner to dnsmasq..."
|
echo ":::"
|
||||||
|
dirToCheck=$piholeFilesDir
|
||||||
|
echo -n "::: Checking for existing base files..."
|
||||||
|
if ! is_repo; then
|
||||||
|
echo -n " Not found! Getting files from github...."
|
||||||
|
repoToClone=$piholeGitUrl
|
||||||
|
make_repo
|
||||||
|
echo " done!"
|
||||||
|
else
|
||||||
|
echo -n " Existing files found. Grabbing latest...."
|
||||||
|
update_repo
|
||||||
|
echo " done!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ":::"
|
||||||
|
dirToCheck=$webInterfaceDir
|
||||||
|
echo -n "::: Checking for existing web interface..."
|
||||||
|
if ! is_repo; then
|
||||||
|
echo -n " Not found! Getting files from github...."
|
||||||
|
repoToClone=$webInterfaceGitUrl
|
||||||
|
make_repo
|
||||||
|
echo " done!"
|
||||||
|
else
|
||||||
|
echo -n " Existing files found. Grabbing latest..."
|
||||||
|
update_repo
|
||||||
|
echo " done!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
is_repo() {
|
||||||
|
# if the directory does not have a .git folder
|
||||||
|
# it is not a repo
|
||||||
|
if [ ! -d "$dirToCheck/.git" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
make_repo() {
|
||||||
|
# remove the non-repod interface and clone the interface
|
||||||
|
|
||||||
|
$SUDO rm -rf $dirToCheck
|
||||||
|
$SUDO git clone -q "$repoToClone" "$dirToCheck" > /dev/null & spinner $!
|
||||||
|
}
|
||||||
|
|
||||||
|
update_repo() {
|
||||||
|
# pull the latest commits
|
||||||
|
cd "$dirToCheck"
|
||||||
|
$SUDO git pull -q > /dev/null & spinner $!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CreateLogFile(){
|
||||||
|
echo ":::"
|
||||||
|
$SUDO 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
|
$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
|
||||||
|
$SUDO echo " done!"
|
||||||
else
|
else
|
||||||
$SUDO echo "::: No need to create, already exists!"
|
$SUDO echo " already exists!"
|
||||||
fi
|
fi
|
||||||
$SUDO echo "::: ...done."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
installPiholeWeb(){
|
installPiholeWeb(){
|
||||||
$SUDO echo " "
|
$SUDO echo ":::"
|
||||||
$SUDO echo "::: Downloading and installing pihole custom index page..."
|
$SUDO 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"
|
$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
|
$SUDO 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
|
$SUDO cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html
|
||||||
|
$SUDO echo " done!"
|
||||||
fi
|
fi
|
||||||
$SUDO echo "::: ...done."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
installCron(){
|
installCron(){
|
||||||
$SUDO echo " "
|
$SUDO echo ":::"
|
||||||
$SUDO echo "::: Downloading latest Cron script..."
|
$SUDO echo -n "::: Installing latest Cron script..."
|
||||||
$SUDO curl -o /etc/cron.d/pihole https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/pihole.cron
|
$SUDO cp /etc/.pihole/advanced/pihole.cron /etc/cron.d/pihole
|
||||||
$SUDO echo "::: ...done."
|
$SUDO echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
runGravity(){
|
runGravity(){
|
||||||
$SUDO echo " "
|
$SUDO echo ":::"
|
||||||
$SUDO echo "::: Preparing to run gravity.sh to refresh hosts..."
|
$SUDO 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)"
|
||||||
|
@ -368,28 +425,21 @@ runGravity(){
|
||||||
$SUDO echo "::: ...done."
|
$SUDO echo "::: ...done."
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForAndInstallDependencies(){
|
|
||||||
if [ upgrade ]; then
|
|
||||||
#Likely an existing install, no need to apt-get update
|
|
||||||
echo "::: Previous installation detected"
|
|
||||||
else
|
|
||||||
echo "::: First time install, updating package list"
|
|
||||||
$SUDO apt-get -qq update & spinner $!
|
|
||||||
echo "::: Upgrading installed apt-get packages"
|
|
||||||
$SUDO apt-get -yqq upgrade & spinner $!
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
installPihole(){
|
installPihole(){
|
||||||
installDependencies
|
checkForDependencies # done
|
||||||
stopServices
|
stopServices
|
||||||
|
|
||||||
$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
|
||||||
$SUDO lighty-enable-mod fastcgi fastcgi-php
|
$SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
||||||
|
|
||||||
|
getGitFiles
|
||||||
installScripts
|
installScripts
|
||||||
installConfigs
|
installConfigs
|
||||||
installWebAdmin
|
#installWebAdmin
|
||||||
|
CreateLogFile
|
||||||
installPiholeWeb
|
installPiholeWeb
|
||||||
installCron
|
installCron
|
||||||
runGravity
|
runGravity
|
||||||
|
@ -417,7 +467,7 @@ chooseInterface
|
||||||
# Let the user decide if they want to block ads over IPv4 and/or IPv6
|
# Let the user decide if they want to block ads over IPv4 and/or IPv6
|
||||||
use4andor6
|
use4andor6
|
||||||
|
|
||||||
checkForAndInstallDependencies
|
|
||||||
|
|
||||||
# Install and log everything to a file
|
# Install and log everything to a file
|
||||||
installPihole | tee $tmpLog
|
installPihole | tee $tmpLog
|
||||||
|
|
Loading…
Reference in New Issue