mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-03 19:43:17 +00:00
Wrap script in main()
- prepare for no more sudo
This commit is contained in:
parent
10ad32de9b
commit
962d162d75
1 changed files with 68 additions and 64 deletions
|
@ -909,78 +909,82 @@ updateDialogs(){
|
||||||
}
|
}
|
||||||
|
|
||||||
######## MAIN MAIN MAIN ########
|
######## MAIN MAIN MAIN ########
|
||||||
if [[ -f ${setupVars} ]];then
|
main () {
|
||||||
. ${setupVars}
|
if [[ -f ${setupVars} ]];then
|
||||||
|
. ${setupVars}
|
||||||
|
|
||||||
if [ "$1" == "pihole" ]; then
|
if [ "$1" == "pihole" ]; then
|
||||||
useUpdateVars=true
|
useUpdateVars=true
|
||||||
else
|
else
|
||||||
updateDialogs
|
updateDialogs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
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
|
||||||
verify_free_disk_space
|
verify_free_disk_space
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install packages used by this installation script
|
# Install packages used by this installation script
|
||||||
installer_dependencies
|
installer_dependencies
|
||||||
|
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
welcome_dialogs
|
welcome_dialogs
|
||||||
${SUDO} mkdir -p /etc/pihole/
|
${SUDO} mkdir -p /etc/pihole/
|
||||||
# Find IP used to route to outside world
|
# Find IP used to route to outside world
|
||||||
find_IPv4_route
|
find_IPv4_route
|
||||||
# Find interfaces and let the user choose one
|
# Find interfaces and let the user choose one
|
||||||
choose_interface
|
choose_interface
|
||||||
# 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
|
||||||
use_IPv4_and_or_IPv6
|
use_IPv4_and_or_IPv6
|
||||||
# Decide what upstream DNS Servers to use
|
# Decide what upstream DNS Servers to use
|
||||||
set_upstream_dns
|
set_upstream_dns
|
||||||
# Install and log everything to a file
|
# Install and log everything to a file
|
||||||
install | tee ${tmpLog}
|
install | tee ${tmpLog}
|
||||||
else
|
else
|
||||||
update | tee ${tmpLog}
|
update | tee ${tmpLog}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Move the log file into /etc/pihole for storage
|
# Move the log file into /etc/pihole for storage
|
||||||
${SUDO} mv ${tmpLog} ${instalLogLoc}
|
${SUDO} mv ${tmpLog} ${instalLogLoc}
|
||||||
|
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
displayFinalMessage
|
displayFinalMessage
|
||||||
fi
|
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
|
${SUDO} systemctl enable dnsmasq
|
||||||
${SUDO} systemctl restart dnsmasq
|
${SUDO} systemctl restart dnsmasq
|
||||||
${SUDO} systemctl enable lighttpd
|
${SUDO} systemctl enable lighttpd
|
||||||
${SUDO} systemctl start lighttpd
|
${SUDO} systemctl start lighttpd
|
||||||
else
|
else
|
||||||
${SUDO} service dnsmasq restart
|
${SUDO} service dnsmasq restart
|
||||||
${SUDO} service lighttpd start
|
${SUDO} service lighttpd start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " done."
|
echo " done."
|
||||||
|
|
||||||
echo ":::"
|
echo ":::"
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
echo "::: Installation Complete! Configure your devices to use the Pi-hole as their DNS server using:"
|
echo "::: Installation Complete! Configure your devices to use the Pi-hole as their DNS server using:"
|
||||||
echo "::: ${IPv4addr%/*}"
|
echo "::: ${IPv4addr%/*}"
|
||||||
echo "::: $IPv6addr"
|
echo "::: $IPv6addr"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: If you set a new IP address, you should restart the Pi."
|
echo "::: If you set a new IP address, you should restart the Pi."
|
||||||
else
|
else
|
||||||
echo "::: Update complete!"
|
echo "::: Update complete!"
|
||||||
fi
|
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