bridgehead/ccp/modules/datashield-setup.sh

34 lines
2.1 KiB
Bash
Raw Normal View History

2023-09-04 16:43:40 +02:00
#!/bin/bash -e
2023-04-12 09:46:35 +02:00
if [ "$ENABLE_DATASHIELD" == true ]; then
2023-04-12 09:46:35 +02:00
log INFO "DataSHIELD setup detected -- will start DataSHIELD services."
OVERRIDE+=" -f ./$PROJECT/modules/datashield-compose.yml"
2023-11-23 15:54:44 +01:00
EXPORTER_OPAL_PASSWORD="$(generate_password \"exporter in Opal\")"
TOKEN_MANAGER_OPAL_PASSWORD="$(generate_password \"Token Manager in Opal\")"
OPAL_DB_PASSWORD="$(echo \"This is a salt string to generate one consistent password for Opal. It is not required to be secret.\" | openssl rsautl -sign -inkey /etc/bridgehead/pki/${SITE_ID}.priv.pem | base64 | head -c 30)"
OPAL_ADMIN_PASSWORD="$(generate_password \"admin password for Opal\")"
2023-11-23 17:28:39 +01:00
RSTUDIO_ADMIN_PASSWORD="$(generate_password \"admin password for R-Studio\")"
DATASHIELD_CONNECT_SECRET="$(echo \"This is a salt string to generate one consistent password as the DataShield Connect secret. It is not required to be secret.\" | openssl rsautl -sign -inkey /etc/bridgehead/pki/${SITE_ID}.priv.pem | base64 | head -c 30)"
2023-12-12 10:53:14 +01:00
TOKEN_MANAGER_SECRET="$(echo \"This is a salt string to generate one consistent password as the Token Manger secret. It is not required to be secret.\" | openssl rsautl -sign -inkey /etc/bridgehead/pki/${SITE_ID}.priv.pem | base64 | head -c 30)"
if [ ! -e /tmp/bridgehead/opal-cert.pem ]; then
mkdir -p /tmp/bridgehead/
chown -R bridgehead:docker /tmp/bridgehead/
openssl req -x509 -newkey rsa:4096 -nodes -keyout /tmp/bridgehead/opal-key.pem -out /tmp/bridgehead/opal-cert.pem -days 3650 -subj "/CN=${HOST:-opal}/C=DE"
chmod g+r /tmp/bridgehead/opal-key.pem
fi
2023-09-15 11:45:28 +02:00
mkdir -p /tmp/bridgehead/opal-map
jq -n '{"sites": input | map({
"name": .,
"id": .,
2023-12-13 14:17:16 +01:00
"virtualhost": "\(.):443",
"beamconnect": "datashield-connect.\(.).'"$BROKER_ID"'"
})}' ./$PROJECT/modules/datashield-mappings.json > /tmp/bridgehead/opal-map/central.json
jq -n '[{
2023-12-13 14:17:16 +01:00
"external": "'"$SITE_ID"':443",
"internal": "opal:8080",
"allowed": input | map("datashield-connect.\(.).'"$BROKER_ID"'")
}]' ./$PROJECT/modules/datashield-mappings.json > /tmp/bridgehead/opal-map/local.json
chown -R bridgehead:docker /tmp/bridgehead/
2023-11-30 14:46:08 +01:00
add_private_oidc_redirect_url "/opal/*"
2023-05-16 16:40:22 +02:00
fi