mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-26 06:40:17 +00:00
Merge remote-tracking branch 'refs/remotes/pi-hole/development' into development
This commit is contained in:
commit
975f4f2a17
1 changed files with 140 additions and 142 deletions
|
@ -45,11 +45,15 @@ echo ":::"
|
||||||
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 install."
|
echo "::: Script called with non-root privileges. The Pi-hole installs server packages and configures"
|
||||||
# Check if it is actually installed
|
echo "::: system networking, it requires elevated rights. Please check the contents of the script for"
|
||||||
# If it isn't, exit because the install cannot complete
|
echo "::: any concerns with this requirement. Please be sure to download this script from a trusted source."
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Detecting the presence of the sudo utility for continuation of this install..."
|
||||||
if [ -x "$(command -v sudo)" ];then
|
if [ -x "$(command -v sudo)" ];then
|
||||||
export SUDO="sudo"
|
echo "::: Utility sudo located."
|
||||||
|
exec sudo bash "$0" "$@"
|
||||||
|
exit $?
|
||||||
else
|
else
|
||||||
echo "::: sudo is needed for the Web interface to run pihole commands. Please run this script as root and it will be automatically installed."
|
echo "::: sudo is needed for the Web interface to run pihole commands. Please run this script as root and it will be automatically installed."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -62,19 +66,19 @@ if [ -x "$(command -v apt-get)" ];then
|
||||||
#Debian Family
|
#Debian Family
|
||||||
#Decide if php should be `php5` or just `php` (Fixes issues with Ubuntu 16.04 LTS)
|
#Decide if php should be `php5` or just `php` (Fixes issues with Ubuntu 16.04 LTS)
|
||||||
phpVer="php"
|
phpVer="php"
|
||||||
${SUDO} apt-get install --dry-run php5 > /dev/null 2>&1
|
apt-get install --dry-run php5 > /dev/null 2>&1
|
||||||
if [ $? == 0 ]; then
|
if [ $? == 0 ]; then
|
||||||
phpVer="php5"
|
phpVer="php5"
|
||||||
fi
|
fi
|
||||||
#############################################
|
#############################################
|
||||||
PKG_MANAGER="apt-get"
|
PKG_MANAGER="apt-get"
|
||||||
PKG_CACHE="/var/cache/apt"
|
PKG_CACHE="/var/lib/apt/lists/"
|
||||||
UPDATE_PKG_CACHE="$PKG_MANAGER -qq update"
|
UPDATE_PKG_CACHE="$PKG_MANAGER -qq update"
|
||||||
PKG_UPDATE="$PKG_MANAGER upgrade"
|
PKG_UPDATE="$PKG_MANAGER upgrade"
|
||||||
PKG_INSTALL="$PKG_MANAGER --yes --quiet install"
|
PKG_INSTALL="$PKG_MANAGER --yes --quiet install"
|
||||||
PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst"
|
PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst"
|
||||||
INSTALLER_DEPS=( apt-utils whiptail dhcpcd5)
|
INSTALLER_DEPS=( apt-utils whiptail dhcpcd5)
|
||||||
PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd ${phpVer}-common ${phpVer}-cgi ${phpVer} git curl unzip wget sudo netcat cron iproute2 )
|
PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd ${phpVer}-common ${phpVer}-cgi git curl unzip wget sudo netcat cron iproute2 )
|
||||||
LIGHTTPD_USER="www-data"
|
LIGHTTPD_USER="www-data"
|
||||||
LIGHTTPD_GROUP="www-data"
|
LIGHTTPD_GROUP="www-data"
|
||||||
LIGHTTPD_CFG="lighttpd.conf.debian"
|
LIGHTTPD_CFG="lighttpd.conf.debian"
|
||||||
|
@ -317,7 +321,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 /etc/dhcpcd.conf >/dev/null
|
static domain_name_servers=$IPv4gw" | tee -a /etc/dhcpcd.conf >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
setStaticIPv4() {
|
setStaticIPv4() {
|
||||||
|
@ -327,7 +331,7 @@ setStaticIPv4() {
|
||||||
echo "::: Static IP already configured"
|
echo "::: Static IP already configured"
|
||||||
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 ":::"
|
||||||
|
@ -343,20 +347,20 @@ setStaticIPv4() {
|
||||||
# Backup existing interface configuration:
|
# Backup existing interface configuration:
|
||||||
cp ${IFCFG_FILE} ${IFCFG_FILE}.backup-$(date +%Y-%m-%d-%H%M%S)
|
cp ${IFCFG_FILE} ${IFCFG_FILE}.backup-$(date +%Y-%m-%d-%H%M%S)
|
||||||
# Build Interface configuration file:
|
# Build Interface configuration file:
|
||||||
${SUDO} echo "# Configured via Pi-Hole installer" > ${IFCFG_FILE}
|
echo "# Configured via Pi-Hole installer" > ${IFCFG_FILE}
|
||||||
${SUDO} echo "DEVICE=$piholeInterface" >> ${IFCFG_FILE}
|
echo "DEVICE=$piholeInterface" >> ${IFCFG_FILE}
|
||||||
${SUDO} echo "BOOTPROTO=none" >> ${IFCFG_FILE}
|
echo "BOOTPROTO=none" >> ${IFCFG_FILE}
|
||||||
${SUDO} echo "ONBOOT=yes" >> ${IFCFG_FILE}
|
echo "ONBOOT=yes" >> ${IFCFG_FILE}
|
||||||
${SUDO} echo "IPADDR=$IPADDR" >> ${IFCFG_FILE}
|
echo "IPADDR=$IPADDR" >> ${IFCFG_FILE}
|
||||||
${SUDO} echo "PREFIX=$CIDR" >> ${IFCFG_FILE}
|
echo "PREFIX=$CIDR" >> ${IFCFG_FILE}
|
||||||
${SUDO} echo "GATEWAY=$IPv4gw" >> ${IFCFG_FILE}
|
echo "GATEWAY=$IPv4gw" >> ${IFCFG_FILE}
|
||||||
${SUDO} echo "DNS1=$piholeDNS1" >> ${IFCFG_FILE}
|
echo "DNS1=$piholeDNS1" >> ${IFCFG_FILE}
|
||||||
${SUDO} echo "DNS2=$piholeDNS2" >> ${IFCFG_FILE}
|
echo "DNS2=$piholeDNS2" >> ${IFCFG_FILE}
|
||||||
${SUDO} echo "USERCTL=no" >> ${IFCFG_FILE}
|
echo "USERCTL=no" >> ${IFCFG_FILE}
|
||||||
${SUDO} ip addr replace dev "$piholeInterface" "$IPv4addr"
|
ip addr replace dev "$piholeInterface" "$IPv4addr"
|
||||||
if [ -x "$(command -v nmcli)" ];then
|
if [ -x "$(command -v nmcli)" ];then
|
||||||
# Tell NetworkManager to read our new sysconfig file
|
# Tell NetworkManager to read our new sysconfig file
|
||||||
${SUDO} nmcli con load ${IFCFG_FILE} > /dev/null
|
nmcli con load ${IFCFG_FILE} > /dev/null
|
||||||
fi
|
fi
|
||||||
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."
|
||||||
|
@ -491,100 +495,91 @@ 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
|
||||||
${SUDO} sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsFile1}
|
sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsFile1}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 to /opt/pihole..."
|
echo -n "::: Installing scripts to /opt/pihole..."
|
||||||
if [ ! -d /opt/pihole ]; then
|
install -o "${USER}" -m755 -d /opt/pihole
|
||||||
${SUDO} mkdir /opt/pihole
|
|
||||||
${SUDO} chown "$USER":root /opt/pihole
|
cd /etc/.pihole/
|
||||||
${SUDO} chmod u+srwx /opt/pihole
|
|
||||||
fi
|
install -o "${USER}" -Dm755 -t /opt/pihole/ gravity.sh
|
||||||
${SUDO} cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh
|
install -o "${USER}" -Dm755 -t /opt/pihole/ ./advanced/Scripts/*.sh
|
||||||
${SUDO} cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh
|
install -o "${USER}" -Dm755 -t /usr/local/bin/ pihole
|
||||||
${SUDO} cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh
|
|
||||||
${SUDO} cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/blacklist.sh
|
install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
||||||
${SUDO} cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh
|
|
||||||
${SUDO} cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh
|
|
||||||
${SUDO} cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh
|
|
||||||
${SUDO} cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh
|
|
||||||
${SUDO} cp /etc/.pihole/advanced/Scripts/version.sh /opt/pihole/version.sh
|
|
||||||
${SUDO} chmod 755 /opt/pihole/gravity.sh /opt/pihole/chronometer.sh /opt/pihole/whitelist.sh /opt/pihole/blacklist.sh /opt/pihole/piholeLogFlush.sh /opt/pihole/uninstall.sh /opt/pihole/setupLCD.sh /opt/pihole/version.sh
|
|
||||||
${SUDO} cp /etc/.pihole/pihole /usr/local/bin/pihole
|
|
||||||
${SUDO} chmod 755 /usr/local/bin/pihole
|
|
||||||
${SUDO} cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
|
||||||
. /etc/bash_completion.d/pihole
|
. /etc/bash_completion.d/pihole
|
||||||
|
|
||||||
#Tidy up /usr/local/bin directory if installing over previous install.
|
#Tidy up /usr/local/bin directory if installing over previous install.
|
||||||
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug)
|
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug)
|
||||||
for i in "${oldFiles[@]}"; do
|
for i in "${oldFiles[@]}"; do
|
||||||
if [ -f "/usr/local/bin/$i.sh" ]; then
|
if [ -f "/usr/local/bin/$i.sh" ]; then
|
||||||
${SUDO} rm /usr/local/bin/"$i".sh
|
rm /usr/local/bin/"$i".sh
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
${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
|
||||||
if [ ! -d "/etc/lighttpd" ]; then
|
if [ ! -d "/etc/lighttpd" ]; then
|
||||||
${SUDO} mkdir /etc/lighttpd
|
mkdir /etc/lighttpd
|
||||||
${SUDO} chown "$USER":root /etc/lighttpd
|
chown "$USER":root /etc/lighttpd
|
||||||
${SUDO} mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
||||||
fi
|
fi
|
||||||
${SUDO} cp /etc/.pihole/advanced/${LIGHTTPD_CFG} /etc/lighttpd/lighttpd.conf
|
cp /etc/.pihole/advanced/${LIGHTTPD_CFG} /etc/lighttpd/lighttpd.conf
|
||||||
${SUDO} mkdir -p /var/run/lighttpd
|
mkdir -p /var/run/lighttpd
|
||||||
${SUDO} chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/run/lighttpd
|
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/run/lighttpd
|
||||||
${SUDO} mkdir -p /var/cache/lighttpd/compress
|
mkdir -p /var/cache/lighttpd/compress
|
||||||
${SUDO} chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/compress
|
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/compress
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
#$SUDO service dnsmasq stop & spinner $! || true
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
${SUDO} systemctl stop lighttpd & spinner $! || true
|
systemctl stop lighttpd & spinner $! || true
|
||||||
else
|
else
|
||||||
${SUDO} service lighttpd stop & spinner $! || true
|
service lighttpd stop & spinner $! || true
|
||||||
fi
|
fi
|
||||||
${SUDO} echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
installerDependencies() {
|
installerDependencies() {
|
||||||
|
@ -602,12 +597,12 @@ installerDependencies() {
|
||||||
#update package lists
|
#update package lists
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: $PKG_MANAGER update has not been run today. Running now..."
|
echo -n "::: $PKG_MANAGER update has not been run today. Running now..."
|
||||||
${SUDO} ${UPDATE_PKG_CACHE} > /dev/null 2>&1
|
${UPDATE_PKG_CACHE} > /dev/null 2>&1
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Checking $PKG_MANAGER for upgraded packages...."
|
echo -n "::: Checking $PKG_MANAGER for upgraded packages...."
|
||||||
updatesToInstall=$(eval "${SUDO} ${PKG_COUNT}")
|
updatesToInstall=$(eval "${PKG_COUNT}")
|
||||||
echo " done!"
|
echo " done!"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
if [[ ${updatesToInstall} -eq "0" ]]; then
|
if [[ ${updatesToInstall} -eq "0" ]]; then
|
||||||
|
@ -624,7 +619,7 @@ installerDependencies() {
|
||||||
package_check ${i} > /dev/null
|
package_check ${i} > /dev/null
|
||||||
if ! [ $? -eq 0 ]; then
|
if ! [ $? -eq 0 ]; then
|
||||||
echo -n " Not found! Installing...."
|
echo -n " Not found! Installing...."
|
||||||
${SUDO} ${PKG_INSTALL} "$i" > /dev/null 2>&1
|
${PKG_INSTALL} "$i" > /dev/null 2>&1
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
echo " already installed!"
|
echo " already installed!"
|
||||||
|
@ -641,7 +636,7 @@ checkForDependencies() {
|
||||||
package_check ${i} > /dev/null
|
package_check ${i} > /dev/null
|
||||||
if ! [ $? -eq 0 ]; then
|
if ! [ $? -eq 0 ]; then
|
||||||
echo -n " Not found! Installing...."
|
echo -n " Not found! Installing...."
|
||||||
${SUDO} ${PKG_INSTALL} "$i" > /dev/null & spinner $!
|
${PKG_INSTALL} "$i" > /dev/null & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
echo " already installed!"
|
echo " already installed!"
|
||||||
|
@ -682,8 +677,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!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,7 +686,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" || exit
|
cd "$1" || exit
|
||||||
${SUDO} git pull -q > /dev/null & spinner $!
|
git pull -q > /dev/null & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,59 +694,59 @@ 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
|
||||||
if [ -f /var/www/html/index.lighttpd.html ]; then
|
if [ -f /var/www/html/index.lighttpd.html ]; then
|
||||||
${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
|
||||||
else
|
else
|
||||||
printf "\n:::\tNo default index.lighttpd.html file found... not backing up"
|
printf "\n:::\tNo default index.lighttpd.html file found... not backing up"
|
||||||
fi
|
fi
|
||||||
${SUDO} cp /etc/.pihole/advanced/index.* /var/www/html/pihole/.
|
cp /etc/.pihole/advanced/index.* /var/www/html/pihole/.
|
||||||
${SUDO} echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
# Install Sudoer file
|
# Install Sudoer file
|
||||||
echo -n "::: Installing sudoer file..."
|
echo -n "::: Installing sudoer file..."
|
||||||
${SUDO} mkdir -p /etc/sudoers.d/
|
mkdir -p /etc/sudoers.d/
|
||||||
${SUDO} cp /etc/.pihole/advanced/pihole.sudo /etc/sudoers.d/pihole
|
cp /etc/.pihole/advanced/pihole.sudo /etc/sudoers.d/pihole
|
||||||
${SUDO} chmod 0440 /etc/sudoers.d/pihole
|
chmod 0440 /etc/sudoers.d/pihole
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
echo "::: Running gravity.sh"
|
echo "::: Running gravity.sh"
|
||||||
${SUDO} /opt/pihole/gravity.sh
|
/opt/pihole/gravity.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
setUser(){
|
setUser(){
|
||||||
|
@ -761,41 +756,41 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
configureFirewall() {
|
configureFirewall() {
|
||||||
# Allow HTTP and DNS traffic
|
# Allow HTTP and DNS traffic
|
||||||
if [ -x "$(command -v firewall-cmd)" ]; then
|
if [ -x "$(command -v firewall-cmd)" ]; then
|
||||||
${SUDO} firewall-cmd --state > /dev/null
|
firewall-cmd --state > /dev/null
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
${SUDO} echo "::: Configuring firewalld for httpd and dnsmasq.."
|
echo "::: Configuring firewalld for httpd and dnsmasq.."
|
||||||
${SUDO} firewall-cmd --permanent --add-port=80/tcp
|
firewall-cmd --permanent --add-port=80/tcp
|
||||||
${SUDO} firewall-cmd --permanent --add-port=53/tcp
|
firewall-cmd --permanent --add-port=53/tcp
|
||||||
${SUDO} firewall-cmd --permanent --add-port=53/udp
|
firewall-cmd --permanent --add-port=53/udp
|
||||||
${SUDO} firewall-cmd --reload
|
firewall-cmd --reload
|
||||||
fi
|
fi
|
||||||
elif [ -x "$(command -v iptables)" ]; then
|
elif [ -x "$(command -v iptables)" ]; then
|
||||||
${SUDO} echo "::: Configuring iptables for httpd and dnsmasq.."
|
echo "::: Configuring iptables for httpd and dnsmasq.."
|
||||||
${SUDO} iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
|
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
|
||||||
${SUDO} iptables -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
|
iptables -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
|
||||||
${SUDO} iptables -A INPUT -p udp -m udp --dport 53 -j ACCEPT
|
iptables -A INPUT -p udp -m udp --dport 53 -j ACCEPT
|
||||||
else
|
else
|
||||||
${SUDO} echo "::: No firewall detected.. skipping firewall configuration."
|
echo "::: No firewall detected.. skipping firewall configuration."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
finalExports() {
|
finalExports() {
|
||||||
#If it already exists, lets overwrite it with the new values.
|
#If it already exists, lets overwrite it with the new values.
|
||||||
if [[ -f ${setupVars} ]];then
|
if [[ -f ${setupVars} ]];then
|
||||||
${SUDO} rm ${setupVars}
|
rm ${setupVars}
|
||||||
fi
|
fi
|
||||||
${SUDO} echo "piholeInterface=${piholeInterface}" >> ${setupVars}
|
echo "piholeInterface=${piholeInterface}" >> ${setupVars}
|
||||||
${SUDO} echo "IPv4addr=${IPv4addr}" >> ${setupVars}
|
echo "IPv4addr=${IPv4addr}" >> ${setupVars}
|
||||||
${SUDO} echo "piholeIPv6=${piholeIPv6}" >> ${setupVars}
|
echo "piholeIPv6=${piholeIPv6}" >> ${setupVars}
|
||||||
${SUDO} echo "piholeDNS1=${piholeDNS1}" >> ${setupVars}
|
echo "piholeDNS1=${piholeDNS1}" >> ${setupVars}
|
||||||
${SUDO} echo "piholeDNS2=${piholeDNS2}" >> ${setupVars}
|
echo "piholeDNS2=${piholeDNS2}" >> ${setupVars}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -805,13 +800,13 @@ installPihole() {
|
||||||
stopServices
|
stopServices
|
||||||
setUser
|
setUser
|
||||||
if [ ! -d "/var/www/html" ]; then
|
if [ ! -d "/var/www/html" ]; then
|
||||||
${SUDO} mkdir -p /var/www/html
|
mkdir -p /var/www/html
|
||||||
fi
|
fi
|
||||||
${SUDO} chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/www/html
|
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/www/html
|
||||||
${SUDO} chmod 775 /var/www/html
|
chmod 775 /var/www/html
|
||||||
${SUDO} usermod -a -G ${LIGHTTPD_GROUP} pihole
|
usermod -a -G ${LIGHTTPD_GROUP} pihole
|
||||||
if [ -x "$(command -v lighty-enable-mod)" ]; then
|
if [ -x "$(command -v lighty-enable-mod)" ]; then
|
||||||
${SUDO} lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
||||||
else
|
else
|
||||||
printf "\n:::\tWarning: 'lighty-enable-mod' utility not found. Please ensure fastcgi is enabled if you experience issues.\n"
|
printf "\n:::\tWarning: 'lighty-enable-mod' utility not found. Please ensure fastcgi is enabled if you experience issues.\n"
|
||||||
fi
|
fi
|
||||||
|
@ -823,9 +818,9 @@ installPihole() {
|
||||||
configureSelinux
|
configureSelinux
|
||||||
installPiholeWeb
|
installPiholeWeb
|
||||||
installCron
|
installCron
|
||||||
runGravity
|
|
||||||
configureFirewall
|
configureFirewall
|
||||||
finalExports
|
finalExports
|
||||||
|
runGravity
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePihole() {
|
updatePihole() {
|
||||||
|
@ -839,8 +834,8 @@ updatePihole() {
|
||||||
configureSelinux
|
configureSelinux
|
||||||
installPiholeWeb
|
installPiholeWeb
|
||||||
installCron
|
installCron
|
||||||
runGravity
|
|
||||||
configureFirewall
|
configureFirewall
|
||||||
|
runGravity
|
||||||
}
|
}
|
||||||
|
|
||||||
configureSelinux() {
|
configureSelinux() {
|
||||||
|
@ -850,22 +845,22 @@ configureSelinux() {
|
||||||
package_check "selinux-policy-devel" > /dev/null
|
package_check "selinux-policy-devel" > /dev/null
|
||||||
if ! [ $? -eq 0 ]; then
|
if ! [ $? -eq 0 ]; then
|
||||||
echo -n " Not found! Installing...."
|
echo -n " Not found! Installing...."
|
||||||
${SUDO} ${PKG_INSTALL} "selinux-policy-devel" > /dev/null & spinner $!
|
${PKG_INSTALL} "selinux-policy-devel" > /dev/null & spinner $!
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
echo " already installed!"
|
echo " already installed!"
|
||||||
fi
|
fi
|
||||||
printf "::: Enabling httpd server side includes (SSI).. "
|
printf "::: Enabling httpd server side includes (SSI).. "
|
||||||
${SUDO} setsebool -P httpd_ssi_exec on
|
setsebool -P httpd_ssi_exec on
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo -n "Success"
|
echo -n "Success"
|
||||||
fi
|
fi
|
||||||
printf "\n:::\tCompiling Pi-Hole SELinux policy..\n"
|
printf "\n:::\tCompiling Pi-Hole SELinux policy..\n"
|
||||||
${SUDO} checkmodule -M -m -o /etc/pihole/pihole.mod /etc/.pihole/advanced/selinux/pihole.te
|
checkmodule -M -m -o /etc/pihole/pihole.mod /etc/.pihole/advanced/selinux/pihole.te
|
||||||
${SUDO} semodule_package -o /etc/pihole/pihole.pp -m /etc/pihole/pihole.mod
|
semodule_package -o /etc/pihole/pihole.pp -m /etc/pihole/pihole.mod
|
||||||
${SUDO} semodule -i /etc/pihole/pihole.pp
|
semodule -i /etc/pihole/pihole.pp
|
||||||
${SUDO} rm -f /etc/pihole/pihole.mod
|
rm -f /etc/pihole/pihole.mod
|
||||||
${SUDO} semodule -l | grep pihole > /dev/null
|
semodule -l | grep pihole > /dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
printf "::: Successfully installed Pi-Hole SELinux policy\n"
|
printf "::: Successfully installed Pi-Hole SELinux policy\n"
|
||||||
else
|
else
|
||||||
|
@ -912,7 +907,7 @@ updateDialogs(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######## SCRIPT ############
|
main() {
|
||||||
if [[ -f ${setupVars} ]];then
|
if [[ -f ${setupVars} ]];then
|
||||||
. ${setupVars}
|
. ${setupVars}
|
||||||
|
|
||||||
|
@ -926,8 +921,8 @@ fi
|
||||||
|
|
||||||
# Start the installer
|
# Start the installer
|
||||||
# Verify there is enough disk space for the install
|
# Verify there is enough disk space for the install
|
||||||
if [ $1 = "--i_do_not_follow_recommendations" ]; then
|
if [[ $1 = "--i_do_not_follow_recommendations" ]]; then
|
||||||
echo "::: ----i_do_not_follow_recommendations passed to script"
|
echo "::: --i_do_not_follow_recommendations passed to script"
|
||||||
echo "::: skipping free disk space verification!"
|
echo "::: skipping free disk space verification!"
|
||||||
else
|
else
|
||||||
verifyFreeDiskSpace
|
verifyFreeDiskSpace
|
||||||
|
@ -938,7 +933,7 @@ installerDependencies
|
||||||
|
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
welcomeDialogs
|
welcomeDialogs
|
||||||
${SUDO} mkdir -p /etc/pihole/
|
mkdir -p /etc/pihole/
|
||||||
# Find IP used to route to outside world
|
# Find IP used to route to outside world
|
||||||
findIPRoute
|
findIPRoute
|
||||||
# Find interfaces and let the user choose one
|
# Find interfaces and let the user choose one
|
||||||
|
@ -954,7 +949,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 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}
|
||||||
|
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
displayFinalMessage
|
displayFinalMessage
|
||||||
|
@ -963,13 +958,13 @@ fi
|
||||||
echo -n "::: Restarting services..."
|
echo -n "::: Restarting services..."
|
||||||
# Start services
|
# Start services
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
${SUDO} systemctl enable dnsmasq
|
systemctl enable dnsmasq
|
||||||
${SUDO} systemctl restart dnsmasq
|
systemctl restart dnsmasq
|
||||||
${SUDO} systemctl enable lighttpd
|
systemctl enable lighttpd
|
||||||
${SUDO} systemctl start lighttpd
|
systemctl start lighttpd
|
||||||
else
|
else
|
||||||
${SUDO} service dnsmasq restart
|
service dnsmasq restart
|
||||||
${SUDO} service lighttpd start
|
service lighttpd start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " done."
|
echo " done."
|
||||||
|
@ -988,3 +983,6 @@ fi
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: The install log is located at: /etc/pihole/install.log"
|
echo "::: The install log is located at: /etc/pihole/install.log"
|
||||||
echo "::: View the web interface at http://pi.hole/admin or http://${IPv4addr%/*}/admin"
|
echo "::: View the web interface at http://pi.hole/admin or http://${IPv4addr%/*}/admin"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|
Loading…
Reference in a new issue