Fixes #154 #269. No need for PR #214 any more.

This commit is contained in:
Promofaux 2016-01-31 20:39:12 +00:00
parent 442b7b4c4d
commit 29e0e1760b

View file

@ -90,7 +90,7 @@ spinner() {
backupLegacyPihole() { backupLegacyPihole() {
# This function detects and backups the pi-hole v1 files. It will not do anything to the current version files. # This function detects and backups the pi-hole v1 files. It will not do anything to the current version files.
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")
@ -134,13 +134,18 @@ chooseInterface() {
interfaceCount=$(echo "$availableInterfaces" | wc -l) interfaceCount=$(echo "$availableInterfaces" | wc -l)
chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface" $r $c $interfaceCount) chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface" $r $c $interfaceCount)
chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty) chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty)
if [[ $? = 0 ]];then
for desiredInterface in $chooseInterfaceOptions for desiredInterface in $chooseInterfaceOptions
do do
piholeInterface=$desiredInterface piholeInterface=$desiredInterface
echo "::: Using interface: $piholeInterface" echo "::: Using interface: $piholeInterface"
echo ${piholeInterface} > /tmp/piholeINT echo ${piholeInterface} > /tmp/piholeINT
done done
else
echo "::: Cancel selected, exiting...."
exit 1
fi
} }
@ -150,34 +155,40 @@ use4andor6() {
options=(IPv4 "Block ads over IPv4" on options=(IPv4 "Block ads over IPv4" on
IPv6 "Block ads over IPv6" off) IPv6 "Block ads over IPv6" off)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
for choice in $choices if [[ $? = 0 ]];then
do for choice in $choices
case $choice in do
IPv4 ) useIPv4=true;; case $choice in
IPv6 ) useIPv6=true;; IPv4 ) useIPv4=true;;
esac IPv6 ) useIPv6=true;;
done esac
if [ $useIPv4 ] && [ ! $useIPv6 ]; then done
getStaticIPv4Settings
setStaticIPv4 if [ $useIPv4 ] && [ ! $useIPv6 ]; then
echo "::: Using IPv4 on $IPv4addr" getStaticIPv4Settings
echo "::: IPv6 will NOT be used." setStaticIPv4
fi echo "::: Using IPv4 on $IPv4addr"
if [ ! $useIPv4 ] && [ $useIPv6 ]; then echo "::: IPv6 will NOT be used."
useIPv6dialog fi
echo "::: IPv4 will NOT be used." if [ ! $useIPv4 ] && [ $useIPv6 ]; then
echo "::: Using IPv6 on $piholeIPv6" useIPv6dialog
fi echo "::: IPv4 will NOT be used."
if [ $useIPv4 ] && [ $useIPv6 ]; then echo "::: Using IPv6 on $piholeIPv6"
getStaticIPv4Settings fi
setStaticIPv4 if [ $useIPv4 ] && [ $useIPv6 ]; then
useIPv6dialog getStaticIPv4Settings
echo "::: Using IPv4 on $IPv4addr" setStaticIPv4
echo "::: Using IPv6 on $piholeIPv6" useIPv6dialog
fi echo "::: Using IPv4 on $IPv4addr"
if [ ! $useIPv4 ] && [ ! $useIPv6 ]; then echo "::: Using IPv6 on $piholeIPv6"
echo "::: Cannot continue, neither IPv4 or IPv6 selected" fi
echo "::: Exiting" if [ ! $useIPv4 ] && [ ! $useIPv6 ]; then
echo "::: Cannot continue, neither IPv4 or IPv6 selected"
echo "::: Exiting"
exit 1
fi
else
echo "::: Cancel selected. Exiting..."
exit 1 exit 1
fi fi
} }
@ -209,11 +220,11 @@ getStaticIPv4Settings() {
# Ask for the IPv4 address # Ask for the IPv4 address
IPv4addr=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 address" --inputbox "Enter your desired IPv4 address" $r $c $IPv4addr 3>&1 1>&2 2>&3) IPv4addr=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 address" --inputbox "Enter your desired IPv4 address" $r $c $IPv4addr 3>&1 1>&2 2>&3)
if [[ $? = 0 ]];then if [[ $? = 0 ]];then
echo "Your static IPv4 address: $IPv4addr" echo "::: Your static IPv4 address: $IPv4addr"
# Ask for the gateway # Ask for the gateway
IPv4gw=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 gateway (router)" --inputbox "Enter your desired IPv4 default gateway" $r $c $IPv4gw 3>&1 1>&2 2>&3) IPv4gw=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 gateway (router)" --inputbox "Enter your desired IPv4 default gateway" $r $c $IPv4gw 3>&1 1>&2 2>&3)
if [[ $? = 0 ]];then if [[ $? = 0 ]];then
echo "Your static IPv4 gateway: $IPv4gw" echo "::: Your static IPv4 gateway: $IPv4gw"
# Give the user a chance to review their settings before moving on # Give the user a chance to review their settings before moving on
if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Are these settings correct? if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Are these settings correct?
IP address: $IPv4addr IP address: $IPv4addr
@ -231,14 +242,14 @@ getStaticIPv4Settings() {
else else
# Cancelling gateway settings window # Cancelling gateway settings window
ipSettingsCorrect=False ipSettingsCorrect=False
echo "User canceled." echo "::: Cancel selected. Exiting..."
exit exit 1
fi fi
else else
# Cancelling IPv4 settings window # Cancelling IPv4 settings window
ipSettingsCorrect=False ipSettingsCorrect=False
echo "User canceled." echo "::: Cancel selected. Exiting..."
exit exit 1
fi fi
done done
# End the if statement for DHCP vs. static # End the if statement for DHCP vs. static
@ -247,7 +258,7 @@ getStaticIPv4Settings() {
setDHCPCD() { setDHCPCD() {
# Append these lines to dhcpcd.conf to enable a static IP # Append these lines to dhcpcd.conf to enable a static IP
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" | $SUDO tee -a $dhcpcdFile >/dev/null
@ -272,19 +283,23 @@ setDNS(){
DNSChooseOptions=(Google "Use Google's DNS Servers" on DNSChooseOptions=(Google "Use Google's DNS Servers" on
DynDNS "Use DynDNS's DNS Servers" off) DynDNS "Use DynDNS's DNS Servers" off)
DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty)
if [[ $? = 0 ]];then
case $DNSchoices in case $DNSchoices in
Google) Google)
echo "Google selected." echo "::: Using Google DNS servers."
piholeDNS1="8.8.8.8" piholeDNS1="8.8.8.8"
piholeDNS2="8.8.4.4" piholeDNS2="8.8.4.4"
;; ;;
DynDNS) DynDNS)
echo "DynDNS selected." echo "::: Using DynDNS servers."
piholeDNS1="208.67.222.222" piholeDNS1="208.67.222.222"
piholeDNS2="208.67.220.220" piholeDNS2="208.67.220.220"
;; ;;
esac esac
else
echo "::: Cancel selected. Exiting..."
exit 1
fi
} }
versionCheckDNSmasq(){ versionCheckDNSmasq(){