Avoid reactivating a deactivated lighttpd service (#1485)

* Do not activate disabled lighttpd upon update

* Fixes #1362

* Use systemctl when available

* Move `finalexports` to the very end of the install script
set value of LIGHTTPD_ENABLED to 1 or 0 depending on whether or not lighttpd is enabled or disabled.
actually save LIGHTTPD_ENABLED value to setupvars.conf

Signed-off-by: Adam Warner <adamw@rner.email>

* add [[ -z "${LIGHTTPD_ENABLED}" ]] back in!

Signed-off-by: Adam Warner <adamw@rner.email>

* Ensure "Loaded:" is the line being checked

* Colourise disabled lighttpd message

* Prevent disabled lighttpd triggering error

* change of plan, don't need that [[ -z "${LIGHTTPD_ENABLED}" ]]

Signed-off-by: Adam Warner <adamw@rner.email>
This commit is contained in:
WaLLy3K 2017-07-17 01:44:14 +10:00 committed by Adam Warner
parent 3a50b91722
commit c9a98b68c8

View file

@ -1485,8 +1485,7 @@ finalExports() {
# If the setup variable file exists, # If the setup variable file exists,
if [ -e "${setupVars}" ]; then if [ -e "${setupVars}" ]; then
# update the variables in the file sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;/INSTALL_WEB/d;/LIGHTTPD_ENABLED/d;' "${setupVars}"
sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;/INSTALL_WEB/d;' "${setupVars}"
fi fi
# echo the information to the user # echo the information to the user
{ {
@ -1497,6 +1496,7 @@ finalExports() {
echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}" echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}"
echo "QUERY_LOGGING=${QUERY_LOGGING}" echo "QUERY_LOGGING=${QUERY_LOGGING}"
echo "INSTALL_WEB=${INSTALL_WEB}" echo "INSTALL_WEB=${INSTALL_WEB}"
echo "LIGHTTPD_ENABLED=${LIGHTTPD_ENABLED}"
}>> "${setupVars}" }>> "${setupVars}"
# Look for DNS server settings which would have to be reapplied # Look for DNS server settings which would have to be reapplied
@ -1585,9 +1585,6 @@ installPihole() {
FTLdetect || echo -e " ${CROSS} FTL Engine not installed." FTLdetect || echo -e " ${CROSS} FTL Engine not installed."
# Configure the firewall # Configure the firewall
configureFirewall configureFirewall
# Run the final exports
finalExports
#runGravity
} }
# At some point in the future this list can be pruned, for now we'll need it to ensure updates don't break. # At some point in the future this list can be pruned, for now we'll need it to ensure updates don't break.
@ -1621,8 +1618,8 @@ updatePihole() {
installLogrotate installLogrotate
# Detect if FTL is installed # Detect if FTL is installed
FTLdetect || echo -e " ${CROSS} FTL Engine not installed." FTLdetect || echo -e " ${CROSS} FTL Engine not installed."
finalExports #re-export setupVars.conf to account for any new vars added in new versions
#runGravity
} }
@ -2052,10 +2049,24 @@ main() {
enable_service dnsmasq enable_service dnsmasq
# If the Web server was installed, # If the Web server was installed,
if [[ ${INSTALL_WEB} == true ]]; then if [[ "${INSTALL_WEB}" == true ]]; then
# enable it # Check to see if lighttpd was already set to run on reboot
start_service lighttpd if [[ "${useUpdateVars}" == true ]]; then
enable_service lighttpd if [[ -x "$(command -v systemctl)" ]]; then
# Value will either be 1, if true, or 0
LIGHTTPD_ENABLED=$(systemctl is-enabled lighttpd | grep -c 'enabled' || true)
else
# Value will either be 1, if true, or 0
LIGHTTPD_ENABLED=$(service lighttpd status | awk '/Loaded:/ {print $0}' | grep -c 'enabled' || true)
fi
fi
if [[ "${LIGHTTPD_ENABLED}" == "1" ]]; then
start_service lighttpd
enable_service lighttpd
else
echo -e " ${INFO} Lighttpd is disabled, skipping service restart"
fi
fi fi
# Download and compile the aggregated block list # Download and compile the aggregated block list
@ -2103,6 +2114,8 @@ main() {
# Display where the log file is # Display where the log file is
echo -e "\n ${INFO} The install log is located at: /etc/pihole/install.log echo -e "\n ${INFO} The install log is located at: /etc/pihole/install.log
${COL_LIGHT_GREEN}${INSTALL_TYPE} Complete! ${COL_NC}" ${COL_LIGHT_GREEN}${INSTALL_TYPE} Complete! ${COL_NC}"
#update setupvars.conf with any variables that may or may not have been changed during the install
finalExports
} }
# #