-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_dotenv.sh
More file actions
70 lines (62 loc) · 1.75 KB
/
create_dotenv.sh
File metadata and controls
70 lines (62 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -e
# $1 username for postgres superuser
# $2 password for postgres superuser
# $3 username for regular postgres user
# $4 password for regular postgres user
# $5 hostname of REST server (default: http://localhost)
PG_DB="flai_db_v1"
PG_PORT="5432"
declare -A vue=(
["dir"]="frontend/flai_app"
["VITE_REST_HOSTNAME"]="${5-http://localhost:5000}"
)
declare -A express=(
["dir"]="backend/express"
["PORT"]="5000"
["ACCESS_TOKEN_SECRET"]=$(openssl rand -hex 64)
["REFRESH_TOKEN_SECRET"]=$(openssl rand -hex 64)
["PG_USER"]="$3"
["PG_PASSWORD"]="$4"
["PG_DB"]="$PG_DB"
["PG_HOSTNAME"]="localhost"
["PG_PORT"]="$PG_PORT"
)
declare -A docker=(
["dir"]="."
["IMAGE_TAG"]="flai"
["VUE_APP_HOST_PORT"]="3000"
["VUE_APP_CONTAINER_PORT"]="3000"
["EXPRESS_APP_HOST_PORT"]="5000"
["EXPRESS_APP_CONTAINER_PORT"]="5000"
["ACCESS_TOKEN_SECRET"]=$(openssl rand -hex 64)
["REFRESH_TOKEN_SECRET"]=$(openssl rand -hex 64)
["POSTGRES_DB_HOST_PORT"]="$PG_PORT"
["POSTGRES_DB_CONTAINER_PORT"]="5432"
["PG_USER"]="$1"
["PG_PASSWORD"]="$2"
["PG_DB"]="postgres"
["DEV_USER"]="$3"
["DEV_PASSWORD"]="$4"
["DEV_DB"]="$PG_DB"
["ADMINER_HOST_PORT"]="7000"
["ADMINER_CONTAINER_PORT"]="8080"
)
create_env_variables(){
for env in $1
do
declare -n dict=$env
directory=${dict[dir]}
cd $directory
echo "Creating $env .env in $directory"
[ ! -e .env ] || rm .env
for var in "${!dict[@]}"
do
[ "$var" != "dir" ] && echo "$var=${dict[$var]}" >> .env
done
unset -n dict
cd - >/dev/null
done
}
create_env_variables 'vue express docker'
echo "------------> $0 has finished successfully"