From e489f60b449b398cbe77316813e064a988158ff4 Mon Sep 17 00:00:00 2001 From: Corentin LABBE Date: Tue, 27 Nov 2018 14:13:27 +0100 Subject: lava-master: skip creation of already existing groups When restoring a backup, it is not possible to create a group which already exists. This patch adds detection for this case and skip the creation when the group exists. --- lava-master/scripts/setup.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lava-master/scripts/setup.sh b/lava-master/scripts/setup.sh index b362d16..e662a2b 100755 --- a/lava-master/scripts/setup.sh +++ b/lava-master/scripts/setup.sh @@ -67,18 +67,28 @@ if [ -e /root/lava-users ];then fi if [ -e /root/lava-groups ];then + echo "======================================================" + echo "Handle groups" + echo "======================================================" + GROUP_CURRENT_LIST=/tmp/group.list + lava-server manage groups list |grep '^\*' > $GROUP_CURRENT_LIST || exit 1 for group in $(ls /root/lava-groups/*group) do GROUPNAME="" SUBMIT=0 OPTION_SUBMIT="" . $group - if [ $SUBMIT -eq 1 ];then - echo "DEBUG: $GROUPNAME can submit jobs" - OPTION_SUBMIT="--submitting" + grep -q $GROUPNAME $GROUP_CURRENT_LIST + if [ $? -eq 0 ];then + echo "DEBUG: SKIP creation of $GROUPNAME which already exists" + else + if [ $SUBMIT -eq 1 ];then + echo "DEBUG: $GROUPNAME can submit jobs" + OPTION_SUBMIT="--submitting" + fi + echo "DEBUG: Add group $GROUPNAME" + lava-server manage groups add $OPTION_SUBMIT $GROUPNAME || exit 1 fi - echo "DEBUG: Add group $GROUPNAME" - lava-server manage groups add $OPTION_SUBMIT $GROUPNAME || exit 1 if [ -e ${group}.list ];then echo "DEBUG: Found ${group}.list" while read username -- cgit 1.2.3-korg