-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakeConfigs.sh
147 lines (118 loc) · 3.56 KB
/
makeConfigs.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
echo "Checking for config files..."
if [ -f ".env" ]; then
echo ".env file exists, please delete it if you want to make a new one"
else
echo "Database config file does not exist"
echo "Creating Database config file"
echo "Making config files for Database"
echo "Please enter the mongoDB URI"
if [ -z "$1" ]; then
read -p "URI: " uri
else
uri=$1
fi
echo "Please enter the mongoDB database name"
if [ -z "$2" ]; then
read -p "Database: " database
else
database=$2
fi
echo "Please enter the mongoDB collection name for the notes"
if [ -z "$3" ]; then
read -p "Collection: " collection
else
collection=$3
fi
echo "Please enter the mongoDB username"
if [ -z "$4" ]; then
read -p "Username: " username
else
username=$4
fi
echo "Please enter the mongoDB password"
if [ -z "$5" ]; then
read -p "Password: " password
else
password=$5
fi
echo "Please enter the mongoDB collection name for the users"
if [ -z "$6" ]; then
read -p "User Collection: " userCollection
else
userCollection=$6
fi
echo "Please enter the mongoDB collection name for the groups"
if [ -z "$7" ]; then
read -p "Group Collection: " groupCollection
else
groupCollection=$7
fi
if [ -z "$8" ]; then
echo -e "\e[32mGenerating a secret key (used for the flask app)...\e[0m"
secretKey=$(openssl rand -hex 32)
echo -e "\e[32mSecret key generated\e[0m"
else
secretKey=$8
fi
if [ -z "$9" ]; then
read -p "Encrypted? (y/n): HIGHLY RECOMMENDED " encrypted
else
encrypted=$9
fi
if [ "$encrypted" = "y" ]; then
echo -e "\e[32mGenerating an encryption key (used for sensitive info)...\e[0m"
while [ ${#encryptionKey} -lt 32 ]; do
random_bytes=$(openssl rand -hex 16)
encryptionKey=$(echo -n "$random_bytes" | base64 -d | head -c 32 | base64 -w 0)
done
echo -e "\e[32mEncryption key generated\e[0m"
fi
echo "Please enter the mongoDB collection name for the global messages"
if [ -z "${14}" ]; then
read -p "Global message Collection: " gMessageCollection
else
userCollection=${14}
fi
echo "Stripe Details"
echo "Please enter the Stripe publishable key"
if [ -z "${10}" ]; then
read -p "Stripe Publishable Key: " stripeKeyPublishable
else
stripeKey=${10}
fi
echo "Please enter the Stripe secret key"
if [ -z "${11}" ]; then
read -p "Stripe Secret Key: " stripeKeySecret
else
stripeKey=${11}
fi
echo "Please enter the Stripe price ID"
if [ -z "${12}" ]; then
read -p "Stripe Price ID: " stripePriceID
else
stripePriceID=${12}
fi
echo "Please enter the Stripe endpoint secret for the webhook"
echo "Please enter the Stripe price ID"
if [ -z "${13}" ]; then
read -p "Stripe E.P: " stripeEP
else
stripePriceID=${13}
fi
echo 'URI='"${uri}"'
DATABASE='"${database}"'
COLLECTION='"${collection}"'
USERNAME='"${username}"'
PASSWORD='"${password}"'
USERCOLLECTION='"${userCollection}"'
GROUPCOLLECTION='"${groupCollection}"'
SECRETKEY='"$secretKey"'
ENCRYPTIONKEY='"$encryptionKey"'
GMESSAGECOLLECTION='"${gMessageCollection}"'
PUBLISHSTRIPEKEY='"${stripeKeyPublishable}"'
SECRETSTRIPEKEY='"${stripeKeySecret}"'
STRIPEPRICEID='"${stripePriceID}"'
STRIPEENDPOINTSECRET='"${stripeEP}"'
' >> .env
echo -e "\e[32mConfig file created\e[0m"
fi