Not the diff result + use chmod so all users can read the mailing list.

This commit is contained in:
Thomas Stokes
2024-03-21 13:02:55 +01:00
parent 1cdac2e549
commit 41e38c2cb9
@@ -8,11 +8,12 @@ NAME_TO_STORE_IN="landscapeManagersMailingList"
BASE_URL="https://security-service.sapsailing.com"
curl_output=$( curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/security/api/restsecurity/users_with_permission?permission=LANDSCAPE:MANAGE:AWS" 2>/dev/null )
temp_file_path=$(mktemp /var/cache/emails_XXX)
chmod 644 $temp_file_path
echo $curl_output | jq -r .[] | while read user; do
email=$(curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/security/api/restsecurity/user?username=$user" 2>/dev/null| jq -r '.email' )
echo $email >> $temp_file_path
done
if diff ${PATH_TO_STORE}/${NAME_TO_STORE_IN} ${temp_file_path}; then
if ! diff ${PATH_TO_STORE}/${NAME_TO_STORE_IN} ${temp_file_path}; then
mv "$temp_file_path" ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
else
rm ${temp_file_path}