use the web install flag. Could be optimised

This commit is contained in:
Promofaux 2017-01-28 15:25:02 +00:00
parent dfdb9e393b
commit f8322cc2d4
1 changed files with 39 additions and 23 deletions

View File

@ -994,7 +994,9 @@ installPihole() {
installScripts installScripts
installConfigs installConfigs
CreateLogFile CreateLogFile
installPiholeWeb if [[ ${INSTALL_WEB} == true ]]; then
installPiholeWeb
fi
installCron installCron
installLogrotate installLogrotate
configureFirewall configureFirewall
@ -1025,7 +1027,9 @@ updatePihole() {
installScripts installScripts
installConfigs installConfigs
CreateLogFile CreateLogFile
installPiholeWeb if [[ ${INSTALL_WEB} == true ]]; then
installPiholeWeb
fi
installCron installCron
installLogrotate installLogrotate
finalExports #re-export setupVars.conf to account for any new vars added in new versions finalExports #re-export setupVars.conf to account for any new vars added in new versions
@ -1188,7 +1192,9 @@ main() {
mkdir -p /etc/pihole/ mkdir -p /etc/pihole/
# Stop resolver and webserver while installing proceses # Stop resolver and webserver while installing proceses
stop_service dnsmasq stop_service dnsmasq
stop_service lighttpd if [[ ${INSTALL_WEB} == true ]]; then
stop_service lighttpd
fi
# Determine available interfaces # Determine available interfaces
get_available_interfaces get_available_interfaces
# Find interfaces and let the user choose one # Find interfaces and let the user choose one
@ -1227,25 +1233,31 @@ main() {
# Move the log file into /etc/pihole for storage # Move the log file into /etc/pihole for storage
mv ${tmpLog} ${instalLogLoc} mv ${tmpLog} ${instalLogLoc}
# Add password to web UI if there is none if [[ ${INSTALL_WEB} == true ]]; then
pw="" # Add password to web UI if there is none
if [[ $(grep 'WEBPASSWORD' -c /etc/pihole/setupVars.conf) == 0 ]] ; then pw=""
pw=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8) if [[ $(grep 'WEBPASSWORD' -c /etc/pihole/setupVars.conf) == 0 ]] ; then
/usr/local/bin/pihole -a -p "${pw}" pw=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8)
fi /usr/local/bin/pihole -a -p "${pw}"
fi
if [[ "${useUpdateVars}" == false ]]; then
displayFinalMessage "${pw}"
fi fi
echo "::: Restarting services..." echo "::: Restarting services..."
# Start services # Start services
start_service dnsmasq start_service dnsmasq
enable_service dnsmasq enable_service dnsmasq
start_service lighttpd
enable_service lighttpd if [[ ${INSTALL_WEB} == true ]]; then
start_service lighttpd
enable_service lighttpd
fi
echo "::: done." echo "::: done."
if [[ "${useUpdateVars}" == false ]]; then
displayFinalMessage "${pw}"
fi
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:"
@ -1253,19 +1265,23 @@ main() {
echo "::: ${IPV6_ADDRESS}" echo "::: ${IPV6_ADDRESS}"
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."
echo "::: View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin" if [[ ${INSTALL_WEB} == true ]]; then
echo "::: View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin"
fi
else else
echo "::: Update complete!" echo "::: Update complete!"
fi fi
if (( ${#pw} > 0 )) ; then if [[ ${INSTALL_WEB} == true ]]; then
echo ":::" if (( ${#pw} > 0 )) ; then
echo "::: Note: As security measure a password has been installed for your web interface" echo ":::"
echo "::: The currently set password is" echo "::: Note: As security measure a password has been installed for your web interface"
echo "::: ${pw}" echo "::: The currently set password is"
echo ":::" echo "::: ${pw}"
echo "::: You can always change it using" echo ":::"
echo "::: pihole -a -p new_password" echo "::: You can always change it using"
echo "::: pihole -a -p new_password"
fi
fi fi
echo ":::" echo ":::"