simplifie le test de création de l'orga comme équipe MM
This commit is contained in:
+15
-19
@@ -661,39 +661,35 @@ EOF
|
|||||||
|
|
||||||
if [ "${EQUIPE_AGORA}" != "" -a "${EQUIPE_AGORA}" != "kaz" ]; then
|
if [ "${EQUIPE_AGORA}" != "" -a "${EQUIPE_AGORA}" != "kaz" ]; then
|
||||||
# l'équipe existe t-elle déjà ?
|
# l'équipe existe t-elle déjà ?
|
||||||
|
|
||||||
#nb=$(docker exec mattermostServ bin/mmctl team list | grep -w "${EQUIPE_AGORA}" | wc -l)
|
|
||||||
http_code=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${mattermost_token}" "https://${URL_AGORA}/api/v4/teams/name/${EQUIPE_AGORA}")
|
http_code=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${mattermost_token}" "https://${URL_AGORA}/api/v4/teams/name/${EQUIPE_AGORA}")
|
||||||
[ "$http_code" -eq 200 ] && nb=1 || nb=0
|
|
||||||
|
|
||||||
if [ "${nb}" == "0" ];then # non, on la créé en mettant le user en admin de l'équipe
|
if [ "$http_code" -eq 200 ]; then
|
||||||
|
echo "équipe trouvée"
|
||||||
#echo "docker exec -i mattermostServ bin/mmctl team create --name ${EQUIPE_AGORA} --display-name ${EQUIPE_AGORA} --email ${EMAIL_SOUHAITE}" --private | tee -a "${CMD_INIT}"
|
else
|
||||||
|
# non, on la créé en mettant le user en admin de l'équipe
|
||||||
#################################
|
cat >> "${CMD_LOGIN}" <<EOF
|
||||||
cat >> "${CMD_LOGIN}" <<EOF
|
resp=\$(curl -s -X POST "https://${URL_AGORA}/api/v4/teams" \
|
||||||
resp=\$(curl -s -X POST "https://${URL_AGORA}/api/v4/teams" \
|
|
||||||
-H "Authorization: Bearer ${mattermost_token}" \
|
-H "Authorization: Bearer ${mattermost_token}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{ "name":"${EQUIPE_AGORA}", "display_name":"${EQUIPE_AGORA}", "type":"O"}')
|
-d '{ "name":"${EQUIPE_AGORA}", "display_name":"${EQUIPE_AGORA}", "type":"O"}')
|
||||||
|
|
||||||
TEAM_ID=\$(echo "\$resp" | jq -r '.id')
|
TEAM_ID=\$(echo "\$resp" | jq -r '.id')
|
||||||
|
|
||||||
#puis ajouter le user à l'équipe
|
#puis ajouter le user à l'équipe
|
||||||
#echo "docker exec -i mattermostServ bin/mmctl team users add ${EQUIPE_AGORA} ${EMAIL_SOUHAITE}" | tee -a "${CMD_INIT}"
|
#echo "docker exec -i mattermostServ bin/mmctl team users add ${EQUIPE_AGORA} ${EMAIL_SOUHAITE}" | tee -a "${CMD_INIT}"
|
||||||
|
|
||||||
curl -s -X POST "https://${URL_AGORA}/api/v4/teams/\${TEAM_ID}/members" \
|
curl -s -X POST "https://${URL_AGORA}/api/v4/teams/\${TEAM_ID}/members" \
|
||||||
-H "Authorization: Bearer ${mattermost_token}" \
|
-H "Authorization: Bearer ${mattermost_token}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{ "team_id": "'"\${TEAM_ID}"'", "user_id": "'"\${USER_ID}"'" }'
|
-d '{ "team_id": "'"\${TEAM_ID}"'", "user_id": "'"\${USER_ID}"'" }'
|
||||||
|
|
||||||
#et on le rend admin de son équipe
|
#et on le rend admin de son équipe
|
||||||
curl -s -X PUT "https://${URL_AGORA}/api/v4/teams/\${TEAM_ID}/members/\${USER_ID}/roles" \
|
curl -s -X PUT "https://${URL_AGORA}/api/v4/teams/\${TEAM_ID}/members/\${USER_ID}/roles" \
|
||||||
-H "Authorization: Bearer ${mattermost_token}" \
|
-H "Authorization: Bearer ${mattermost_token}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"roles":"team_user team_admin"}'
|
-d '{"roles":"team_user team_admin"}'
|
||||||
EOF
|
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user