mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
remove trailing whitespace basic-install.sh
This commit is contained in:
parent
ced0ae0d65
commit
4452f784a8
1 changed files with 28 additions and 28 deletions
|
@ -111,7 +111,7 @@ welcomeDialogs() {
|
||||||
whiptail --msgbox --backtitle "Plea" --title "Free and open source" "The Pi-hole is free, but powered by your donations: http://pi-hole.net/donate" $r $c
|
whiptail --msgbox --backtitle "Plea" --title "Free and open source" "The Pi-hole is free, but powered by your donations: http://pi-hole.net/donate" $r $c
|
||||||
|
|
||||||
# Explain the need for a static address
|
# Explain the need for a static address
|
||||||
whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed" "The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
|
whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed" "The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
|
||||||
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c
|
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,12 +119,12 @@ welcomeDialogs() {
|
||||||
verifyFreeDiskSpace() {
|
verifyFreeDiskSpace() {
|
||||||
# 25MB is the minimum space needed (20MB install + 5MB one day of logs.)
|
# 25MB is the minimum space needed (20MB install + 5MB one day of logs.)
|
||||||
requiredFreeBytes=51200
|
requiredFreeBytes=51200
|
||||||
|
|
||||||
existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1`
|
existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1`
|
||||||
if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then
|
if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then
|
||||||
existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1`
|
existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then
|
if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then
|
||||||
whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c
|
whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c
|
||||||
echo "$existingFreeBytes is less than $requiredFreeBytes"
|
echo "$existingFreeBytes is less than $requiredFreeBytes"
|
||||||
|
@ -164,7 +164,7 @@ chooseInterface() {
|
||||||
echo "::: Cancel selected, exiting...."
|
echo "::: Cancel selected, exiting...."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupIPv6() {
|
cleanupIPv6() {
|
||||||
|
@ -188,7 +188,7 @@ use4andor6() {
|
||||||
IPv6 ) useIPv6=true;;
|
IPv6 ) useIPv6=true;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $useIPv4 ] && [ ! $useIPv6 ]; then
|
if [ $useIPv4 ] && [ ! $useIPv6 ]; then
|
||||||
getStaticIPv4Settings
|
getStaticIPv4Settings
|
||||||
setStaticIPv4
|
setStaticIPv4
|
||||||
|
@ -308,7 +308,7 @@ function valid_ip()
|
||||||
{
|
{
|
||||||
local ip=$1
|
local ip=$1
|
||||||
local stat=1
|
local stat=1
|
||||||
|
|
||||||
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||||
OIFS=$IFS
|
OIFS=$IFS
|
||||||
IFS='.'
|
IFS='.'
|
||||||
|
@ -360,9 +360,9 @@ setDNS(){
|
||||||
Custom)
|
Custom)
|
||||||
until [[ $DNSSettingsCorrect = True ]]
|
until [[ $DNSSettingsCorrect = True ]]
|
||||||
do
|
do
|
||||||
|
|
||||||
strInvalid="Invalid"
|
strInvalid="Invalid"
|
||||||
|
|
||||||
if [ ! $piholeDNS1 ]; then
|
if [ ! $piholeDNS1 ]; then
|
||||||
if [ ! $piholeDNS2 ]; then
|
if [ ! $piholeDNS2 ]; then
|
||||||
prePopulate=""
|
prePopulate=""
|
||||||
|
@ -374,38 +374,38 @@ setDNS(){
|
||||||
elif [ $piholeDNS1 ] && [ $piholeDNS2 ]; then
|
elif [ $piholeDNS1 ] && [ $piholeDNS2 ]; then
|
||||||
prePopulate="$piholeDNS1, $piholeDNS2"
|
prePopulate="$piholeDNS1, $piholeDNS2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\n\nFor example '8.8.8.8, 8.8.4.4'" $r $c "$prePopulate" 3>&1 1>&2 2>&3)
|
piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\n\nFor example '8.8.8.8, 8.8.4.4'" $r $c "$prePopulate" 3>&1 1>&2 2>&3)
|
||||||
if [[ $? = 0 ]];then
|
if [[ $? = 0 ]];then
|
||||||
piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}')
|
piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}')
|
||||||
piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}')
|
piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}')
|
||||||
|
|
||||||
if ! valid_ip $piholeDNS1 || [ ! $piholeDNS1 ]; then
|
if ! valid_ip $piholeDNS1 || [ ! $piholeDNS1 ]; then
|
||||||
piholeDNS1=$strInvalid
|
piholeDNS1=$strInvalid
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! valid_ip $piholeDNS2 && [ $piholeDNS2 ]; then
|
if ! valid_ip $piholeDNS2 && [ $piholeDNS2 ]; then
|
||||||
piholeDNS2=$strInvalid
|
piholeDNS2=$strInvalid
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "::: Cancel selected, exiting...."
|
echo "::: Cancel selected, exiting...."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $piholeDNS1 == $strInvalid ]] || [[ $piholeDNS2 == $strInvalid ]]; then
|
if [[ $piholeDNS1 == $strInvalid ]] || [[ $piholeDNS2 == $strInvalid ]]; then
|
||||||
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c
|
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c
|
||||||
|
|
||||||
if [[ $piholeDNS1 == $strInvalid ]]; then
|
if [[ $piholeDNS1 == $strInvalid ]]; then
|
||||||
piholeDNS1=""
|
piholeDNS1=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $piholeDNS2 == $strInvalid ]]; then
|
if [[ $piholeDNS2 == $strInvalid ]]; then
|
||||||
piholeDNS2=""
|
piholeDNS2=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DNSSettingsCorrect=False
|
DNSSettingsCorrect=False
|
||||||
else
|
else
|
||||||
if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then
|
if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then
|
||||||
DNSSettingsCorrect=True
|
DNSSettingsCorrect=True
|
||||||
else
|
else
|
||||||
|
@ -427,11 +427,11 @@ versionCheckDNSmasq(){
|
||||||
dnsFile1="/etc/dnsmasq.conf"
|
dnsFile1="/etc/dnsmasq.conf"
|
||||||
dnsFile2="/etc/dnsmasq.conf.orig"
|
dnsFile2="/etc/dnsmasq.conf.orig"
|
||||||
dnsSearch="addn-hosts=/etc/pihole/gravity.list"
|
dnsSearch="addn-hosts=/etc/pihole/gravity.list"
|
||||||
|
|
||||||
defaultFile="/etc/.pihole/advanced/dnsmasq.conf.original"
|
defaultFile="/etc/.pihole/advanced/dnsmasq.conf.original"
|
||||||
newFileToInstall="/etc/.pihole/advanced/01-pihole.conf"
|
newFileToInstall="/etc/.pihole/advanced/01-pihole.conf"
|
||||||
newFileFinalLocation="/etc/dnsmasq.d/01-pihole.conf"
|
newFileFinalLocation="/etc/dnsmasq.d/01-pihole.conf"
|
||||||
|
|
||||||
if [ -f $dnsFile1 ]; then
|
if [ -f $dnsFile1 ]; then
|
||||||
echo -n "::: Existing dnsmasq.conf found..."
|
echo -n "::: Existing dnsmasq.conf found..."
|
||||||
if grep -q $dnsSearch $dnsFile1; then
|
if grep -q $dnsSearch $dnsFile1; then
|
||||||
|
@ -443,14 +443,14 @@ versionCheckDNSmasq(){
|
||||||
$SUDO cp $defaultFile $dnsFile1
|
$SUDO 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
|
$SUDO 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
|
$SUDO cp $newFileToInstall $newFileFinalLocation
|
||||||
echo " done."
|
echo " done."
|
||||||
|
@ -635,9 +635,9 @@ installCron() {
|
||||||
runGravity() {
|
runGravity() {
|
||||||
# Rub gravity.sh to build blacklists
|
# Rub gravity.sh to build blacklists
|
||||||
$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)"
|
||||||
$SUDO rm /etc/pihole/list.*
|
$SUDO rm /etc/pihole/list.*
|
||||||
fi
|
fi
|
||||||
#Don't run as SUDO, this was causing issues
|
#Don't run as SUDO, this was causing issues
|
||||||
|
@ -661,7 +661,7 @@ setUser(){
|
||||||
setPassword() {
|
setPassword() {
|
||||||
# Password needed to authorize changes to lists from admin page
|
# Password needed to authorize changes to lists from admin page
|
||||||
pass=$(whiptail --passwordbox "Please enter a password to secure your Pi-hole web interface." 10 50 3>&1 1>&2 2>&3)
|
pass=$(whiptail --passwordbox "Please enter a password to secure your Pi-hole web interface." 10 50 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
# Entered password
|
# Entered password
|
||||||
echo $pass > /etc/pihole/password.txt
|
echo $pass > /etc/pihole/password.txt
|
||||||
|
|
Loading…
Reference in a new issue