From 3fb870a6fffc36abe7cc84c64778159dd0fb86c4 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Mon, 11 Dec 2017 16:06:44 +0000
Subject: [PATCH] Separate matrix user removal script generation

---
 src/freedombone-app-matrix | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/freedombone-app-matrix b/src/freedombone-app-matrix
index f31240724..31d8c1af0 100755
--- a/src/freedombone-app-matrix
+++ b/src/freedombone-app-matrix
@@ -329,11 +329,7 @@ function matrix_generate {
     matrix_configure_homeserver_yaml "${turnkey}" $homeserver_config
 }
 
-function remove_user_matrix {
-    remove_username="$1"
-
-    ${PROJECT_NAME}-pass -u $remove_username --rmapp matrix
-
+function create_matrix_user_removal_script {
     read_config_param MY_USERNAME
     read_config_param MATRIX_DOMAIN_NAME
 
@@ -349,7 +345,13 @@ function remove_user_matrix {
     echo "curl -X POST 'https://$MATRIX_DOMAIN_NAME/_matrix/client/r0/admin/deactivate/%40\$remove_username%3A$MATRIX_DOMAIN_NAME?access_token=\$TOKEN' --data '{}'" >> $matrix_remove_user
 
     chmod +x $matrix_remove_user
+}
 
+function remove_user_matrix {
+    remove_username="$1"
+
+    create_matrix_user_removal_script
+    ${PROJECT_NAME}-pass -u $remove_username --rmapp matrix
     $matrix_remove_user "$remove_username"
 }
 
@@ -796,6 +798,7 @@ function install_matrix {
         echo $'Failed to add matrix admin user';
         exit 879352
     fi
+    create_matrix_user_removal_script
 
     set_completion_param "matrix domain" "$MATRIX_DOMAIN_NAME"
 
-- 
GitLab