2023-09-04 16:43:40 +02:00
#!/bin/bash -e
2023-04-12 09:46:35 +02:00
2023-07-19 13:45:14 +02:00
if [ " $ENABLE_DATASHIELD " = = true ] ; then
2024-03-11 11:34:05 +01:00
# HACK: This only works because exporter-setup.sh and teiler-setup.sh are sourced after datashield-setup.sh
2024-03-18 12:18:19 +01:00
if [ -z " ${ ENABLE_EXPORTER } " ] || [ " ${ ENABLE_EXPORTER } " != "true" ] ; then
2024-03-19 09:47:57 +01:00
log WARN "The ENABLE_EXPORTER variable is either not set or not set to 'true'."
2024-03-18 12:18:19 +01:00
fi
2024-03-14 12:50:08 +01:00
OAUTH2_CALLBACK = /oauth2/callback
2024-03-18 12:44:34 +01:00
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) "
2024-03-14 12:50:08 +01:00
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) "
2023-09-15 10:12:16 +02:00
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"
2023-07-19 13:45:14 +02:00
fi
2023-09-15 11:45:28 +02:00
mkdir -p /tmp/bridgehead/opal-map
2024-02-19 09:26:53 +01:00
sites = " $( cat ./$PROJECT /modules/datashield-sites.json) "
2024-01-31 10:21:19 +01:00
echo " $sites " | docker_jq -n --args ' { "sites" : input | map( {
2023-12-13 12:01:25 +01:00
"name" : .,
"id" : .,
2023-12-13 14:17:16 +01:00
"virtualhost" : "\(.):443" ,
2023-12-13 12:01:25 +01:00
"beamconnect" : "datashield-connect.\(.).'" $BROKER_ID "'"
2024-03-18 12:18:19 +01:00
} ) } ' $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" ,
2023-12-13 12:01:25 +01:00
"allowed" : input | map( "datashield-connect.\(.).'" $BROKER_ID "'" )
2024-03-18 12:18:19 +01:00
} ] ' >/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