From 698220855e9c85032751fa359ec55789870a2b2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=A1clav=20Barto=C5=A1?= <bartos@cesnet.cz>
Date: Mon, 19 Sep 2022 14:18:27 +0200
Subject: [PATCH] user config: CN made equal to username

firstname and lastname are optional (can be empty) - they are not needed in any of the tools.
---
 configure.sh                      | 40 +++++++++++++++----------------
 group_vars/all/variables.template | 16 ++++++-------
 2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/configure.sh b/configure.sh
index 518e5e6..f7e239b 100755
--- a/configure.sh
+++ b/configure.sh
@@ -83,25 +83,25 @@ else
 	echo
 	echo
 	echo
-	echo "Please provide following parameters for first socctolls user which will be created during the initialization with organization admin privileges:"
+	echo "Please provide the following parameters for the first SOCTools user, which will be created during the initialization with organization admin privileges:"
+	echo "username 	- Username of the user"
 	echo "firstname - First name of the user"
 	echo "lastname 	- Last name of the user"
-	echo "username 	- Username of the user"
-	echo "DN 	- Distinguished Name of the user, for user certificate"
-	echo "CN 	- Common Name of the user, for user certificate"
-	echo "Email will be generated automatically in Username@Domain format becouse of format restrictions in some services"
+	#echo "DN 	- Distinguished Name of the user, for user certificate"
+	#echo "CN 	- Common Name of the user, for user certificate"
+	echo "Email will be generated automatically in Username@Domain format because of format restrictions in some services"
 	echo ""
-	echo ""
-	for i in firstname lastname username; do
-		read -p "${i}: " $i
-	      	if [ -z $i ]; then
-                	echo "Error: Empty string for ${i}! exiting..."
-                	exit 1
-        	fi
-	done
-	read -p "Enter CN for Certificate [${firstname}${lastname}]: " CN
-	CN=${CN:-${firstname}${lastname}}
-	DN=${CN}
+	read -p "username: " username
+	if [ -z "$username" ]; then
+		echo "Error: Empty username! exiting..."
+		exit 1
+  fi
+	read -p "firstname: " firstname
+	read -p "lastname: " lastname
+	#read -p "Enter CN for Certificate [${firstname}${lastname}]: " CN
+	#CN=${CN:-${firstname}${lastname}}
+	CN="$username"
+	DN="CN=${CN}"
 	echo
 	echo
 	echo
@@ -124,12 +124,12 @@ else
 			cp -f group_vars/all/variables.template group_vars/all/variables.yml
 			sed -i "s/CHANGE_ME_TO_FQDN/${soctoolsproxy}/g" group_vars/all/variables.yml
 			sed -i "s/soctools.test/${domain}/g" group_vars/all/variables.yml
-			sed -i "11s/soc_admin/${firstname}/" group_vars/all/variables.yml
-			sed -i "12s/SOC/${lastname}/" group_vars/all/variables.yml
+			sed -i "11s/CHANGE_ME_FIRST_NAME/${firstname}/" group_vars/all/variables.yml
+			sed -i "12s/CHANGE_ME_LAST_NAME/${lastname}/" group_vars/all/variables.yml
 			sed -i "13s/soc_admin/${username}/" group_vars/all/variables.yml
 			sed -i "14s/soc_admin/${username}/" group_vars/all/variables.yml
-			sed -i "15s/SOC_Admin/${DN}/" group_vars/all/variables.yml
-			sed -i "16s/SOC_Admin/${CN}/" group_vars/all/variables.yml
+			sed -i "15s/CN=soc_admin/${DN}/" group_vars/all/variables.yml
+			sed -i "16s/soc_admin/${CN}/" group_vars/all/variables.yml
 			sed -i "26s/soc_admin/${username}/" group_vars/all/variables.yml
 			echo
 			echo
diff --git a/group_vars/all/variables.template b/group_vars/all/variables.template
index ed0178a..04576f3 100644
--- a/group_vars/all/variables.template
+++ b/group_vars/all/variables.template
@@ -8,18 +8,18 @@ domain: "soctools.test"
 
 #List of users which will be created during the initialization with organization admin privileges
 soctools_users:
-  - firstname: "soc_admin"
-    lastname: "SOC"
+  - firstname: "CHANGE_ME_FIRST_NAME"
+    lastname: "CHANGE_ME_LAST_NAME"
     username: "soc_admin"
     email: "soc_admin@{{domain}}"
-    DN: "CN=SOC_Admin"
-    CN: "SOC_Admin"
-#  - firstname: "soc_admin_2"
-#    lastname: "SOC"
+    DN: "CN=soc_admin"
+    CN: "soc_admin"
+#  - firstname: "SOC Admin 2"
+#    lastname: ""
 #    username: "soc_admin_2"
 #    email: "soc_admin_2@{{domain}}"
-#    DN: "CN=SOC_Admin_2"
-#    CN: "SOC_Admin_2"
+#    DN: "CN=soc_admin_2"
+#    CN: "soc_admin_2"
     
 # list of users(username) from previous step which will recive admin roles in ODFE. (Minimum one user is required)
 ODFE_ADMIN_USERS:
-- 
GitLab