-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·58 lines (50 loc) · 1.41 KB
/
init.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
#!/bin/sh
# Generate a 64-byte secret
SECRET=$(openssl rand -base64 48)
# Exit with nonzero status if no arguments are passed in
if [ $# -eq 0 ]; then
echo "No arguments provided. Using default values...\n"
postgres_user="postgres"
postgres_password="postgres"
postgres_db="fuecoco-db-dev"
postgres_port="5432"
else
postgres_user=$1
postgres_password=$2
postgres_db=$3
postgres_port=$4
fi
echo "POSTGRES_USER=$postgres_user"
echo "POSTGRES_PASSWORD=$postgres_password"
echo "POSTGRES_DB=$postgres_db"
echo "POSTGRES_PORT=$postgres_port\n"
# POSTGRES ENV FILE SETUP
if [ -f .env.postgres ]; then
echo ".env.postgres exists. skipping...\n"
else
echo ".Creating .env.postgres ..."
touch .env.postgres
echo "POSTGRES_USER=$postgres_user" >> .env.postgres
echo "POSTGRES_PASSWORD=$postgres_password" >> .env.postgres
echo "POSTGRES_DB=$postgres_db" >> .env.postgres
echo "POSTGRES_PORT=5432" >> .env.postgres
echo "done creating .env.postgres\n"
fi
# FRONTEND ENV FILE SETUP
if [ -f frontend/.env ]; then
echo "frontend/.env.postgres exists. skipping...\n"
else
echo "Creating frontend/.env ..."
touch frontend/.env
echo "AUTH_SECRET='$SECRET'" >> frontend/.env
echo "done creating frontend/.env\n"
fi
# BACKEND ENV FILE SETUP
if [ -f .env ]; then
echo ".env exists. skipping...\n"
else
echo "Creating .env ..."
touch .env
echo "AUTH_SECRET='$SECRET'" >> .env
echo "done creating .env"
fi