Delete setupVars.conf if user cancels out of install process.

This commit is contained in:
Promofaux 2016-08-21 17:57:11 +01:00
parent af666e2209
commit eb42b894c4
1 changed files with 19 additions and 10 deletions

View File

@ -22,6 +22,7 @@
tmpLog=/tmp/pihole-install.log tmpLog=/tmp/pihole-install.log
instalLogLoc=/etc/pihole/install.log instalLogLoc=/etc/pihole/install.log
setupVars=/etc/pihole/setupVars.conf
webInterfaceGitUrl="https://github.com/pi-hole/AdminLTE.git" webInterfaceGitUrl="https://github.com/pi-hole/AdminLTE.git"
webInterfaceDir="/var/www/html/admin" webInterfaceDir="/var/www/html/admin"
@ -194,10 +195,11 @@ chooseInterface() {
piholeInterface=${desiredInterface} piholeInterface=${desiredInterface}
echo "::: Using interface: $piholeInterface" echo "::: Using interface: $piholeInterface"
echo "${piholeInterface}" > /tmp/piholeINT echo "${piholeInterface}" > /tmp/piholeINT
echo "piholeInterface=${piholeInterface}" >> /etc/pihole/setupVars.conf echo "piholeInterface=${piholeInterface}" >> ${setupVars}
done done
else else
echo "::: Cancel selected, exiting...." echo "::: Cancel selected, exiting...."
${SUDO} rm ${setupVars}
exit 1 exit 1
fi fi
@ -228,7 +230,7 @@ use4andor6() {
if [ ${useIPv4} ] && [ ! ${useIPv6} ]; then if [ ${useIPv4} ] && [ ! ${useIPv6} ]; then
getStaticIPv4Settings getStaticIPv4Settings
setStaticIPv4 setStaticIPv4
${SUDO} echo "IPv4addr=${IPv4addr}" >> /etc/pihole/setupVars.conf ${SUDO} echo "IPv4addr=${IPv4addr}" >> ${setupVars}
echo "::: Using IPv4 on $IPv4addr" echo "::: Using IPv4 on $IPv4addr"
echo "::: IPv6 will NOT be used." echo "::: IPv6 will NOT be used."
fi fi
@ -240,7 +242,7 @@ use4andor6() {
if [ ${useIPv4} ] && [ ${useIPv6} ]; then if [ ${useIPv4} ] && [ ${useIPv6} ]; then
getStaticIPv4Settings getStaticIPv4Settings
setStaticIPv4 setStaticIPv4
${SUDO} echo "IPv4addr=${IPv4addr}" >> /etc/pihole/setupVars.conf ${SUDO} echo "IPv4addr=${IPv4addr}" >> ${setupVars}
useIPv6dialog useIPv6dialog
echo "::: Using IPv4 on $IPv4addr" echo "::: Using IPv4 on $IPv4addr"
echo "::: Using IPv6 on $piholeIPv6" echo "::: Using IPv6 on $piholeIPv6"
@ -248,11 +250,13 @@ use4andor6() {
if [ ! ${useIPv4} ] && [ ! ${useIPv6} ]; then if [ ! ${useIPv4} ] && [ ! ${useIPv6} ]; then
echo "::: Cannot continue, neither IPv4 or IPv6 selected" echo "::: Cannot continue, neither IPv4 or IPv6 selected"
echo "::: Exiting" echo "::: Exiting"
${SUDO} rm ${setupVars}
exit 1 exit 1
fi fi
cleanupIPv6 cleanupIPv6
else else
echo "::: Cancel selected. Exiting..." echo "::: Cancel selected. Exiting..."
${SUDO} rm ${setupVars}
exit 1 exit 1
fi fi
} }
@ -260,7 +264,7 @@ use4andor6() {
useIPv6dialog() { useIPv6dialog() {
# Show the IPv6 address used for blocking # Show the IPv6 address used for blocking
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
${SUDO} echo "piholeIPv6=${piholeIPv6}" >> /etc/pihole/setupVars.conf ${SUDO} echo "piholeIPv6=${piholeIPv6}" >> ${setupVars}
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." ${r} ${c} whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." ${r} ${c}
${SUDO} touch /etc/pihole/.useIPv6 ${SUDO} touch /etc/pihole/.useIPv6
@ -310,12 +314,14 @@ It is also possible to use a DHCP reservation, but if you are going to do that,
# Cancelling gateway settings window # Cancelling gateway settings window
ipSettingsCorrect=False ipSettingsCorrect=False
echo "::: Cancel selected. Exiting..." echo "::: Cancel selected. Exiting..."
${SUDO} rm ${setupVars}
exit 1 exit 1
fi fi
else else
# Cancelling IPv4 settings window # Cancelling IPv4 settings window
ipSettingsCorrect=False ipSettingsCorrect=False
echo "::: Cancel selected. Exiting..." echo "::: Cancel selected. Exiting..."
${SUDO} rm ${setupVars}
exit 1 exit 1
fi fi
done done
@ -373,6 +379,7 @@ setStaticIPv4() {
fi fi
else else
echo "::: Warning: Unable to locate configuration file to set static IPv4 address!" echo "::: Warning: Unable to locate configuration file to set static IPv4 address!"
${SUDO} rm ${setupVars}
exit 1 exit 1
fi fi
} }
@ -457,6 +464,7 @@ setDNS(){
fi fi
else else
echo "::: Cancel selected, exiting...." echo "::: Cancel selected, exiting...."
${SUDO} rm ${setupVars}
exit 1 exit 1
fi fi
if [[ ${piholeDNS1} == "$strInvalid" ]] || [[ ${piholeDNS2} == "$strInvalid" ]]; then if [[ ${piholeDNS1} == "$strInvalid" ]] || [[ ${piholeDNS2} == "$strInvalid" ]]; then
@ -481,11 +489,12 @@ setDNS(){
esac esac
else else
echo "::: Cancel selected. Exiting..." echo "::: Cancel selected. Exiting..."
${SUDO} rm ${setupVars}
exit 1 exit 1
fi fi
${SUDO} echo "piholeDNS1=${piholeDNS1}" >> /etc/pihole/setupVars.conf ${SUDO} echo "piholeDNS1=${piholeDNS1}" >> ${setupVars}
${SUDO} echo "piholeDNS2=${piholeDNS2}" >> /etc/pihole/setupVars.conf ${SUDO} echo "piholeDNS2=${piholeDNS2}" >> ${setupVars}
} }
versionCheckDNSmasq(){ versionCheckDNSmasq(){
@ -928,8 +937,8 @@ updateDialogs(){
} }
######## SCRIPT ############ ######## SCRIPT ############
if [[ -f /etc/pihole/setupVars.conf ]];then if [[ -f ${setupVars} ]];then
. /etc/pihole/setupVars.conf . ${setupVars}
updateDialogs updateDialogs
fi fi
@ -938,11 +947,11 @@ fi
installerDependencies installerDependencies
if [[ ${useUpdateVars} == false ]]; then if [[ ${useUpdateVars} == false ]]; then
${SUDO} echo "" > /etc/pihole/setupVars.conf
${SUDO} mkdir -p /etc/pihole/
welcomeDialogs welcomeDialogs
# Verify there is enough disk space for the install # Verify there is enough disk space for the install
verifyFreeDiskSpace verifyFreeDiskSpace
${SUDO} echo "" > ${setupVars}
${SUDO} 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