2022-12-07 15:46:19 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
function idManagementSetup() {
|
2022-12-16 12:02:49 +01:00
|
|
|
if [ -n "$IDMANAGER_UPLOAD_APIKEY" ]; then
|
2022-12-07 15:46:19 +01:00
|
|
|
log INFO "id-management setup detected -- will start id-management (mainzelliste & magicpl)."
|
|
|
|
OVERRIDE+=" -f ./$PROJECT/modules/id-management-compose.yml"
|
|
|
|
|
|
|
|
# Auto Generate local Passwords
|
2023-01-27 10:59:29 +01:00
|
|
|
PATIENTLIST_POSTGRES_PASSWORD="$(echo \"id-management-module-db-password-salt\" | openssl rsautl -sign -inkey /etc/bridgehead/pki/${SITE_ID}.priv.pem | base64 | head -c 30)"
|
2022-12-07 15:46:19 +01:00
|
|
|
IDMANAGER_LOCAL_PATIENTLIST_APIKEY="$(cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 20)"
|
|
|
|
|
2023-01-27 11:52:09 +01:00
|
|
|
# Transform Seeds Configuration to pass it to the Mainzelliste Container
|
|
|
|
PATIENTLIST_SEEDS_TRANSFORMED="$(declare -p PATIENTLIST_SEEDS | tr -d '\"' | sed 's/\[/\[\"/g' | sed 's/\]/\"\]/g')"
|
2022-12-16 12:02:49 +01:00
|
|
|
|
|
|
|
# Ensure old ids are working !!!
|
2023-02-08 14:42:52 +01:00
|
|
|
export IDMANAGEMENT_FRIENDLY_ID=$(legacyIdMapping "$SITE_ID")
|
2022-12-07 15:46:19 +01:00
|
|
|
fi
|
2023-02-08 14:42:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Transform into single string array, e.g. 'dktk-test' to 'dktk test'
|
|
|
|
# Usage: transformToSingleStringArray 'dktk-test' -> 'dktk test'
|
|
|
|
function transformToSingleStringArray() {
|
|
|
|
echo "${1//-/ }";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Ensure all Words are Uppercase
|
|
|
|
# Usage: transformToUppercase 'dktk test' -> 'Dktk Test'
|
|
|
|
function transformToUppercase() {
|
|
|
|
result="";
|
|
|
|
for word in $1; do
|
|
|
|
result+=" ${word^}";
|
|
|
|
done
|
|
|
|
echo "$result";
|
|
|
|
}
|
2022-12-07 15:46:19 +01:00
|
|
|
|
2023-02-08 14:42:52 +01:00
|
|
|
# Handle all execeptions from the norm (e.g LMU, TUM)
|
|
|
|
# Usage: applySpecialCases 'Muenchen Lmu Test' -> 'Muenchen LMU Test'
|
|
|
|
function applySpecialCases() {
|
|
|
|
result="$1";
|
|
|
|
result="${result/Lmu/LMU}";
|
|
|
|
result="${result/Tum/TUM}";
|
|
|
|
echo "$result";
|
2022-12-07 15:46:19 +01:00
|
|
|
}
|
2022-12-16 12:02:49 +01:00
|
|
|
|
2023-02-08 14:42:52 +01:00
|
|
|
# Transform current siteids to legacy version
|
|
|
|
# Usage: legacyIdMapping "dktk-test" -> "DktkTest"
|
2022-12-16 12:02:49 +01:00
|
|
|
function legacyIdMapping() {
|
2023-02-08 14:42:52 +01:00
|
|
|
single_string_array=$(transformToSingleStringArray "$1");
|
|
|
|
uppercase_string=$(transformToUppercase "$single_string_array");
|
|
|
|
normalized_string=$(applySpecialCases "$uppercase_string");
|
|
|
|
echo "$normalized_string" | tr -d ' '
|
2022-12-16 12:02:49 +01:00
|
|
|
}
|