62 lines
2.6 KiB
Bash
62 lines
2.6 KiB
Bash
#!/bin/bash
|
|
|
|
echo Welcome to the Docker Installer:
|
|
|
|
FILE=env.local
|
|
if [ -f "$FILE" ]; then
|
|
source $FILE
|
|
else
|
|
touch $FILE
|
|
KEYCLOAK_PW=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
|
ODC_DB_PW=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
|
KEYCLOAK_ADMIN_PW=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
|
OAUTH_KEYCLOAK_CLIENT_ID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
|
|
|
echo "KEYCLOAK_PW=$KEYCLOAK_PW" >> $FILE
|
|
echo "KEYCLOAK_ADMIN_PW=$KEYCLOAK_ADMIN_PW" >> $FILE
|
|
echo "OAUTH_KEYCLOAK_CLIENT_ID=$OAUTH_KEYCLOAK_CLIENT_ID" >> $FILE
|
|
echo "ODC_DB_PW=$ODC_DB_PW" >> $FILE
|
|
source $FILE
|
|
fi
|
|
ENVIRONMENT=${ENVIRONMENT:=prod}
|
|
read -p "Enter the environment dev/prod[$ENVIRONMENT]: " input
|
|
ENVIRONMENT=${input:=$ENVIRONMENT}
|
|
sed -i '/APP_ENV/d' $FILE
|
|
echo "APP_ENV=$ENVIRONMENT" >> $FILE
|
|
|
|
HTTP_METHOD=${HTTP_METHOD:=http}
|
|
read -p "Enter http/https for testing on local environment ALWAYS use http [$HTTP_METHOD]: " input
|
|
HTTP_METHOD=${input:=$HTTP_METHOD}
|
|
sed -i '/HTTP_METHOD/d' $FILE
|
|
echo "HTTP_METHOD=$HTTP_METHOD" >> $FILE
|
|
|
|
PUBLIC_URL=${PUBLIC_URL:=dev.domain.de}
|
|
read -p "Enter the url you want to enter the open-datenschutzcenter without http://, https:// or ports [$PUBLIC_URL]: " input
|
|
PUBLIC_URL=${input:=$PUBLIC_URL}
|
|
sed -i '/PUBLIC_URL/d' $FILE
|
|
echo "PUBLIC_URL=$PUBLIC_URL" >> $FILE
|
|
|
|
|
|
echo ------------------------------------------------------------
|
|
echo ----------------- Build the Keycloak -----------------------
|
|
echo ------------------------------------------------------------
|
|
|
|
sed -i "s|<clientsecret>|$OAUTH_KEYCLOAK_CLIENT_ID|g" keycloak/realm-export.json
|
|
sed -i "s|<clientUrl>|$HTTP_METHOD://$PUBLIC_URL|g" keycloak/realm-export.json
|
|
|
|
echo ------------------------------------------------------------
|
|
echo ----------------- Build Mysql Init DB ----------------------
|
|
echo ------------------------------------------------------------
|
|
|
|
sed -i "s|<open-datenschutzcenter-pw>|$ODC_DB_PW|g" mysql-initdb/init-userdb.sql
|
|
sed -i "s|<keycloak-pw>|$KEYCLOAK_PW|g" mysql-initdb/init-userdb.sql
|
|
|
|
echo ------------------------------------------------------------
|
|
echo ----------------- Build Docker Compose File ----------------
|
|
echo ------------------------------------------------------------
|
|
|
|
sed -i "s|<keycloakAdminPw>|$KEYCLOAK_ADMIN_PW|g" docker-compose.yml
|
|
sed -i "s|<keycloak-pw>|$KEYCLOAK_PW|g" docker-compose.yml
|
|
sed -i "s|<clientsecret>|$OAUTH_KEYCLOAK_CLIENT_ID|g" docker-compose.yml
|
|
sed -i "s|<clientUrl>|$HTTP_METHOD://$PUBLIC_URL|g" docker-compose.yml
|
|
sed -i "s|<odcMySqlPw>|$ODC_DB_PW|g" docker-compose.yml
|