bridgehead/ccp/modules/datashield-setup.sh

45 lines
2.3 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
# HACK: This only works because exporter-setup.sh and teiler-setup.sh are sourced after datashield-setup.sh
if [ -z "${ENABLE_EXPORTER}" ] || [ "${ENABLE_EXPORTER}" != "true" ]; then
echo "The ENABLE_EXPORTER variable is either not set or not set to 'true'."
fi
OAUTH2_CALLBACK=/oauth2/callback
OAUTH2_PROXY_SECRET="$(echo \"This is a salt string to generate one consistent encryption key for the oauth2_proxy. It is not required to be secret.\" | sha1sum | openssl pkeyutl -sign -inkey /etc/bridgehead/pki/${SITE_ID}.priv.pem | base64 | head -c 32)"
add_private_oidc_redirect_url "${OAUTH2_CALLBACK}"
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-12-22 11:54:13 +01:00
EXPORTER_OPAL_PASSWORD="$(generate_password \"exporter in Opal\")"
TOKEN_MANAGER_OPAL_PASSWORD="$(generate_password \"Token Manager in Opal\")"
2023-12-22 11:41:07 +01:00
OPAL_DB_PASSWORD="$(echo \"Opal DB\" | generate_simple_password)"
2023-11-23 15:54:44 +01:00
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\")"
2023-12-22 11:41:07 +01:00
DATASHIELD_CONNECT_SECRET="$(echo \"DataShield Connect\" | generate_simple_password)"
TOKEN_MANAGER_SECRET="$(echo \"Token Manager\" | generate_simple_password)"
if [ ! -e /tmp/bridgehead/opal-cert.pem ]; then
mkdir -p /tmp/bridgehead/
2023-12-13 15:07:11 +01:00
openssl req -x509 -newkey rsa:4096 -nodes -keyout /tmp/bridgehead/opal-key.pem -out /tmp/bridgehead/opal-cert.pem -days 3650 -subj "/CN=opal/C=DE"
fi
2023-09-15 11:45:28 +02:00
mkdir -p /tmp/bridgehead/opal-map
sites="$(cat ./$PROJECT/modules/datashield-sites.json)"
2024-01-31 10:21:19 +01:00
echo "$sites" | docker_jq -n --args '{"sites": input | map({
"name": .,
"id": .,
2023-12-13 14:17:16 +01:00
"virtualhost": "\(.):443",
"beamconnect": "datashield-connect.\(.).'"$BROKER_ID"'"
})}' $sites >/tmp/bridgehead/opal-map/central.json
2024-01-31 10:21:19 +01:00
echo "$sites" | docker_jq -n --args '[{
2023-12-13 14:17:16 +01:00
"external": "'"$SITE_ID"':443",
2023-12-13 15:07:11 +01:00
"internal": "opal:8443",
"allowed": input | map("datashield-connect.\(.).'"$BROKER_ID"'")
}]' >/tmp/bridgehead/opal-map/local.json
2024-01-31 15:23:14 +01:00
if [ "$USER" == "root" ]; then
chown -R bridgehead:docker /tmp/bridgehead
chmod g+wr /tmp/bridgehead/opal-map/*
chmod g+r /tmp/bridgehead/opal-key.pem
fi
2023-11-30 14:46:08 +01:00
add_private_oidc_redirect_url "/opal/*"
2023-05-16 16:40:22 +02:00
fi