From 179847192ad4016fc15d77fb005c98a03a341edc Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Wed, 1 Aug 2018 18:27:10 +0100
Subject: [PATCH] Create copy of index page after copying webadmin files

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

diff --git a/src/freedombone-installer b/src/freedombone-installer
index 96e1d060d..cbdd3c799 100755
--- a/src/freedombone-installer
+++ b/src/freedombone-installer
@@ -128,7 +128,7 @@ do
                 fi
 
                 # set permissions for web admin site at freedombone.local
-                chown www-data:www-data "$webadmin_install_dir/index.html"
+                chown www-data:www-data "$webadmin_install_dir/*.html"
 
                 # remove the setup file created by setup.php
                 rm "$setup_file"
diff --git a/src/freedombone-utils-webadmin b/src/freedombone-utils-webadmin
index 7f0819b7e..113f55d07 100755
--- a/src/freedombone-utils-webadmin
+++ b/src/freedombone-utils-webadmin
@@ -538,7 +538,6 @@ function web_admin_setup_login {
 
     # create a setup page with the initial password inserted
     # and copy it to the index
-    cp "$webadmin_install_dir"/index.html "$webadmin_install_dir"/index.prev
     cp "$webadmin_install_dir"/setup.html "$webadmin_install_dir"/setup.prev
     cp "$webadmin_install_dir"/setup_confirm_template.html "$webadmin_install_dir"/setup_confirm.html
     sed -i "s|WEBADMINPASSWORD|${webadmin_password}|g" "$webadmin_install_dir/setup.prev"
@@ -584,9 +583,13 @@ function install_web_admin {
             cp -r "/usr/share/${PROJECT_NAME}/webadmin"/* "$webadmin_install_dir"
             cp "/usr/share/${PROJECT_NAME}/webadmin/${language_subdir}"/*.html "$webadmin_install_dir"
 
-            if [ -f "$webadmin_install_dir/setup.prev" ]; then
-                # We are still waiting for initial setup to happen
-                cp "$webadmin_install_dir"/setup.prev "$webadmin_install_dir"/index.html
+            cp "$webadmin_install_dir"/index.html "$webadmin_install_dir"/index.prev
+
+            if [ -f "$webadmin_install_dir/.setupscreenactive" ]; then
+                if [ -f "$webadmin_install_dir/setup.prev" ]; then
+                    # We are still waiting for initial setup to happen
+                    cp "$webadmin_install_dir"/setup.prev "$webadmin_install_dir"/index.html
+                fi
             fi
 
             # if this is an onion only install then modify some php scripts
-- 
GitLab