From f79af2b6c19c539f61b87867e0b4460989ae9087 Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Tue, 17 May 2016 12:19:46 +0300 Subject: [PATCH] [Gerrit] Do not create account if already exists * In case of redeployment invokation of this method may lead to deploy failure. It will try to create an account which probably already exists. So the right solution here to check whether this user exists or not and set related properties (public key and email) to it without user creation. Change-Id: Ia7950e822da2e12b525577df507e7cc9912fca56 --- .../package/Resources/scripts/create_account.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/murano-apps/Gerrit/package/Resources/scripts/create_account.sh b/murano-apps/Gerrit/package/Resources/scripts/create_account.sh index 795615b..9df4bb4 100644 --- a/murano-apps/Gerrit/package/Resources/scripts/create_account.sh +++ b/murano-apps/Gerrit/package/Resources/scripts/create_account.sh @@ -14,5 +14,14 @@ NAME="$6" HOSTNAME="`hostname -f`" -su gerrit2 -c "ssh -p 29418 -i /home/gerrit2/review_site/etc/ssh_project_rsa_key project-creator@$HOSTNAME "` - `"gerrit create-account --group \'${GROUP}\' --full-name \'${FULL_NAME}\' --email $EMAIL --ssh-key \'${SSHKEY}\' $NAME" \ No newline at end of file +set +e +su gerrit2 -c "ssh -p 29418 -i /home/gerrit2/review_site/etc/ssh_project_rsa_key project-creator@$HOSTNAME \ +gerrit create-account --group \'${GROUP}\' --full-name \'${FULL_NAME}\' --email $EMAIL --ssh-key \'${SSHKEY}\' $NAME" + +code=$? + +if [ $code -ne 0 ]; then + # Do not create account but set related properties. + su gerrit2 -c "ssh -p 29418 -i /home/gerrit2/review_site/etc/ssh_project_rsa_key project-creator@$HOSTNAME \ + gerrit set-account --full-name \'${FULL_NAME}\' --add-email $EMAIL --add-ssh-key \'${SSHKEY}\' $NAME" +fi \ No newline at end of file