mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
feat: add platformsh config
This commit is contained in:
parent
b006747a45
commit
f4025098e9
4 changed files with 102 additions and 0 deletions
30
.environment
Normal file
30
.environment
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
# This script can be a starting point to convert
|
||||
# PLATFORM_RELATIONSHIPS into another environment variable
|
||||
# Many CMS systems use a DATABASE_URL to connect to the database
|
||||
# Feel free to use this as inspiration
|
||||
|
||||
getRelationshipInfo() {
|
||||
RELATIONSHIP_NAME="$1"
|
||||
PROPERTY="$2"
|
||||
JQ_STR="to_entries[] | select(.key==\"$RELATIONSHIP_NAME\") | .value[].$PROPERTY"
|
||||
CMD="echo $PLATFORM_RELATIONSHIPS | base64 -d | jq -r '$JQ_STR'"
|
||||
eval $CMD
|
||||
}
|
||||
|
||||
# choose the name of the relationship to parse, feel free to alter this
|
||||
RELATIONSHIP="postgresdatabase"
|
||||
DB_DATABASE="main"
|
||||
|
||||
# Extract the information we need
|
||||
DB_TYPE=$(getRelationshipInfo "$RELATIONSHIP" 'scheme')
|
||||
DB_USERNAME=$(getRelationshipInfo "$RELATIONSHIP" 'username')
|
||||
DB_HOST=$(getRelationshipInfo "$RELATIONSHIP" 'host')
|
||||
DB_PASS=$(getRelationshipInfo "$RELATIONSHIP" 'password')
|
||||
DB_PORT=$(getRelationshipInfo "$RELATIONSHIP" 'port')
|
||||
|
||||
# Create your DATABASE_URL variable here
|
||||
export DATABASE_URL="postgresql://$DB_USERNAME:$DB_PASS@$DB_HOST:$DB_PORT/$DB_DATABASE"
|
||||
|
||||
# So now we have postgresql://user:@db_mysql.internal:3306/main
|
||||
# echo "$DATABASE_URL" #only echo to test since it will expose the credentials
|
||||
Loading…
Add table
Add a link
Reference in a new issue