-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-env.sh
93 lines (75 loc) · 2.44 KB
/
create-env.sh
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
ENVIRONMENT_FILE=".env"
alias pwgen="docker run \
--rm \
--interactive \
backplane/pwgen \
--ambiguous \
--capitalize \
--secure 20 1"
is_environement_file_already_exist () {
if [ -e "${ENVIRONMENT_FILE}" ]
then
echo the "${ENVIRONMENT_FILE}" file already exist
echo you need to delete it to recreate a new one
exit 0
fi
}
generate_all_variables () {
DEVE_POSTGRES_USER=$(whoami)
DEVE_POSTGRES_PASSWORD=$(pwgen)
DEVE_POSTGRES_NAME="matcha-db-dev"
PROD_POSTGRES_USER=$(whoami)
PROD_POSTGRES_PASSWORD=$(pwgen)
PROD_POSTGRES_NAME="matcha-db-prod"
}
mail_credentials() {
echo -n "mail user: " ; read MAIL_USER
echo -n "mail smtp: " ; read MAIL_SMTP
echo -n "mail test (to test the send mail feature): " ; read MAIL_TEST
echo -n "mail password: " ; read -s MAIL_PASSWORD
}
create_the_environment_file () {
cat > ${ENVIRONMENT_FILE} <<- environment_file
# Matcha environment file
# File created the $(date +"%Y.%m.%d") by $(whoami)
# url
DEVE_URL_FRONTEND=http://localhost:4200
DEVE_URL_BACKEND=http://localhost:5001
# PostgreSQLexit
DEVE_POSTGRES_USER=${DEVE_POSTGRES_USER}
DEVE_POSTGRES_PASSWORD=${DEVE_POSTGRES_PASSWORD}
DEVE_POSTGRES_NAME=${DEVE_POSTGRES_NAME}
DEVE_DATABASE_URL=postgres://${DEVE_POSTGRES_USER}:${DEVE_POSTGRES_PASSWORD}@postgres:5432/${DEVE_POSTGRES_NAME}
DEVE_FLASK_JWT_SECRET_KEY=$(pwgen)
DEVE_FLASK_UPLOAD_FOLDER="uploads"
DEVE_FLASK_URL="http://localhost:5001"
# url
PROD_URL=http://localhost
PROD_POSTGRES_USER=${PROD_POSTGRES_USER}
PROD_POSTGRES_PASSWORD=${PROD_POSTGRES_PASSWORD}
PROD_POSTGRES_NAME=${PROD_POSTGRES_NAME}
PROD_DATABASE_URL=postgres://${PROD_POSTGRES_USER}:${PROD_POSTGRES_PASSWORD}@postgres:5432/${PROD_POSTGRES_NAME}
PROD_FLASK_JWT_SECRET_KEY=$(pwgen)
PROD_FLASK_UPLOAD_FOLDER="uploads"
# Mail
DEVE_MAIL_USER=test # default username of MailHog
DEVE_MAIL_SMTP_HOST=mail-dev # container name of MailHog
DEVE_MAIL_SMTP_PORT=1025 # default port of MailHog
DEVE_MAIL_SMTP_METHOD=plain
DEVE_MAIL_PASSWORD=test # default password of MailHog
PROD_MAIL_USER=test # default username of MailHog
PROD_MAIL_SMTP_HOST=mail-dev # container name of MailHog
PROD_MAIL_SMTP_PORT=1025 # default port of MailHog
PROD_MAIL_SMTP_METHOD=plain
PROD_MAIL_PASSWORD=test # default password of MailHog
environment_file
}
main () {
is_environement_file_already_exist
generate_all_variables
create_the_environment_file
}
main