From 360807791fcd52e503418f243d595338343b872a Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Tue, 31 Jul 2018 11:10:54 +0100
Subject: [PATCH] Use a file to indicate that the setup screen is active

---
 src/freedombone-installer      |  5 +++++
 src/freedombone-utils-webadmin | 12 ++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/freedombone-installer b/src/freedombone-installer
index e3d3d3c43..4d922223b 100755
--- a/src/freedombone-installer
+++ b/src/freedombone-installer
@@ -118,6 +118,11 @@ do
                 # remove the setup file created by setup.php
                 rm "$setup_file"
 
+                # remove the file which indicates that the setup screen is active
+                if [ -f "$webadmin_install_dir/.setupscreenactive" ]; then
+                    rm "$webadmin_install_dir/.setupscreenactive"
+                fi
+
                 # restart the web server
                 systemctl restart nginx
             fi
diff --git a/src/freedombone-utils-webadmin b/src/freedombone-utils-webadmin
index 6eb460819..628b154c0 100755
--- a/src/freedombone-utils-webadmin
+++ b/src/freedombone-utils-webadmin
@@ -459,6 +459,12 @@ function web_admin_setup_login {
 
     # if an nginx password file has not been created for web admin
     if [ ! -f /etc/nginx/.webadminpasswd ]; then
+        # this file indicates that the setup screen is active
+        # and gets removed by freedombone-installer
+        if [ ! -f "$webadmin_install_dir/.setupscreenactive" ]; then
+            touch "$webadmin_install_dir/.setupscreenactive"
+        fi
+
         webadmin_password="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
 
         # create a password for users
@@ -509,8 +515,10 @@ function install_web_admin {
     if grep -q 'install_final' "$COMPLETION_FILE"; then
         # initial installation has completed
         if [ -f /etc/nginx/.webadminpasswd ]; then
-            # a password was created
-            basic_auth_str='auth_basic'
+            if [ ! -f "$webadmin_install_dir/.setupscreenactive" ]; then
+                # a password was created
+                basic_auth_str='auth_basic'
+            fi
         fi
     fi
 
-- 
GitLab