From a59f0889fd66ef9c46b3c49a446346a89a087e4f Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Tue, 31 Jul 2018 14:25:44 +0100
Subject: [PATCH] Don't generate pages for apps until initial setup has
 completed

---
 src/freedombone-utils-webadmin | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/src/freedombone-utils-webadmin b/src/freedombone-utils-webadmin
index 87aef69ff..0cb224871 100755
--- a/src/freedombone-utils-webadmin
+++ b/src/freedombone-utils-webadmin
@@ -87,9 +87,18 @@ function web_admin_avahi {
 }
 
 function web_admin_create_users {
-    ADMIN_USER=$(get_completion_param "Admin user")
     web_admin_get_hostname
+
     users_file="$webadmin_install_dir/users.html"
+
+    if [ -f "$webadmin_install_dir/.setupscreenactive" ]; then
+        if [ -f "$users_file" ]; then
+            rm "$users_file"
+        fi
+        return
+    fi
+
+    ADMIN_USER=$(get_completion_param "Admin user")
     cp "$webadmin_install_dir/users_template.html" "$users_file"
     sed -i '/users list/,/end of users/d' "$users_file"
     sed -i '/<\/body>/d' "$users_file"
@@ -158,10 +167,18 @@ function web_admin_create_users {
 }
 
 function web_admin_create_add_apps {
-    read_config_param DDNS_PROVIDER
     web_admin_get_hostname
-    apps_add_template_filename="$webadmin_install_dir/apps_add_template.html"
+
     appslist_add_filename="$webadmin_install_dir/apps_add.html"
+    if [ -f "$webadmin_install_dir/.setupscreenactive" ]; then
+        if [ -f "$appslist_add_filename" ]; then
+            rm "$appslist_add_filename"
+        fi
+        return
+    fi
+
+    read_config_param DDNS_PROVIDER
+    apps_add_template_filename="$webadmin_install_dir/apps_add_template.html"
     pending_installs="$webadmin_install_dir/pending_installs.txt"
     icons_dir="$webadmin_install_dir/icons"
     app_add_template_filename="$webadmin_install_dir/app_add_template.html"
@@ -307,9 +324,17 @@ function web_admin_create_add_apps {
 
 function web_admin_create_installed_apps {
     web_admin_get_hostname
+
+    appslist_filename="$webadmin_install_dir/apps.html"
+    if [ -f "$webadmin_install_dir/.setupscreenactive" ]; then
+        if [ -f "$appslist_filename" ]; then
+            rm "$appslist_filename"
+        fi
+        return
+    fi
+
     appslist_template_filename="$webadmin_install_dir/apps_template.html"
     app_template_filename="$webadmin_install_dir/app_template.html"
-    appslist_filename="$webadmin_install_dir/apps.html"
     icons_dir="$webadmin_install_dir/icons"
     pending_removes="$webadmin_install_dir/pending_removes.txt"
 
@@ -551,6 +576,7 @@ function install_web_admin {
     web_admin_installed=
     if [ -d "/usr/share/${PROJECT_NAME}/webadmin" ]; then
         if [ -d "/usr/share/${PROJECT_NAME}/webadmin/${language_subdir}" ]; then
+            rm "$webadmin_install_dir/*.html"
             cp -r "/usr/share/${PROJECT_NAME}/webadmin"/* "$webadmin_install_dir"
             cp "/usr/share/${PROJECT_NAME}/webadmin/${language_subdir}"/*.html "$webadmin_install_dir"
 
-- 
GitLab