-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-env.sh
executable file
·57 lines (39 loc) · 1.28 KB
/
generate-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
#!/bin/bash
# Forked from https://raw.githubusercontent.com/AudeizReading/ft_transcendence_42/master/app/generate-env.sh
cd "$(dirname "$0")"
if [ -f ".env" ]; then
echo ".env already exist"
printf "overwrite? (y/N) "; read -n 1 DoIOverwrite; printf "\n"
if [ "$DoIOverwrite" != "y" ] && [ "$DoIOverwrite" != "Y" ]; then
exit
fi
fi
printf "Some variables will be asked, press \`enter\` for none.\nGet all informations from one of your apps on https://profile.intra.42.fr/oauth/applications\n\n"
cat << EOF > .env
# 42's api keys
CLIENT_ID=$(printf "Write your 42 uid api: " 1>&2; read api; echo $api)
CLIENT_SECRET=$(printf "Write your 42 secret api: " 1>&2; read api; echo $api)
EOF
printf "\n\e[0;32mWrite the \`redirect_uri\` that you've configured in your api's settings\e[0m\n"
cat << EOF >> .env
REDIRECT_URI=$(printf "Write your \`redirect_uri\`: " 1>&2; read api; echo $api)
EOF
printf "\n"
cat << EOF >> .env
JWT_SECRET=$(openssl rand -base64 32)
EOF
if [[ -n $USER ]]
then
PG_USER=$USER
else
PG_USER=admin
fi
PG_PASSWORD=$(openssl rand -base64 32)
cat << EOF >> .env
# Postgres
POSTGRES_HOST=postgres
POSTGRES_DB=ft_transcendence
POSTGRES_USER=$PG_USER
POSTGRES_PASSWORD=$PG_PASSWORD
EOF
printf "Your generated PostgreSQL password for '$PG_USER' is '$PG_PASSWORD'\n"