[debian-edu-commits] debian-edu/ 23/32: DebConf: Loop on group input screens if a group does not exist (for use_existing_groups == true).

Mike Gabriel sunweaver at debian.org
Mon Aug 18 15:09:47 UTC 2014


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to annotated tag debian/1_2.0.2+dfsg1-1
in repository italc.

commit d0597f03a2ce8685330875f30e37c69a067c6f33
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Fri Aug 15 15:35:33 2014 +0200

    DebConf: Loop on group input screens if a group does not exist (for use_existing_groups == true).
---
 debian/italc-client.config    | 161 +++++++++++++++++++++++++++++-------------
 debian/italc-client.templates |   6 ++
 2 files changed, 118 insertions(+), 49 deletions(-)

diff --git a/debian/italc-client.config b/debian/italc-client.config
index 08f8389..1fbdceb 100755
--- a/debian/italc-client.config
+++ b/debian/italc-client.config
@@ -22,8 +22,11 @@ if [ "$create_keypairs" = "true" ]; then
 	db_go
 	db_get italc-client/create-groups-for-roles
 	create_groups=$RET
+
+	# always allow usage of existing groups (also when $create_groups is set)
+	db_set italc-client/use-existing-groups-for-roles true
+
 	if [ "$create_groups" = "false" ]; then
-		db_set italc-client/use-existing-groups-for-roles true
 
 		db_get italc-client/group-italc-teacher
 		if [ -z "$RET" ] || ! getent group $RET 1>/dev/null; then
@@ -51,61 +54,121 @@ if [ "$create_keypairs" = "true" ]; then
 
 	if [ "$create_groups" = "true" ] || [ "$use_existing_groups" = "true" ]; then
 
-		db_input high italc-client/group-italc-teacher || true
-		db_go
-
-		db_get italc-client/group-italc-teacher
-		italc_group_teacher=$RET
-		db_get italc-client/last-group-teacher
-		if [ -z "$RET" ] || ! getent group $RET 1>/dev/null; then
-			RET="root"
-		fi
-		if [ "$RET" != "$italc_group_teacher" ] && [ "$RET" != 'italc-teacher' ] && [ $(getent group $RET | cut -d ":" -f 3) -ge 500 ]; then
-			db_input critical italc-client/del-last-group-teacher || true
+		loop=1
+		while [ $loop -eq 1 ]; do
+			db_input high italc-client/group-italc-teacher || true
 			db_go
-		fi
-
-		db_input high italc-client/group-italc-student || true
-		db_go
 
-		db_get italc-client/group-italc-student
-		italc_group_student=$RET
-		db_get italc-client/last-group-student
-		if [ -z "$RET" ] || ! getent group $RET 1>/dev/null; then
-			RET="root"
-		fi
-		if [ "$RET" != "$italc_group_student" ] && [ "$RET" != 'italc-student' ] && [ $(getent group $RET | cut -d ":" -f 3) -ge 500 ]; then
-			db_input critical italc-client/del-last-group-student || true
+			db_get italc-client/group-italc-teacher
+			italc_group_teacher=$RET
+			if getent group $italc_group_teacher 1>/dev/null; then
+				loop=0
+			else
+				if [ "$create_groups" = "true" ]; then
+					loop=0
+				else
+					db_input critical italc-client/no-such-group || true
+					db_go
+					continue
+				fi
+			fi
+
+			db_get italc-client/last-group-teacher
+			if [ -z "$RET" ] || ! getent group $RET 1>/dev/null; then
+				RET="root"
+			fi
+			if [ "$RET" != "$italc_group_teacher" ] && [ $(getent group $RET | cut -d ":" -f 3) -ge 100 ]; then
+				db_input critical italc-client/del-last-group-teacher || true
+				db_go
+			fi
+		done
+
+		loop=1
+		while [ $loop -eq 1 ]; do
+			db_input high italc-client/group-italc-student || true
 			db_go
-		fi
 
-		db_input high italc-client/group-italc-supporter || true
-		db_go
-
-		db_get italc-client/group-italc-supporter
-		italc_group_supporter=$RET
-		db_get italc-client/last-group-supporter
-		if [ -z "$RET" ] || ! getent group $RET 1>/dev/null; then
-			RET="root"
-		fi
-		if [ "$RET" != "$italc_group_supporter" ] && [ "$RET" != 'italc-supporter' ] && [ $(getent group $RET | cut -d ":" -f 3) -ge 500 ]; then
-			db_input critical italc-client/del-last-group-supporter || true
+			db_get italc-client/group-italc-student
+			italc_group_student=$RET
+			if getent group $italc_group_student 1>/dev/null; then
+				loop=0
+			else
+				if [ "$create_groups" = "true" ]; then
+					loop=0
+				else
+					db_input critical italc-client/no-such-group || true
+					db_go
+					continue
+				fi
+			fi
+
+			db_get italc-client/last-group-student
+			if [ -z "$RET" ] || ! getent group $RET 1>/dev/null; then
+				RET="root"
+			fi
+			if [ "$RET" != "$italc_group_student" ] && [ $(getent group $RET | cut -d ":" -f 3) -ge 100 ]; then
+				db_input critical italc-client/del-last-group-student || true
+				db_go
+			fi
+		done
+
+		loop=1
+		while [ $loop -eq 1 ]; do
+			db_input high italc-client/group-italc-supporter || true
 			db_go
-		fi
 
-		db_input high italc-client/group-italc-admin || true
-		db_go
-
-		db_get italc-client/group-italc-admin
-		italc_group_admin=$RET
-		db_get italc-client/last-group-admin
-		if [ -z "$RET" ] || ! getent group $RET 1>/dev/null; then
-			RET="root"
-		fi
-		if [ "$RET" != "$italc_group_admin" ] && [ "$RET" != 'italc-admin' ] && [ $(getent group $RET | cut -d ":" -f 3) -ge 500 ]; then
-			db_input critical italc-client/del-last-group-admin || true
+			db_get italc-client/group-italc-supporter
+			italc_group_supporter=$RET
+			if getent group $italc_group_supporter 1>/dev/null; then
+				loop=0
+			else
+				if [ "$create_groups" = "true" ]; then
+					loop=0
+				else
+					db_input critical italc-client/no-such-group || true
+					db_go
+					continue
+				fi
+			fi
+
+			db_get italc-client/last-group-supporter
+			if [ -z "$RET" ] || ! getent group $RET 1>/dev/null; then
+				RET="root"
+			fi
+			if [ "$RET" != "$italc_group_supporter" ] && [ $(getent group $RET | cut -d ":" -f 3) -ge 100 ]; then
+				db_input critical italc-client/del-last-group-supporter || true
+				db_go
+			fi
+		done
+
+		loop=1
+		while [ $loop -eq 1 ]; do
+			db_input high italc-client/group-italc-admin || true
 			db_go
-		fi
+
+			db_get italc-client/group-italc-admin
+			italc_group_admin=$RET
+			if getent group $italc_group_admin 1>/dev/null; then
+				loop=0
+			else
+				if [ "$create_groups" = "true" ]; then
+					loop=0
+				else
+					db_input critical italc-client/no-such-group || true
+					db_go
+					continue
+				fi
+			fi
+
+			db_get italc-client/last-group-admin
+			if [ -z "$RET" ] || ! getent group $RET 1>/dev/null; then
+				RET="root"
+			fi
+			if [ "$RET" != "$italc_group_admin" ] && [ $(getent group $RET | cut -d ":" -f 3) -ge 100 ]; then
+				db_input critical italc-client/del-last-group-admin || true
+				db_go
+			fi
+		done
 
 		db_input high italc-client/key-access-for-groups || true
 		db_go
diff --git a/debian/italc-client.templates b/debian/italc-client.templates
index bd9bf8a..d744764 100644
--- a/debian/italc-client.templates
+++ b/debian/italc-client.templates
@@ -135,6 +135,12 @@ _Description: Delete the group that was formerly used for this role?
  Please specify whether the old group should be deleted. If unsure,
  keep the formerly used group and manually investigate later.
 
+Template: italc-client/no-such-group
+Type: error
+_Description: Non-existing group
+ The given group does not exist on this system. You should specify an
+ already existing group.
+
 Template: italc-client/key-access-for-groups
 Type: boolean
 Default: true

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/pkg-team/italc.git



More information about the debian-edu-commits mailing list