mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-19 04:05:36 +00:00
b5933: Improve resilience of update mailing list script
This commit is contained in:
+7
-5
@@ -7,11 +7,13 @@ PATH_TO_STORE="$2"
|
||||
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 )
|
||||
if [[ -f "${PATH_TO_STORE}/${NAME_TO_STORE_IN}" ]]; then
|
||||
mv -f ${PATH_TO_STORE}/${NAME_TO_STORE_IN} ${PATH_TO_STORE}/${NAME_TO_STORE_IN}.bak
|
||||
fi
|
||||
touch ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
|
||||
temp_file_path=$(mktemp /var/cache/emails_XXX)
|
||||
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 >> ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
|
||||
echo $email >> $temp_file_path
|
||||
done
|
||||
if [[ ! -f "${PATH_TO_STORE}/${NAME_TO_STORE_IN}.bak" && -f "${PATH_TO_STORE}/${NAME_TO_STORE_IN}" ]]; then
|
||||
mv -f ${PATH_TO_STORE}/${NAME_TO_STORE_IN} ${PATH_TO_STORE}/${NAME_TO_STORE_IN}.bak
|
||||
fi
|
||||
cat "$temp_file_path" > ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
|
||||
rm ${temp_file_path}
|
||||
Reference in New Issue
Block a user