From a8f0283e93ba8d7dd3ea4cfb6d4361c9523d0d4d Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 10:11:11 +1000 Subject: [PATCH] Update basic-install.sh This hands checking of lighttpd's status over to the existing check_service_active() function. All other checks of service status within the install script are handled by this function. Use of existing function: Avoids duplication of service detection logic. Uses return code to determine status, thereby avoids parsing text to determine status, and reliance on English language locale to determine activity, (which may also be broken on some systems (# 2204) Signed-off-by: Rob Gill --- automated install/basic-install.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 43d4b7c2..fcc66fe1 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2290,15 +2290,13 @@ main() { if [[ "${INSTALL_WEB_SERVER}" == true ]]; then enable_service lighttpd fi - - 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) + # Determin if lighttpd is correctly enabled + if check_service_active "lighttpd"; then + LIGHTTPD_ENABLED=true; + else + LIGHTTPD_ENABLED=false; fi - + # Install and log everything to a file installPihole | tee -a /proc/$$/fd/3 @@ -2327,7 +2325,7 @@ main() { # If the Web server was installed, if [[ "${INSTALL_WEB_SERVER}" == true ]]; then - if [[ "${LIGHTTPD_ENABLED}" == "1" ]]; then + if [[ "${LIGHTTPD_ENABLED}" == true ]]; then start_service lighttpd enable_service lighttpd else