forked from UltiMafia/Ultimafia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
totalsetup.sh
106 lines (79 loc) · 4.01 KB
/
totalsetup.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
echo "Welcome to the Ultimafia complete setup!"
echo "----------------------------------------"
cp ./docs/client_env ./react_main/.env
cp ./docs/server_env ./.env
echo "If you have not done so yet, go and set up your Firebase."
echo "Once that is done, please enter your Firebase code (press Ctrl+D TWICE when done): "
js_code=$(cat)
# Extract values using grep and awk
apiKey=$(echo "$js_code" | grep -o 'apiKey: ".*"' | awk -F '"' '{print $2}')
authDomain=$(echo "$js_code" | grep -o 'authDomain: ".*"' | awk -F '"' '{print $2}')
projectId=$(echo "$js_code" | grep -o 'projectId: ".*"' | awk -F '"' '{print $2}')
storageBucket=$(echo "$js_code" | grep -o 'storageBucket: ".*"' | awk -F '"' '{print $2}')
messagingSenderId=$(echo "$js_code" | grep -o 'messagingSenderId: ".*"' | awk -F '"' '{print $2}')
appId=$(echo "$js_code" | grep -o 'appId: ".*"' | awk -F '"' '{print $2}')
measurementId=$(echo "$js_code" | grep -o 'measurementId: ".*"' | awk -F '"' '{print $2}')
backFbKey="FIREBASE_API_KEY=x"
backFbKeyRep="FIREBASE_API_KEY=$apiKey"
sed -i "s/$backFbKey/$backFbKeyRep/" "./.env"
backFbAuthD="FIREBASE_AUTH_DOMAIN=x.firebaseapp.com"
backFbAuthDRep="FIREBASE_AUTH_DOMAIN=$authDomain"
sed -i "s/$backFbAuthD/$backFbAuthDRep/" "./.env"
backFbProjId="FIREBASE_PROJECT_ID=x"
backFbProjIdRep="FIREBASE_PROJECT_ID=$projectId"
sed -i "s/$backFbProjId/$backFbProjIdRep/" "./.env"
backFbMsgId="FIREBASE_MESSAGING_SENDER_ID=x"
backFbMsgIdRep="FIREBASE_MESSAGING_SENDER_ID=$messagingSenderId"
sed -i "s/$backFbMsgId/$backFbMsgIdRep/" "./.env"
backFbAppId="FIREBASE_APP_ID=x"
backFbAppIdRep="FIREBASE_APP_ID=$appId"
sed -i "s/$backFbAppId/$backFbAppIdRep/" "./.env"
backFbMeasureId="FIREBASE_MEASUREMENT_ID=x"
backFbMeasureIdRep="FIREBASE_MEASUREMENT_ID=$measurementId"
sed -i "s/$backFbMeasureId/$backFbMeasureIdRep/" "./.env"
#-----------------------------------------------------------------
frontFbKey="REACT_APP_FIREBASE_API_KEY=x"
frontFbKeyRep="REACT_APP_FIREBASE_API_KEY=$apiKey"
sed -i "s/$frontFbKey/$frontFbKeyRep/" "./react_main/.env"
frontFbAuthD="REACT_APP_FIREBASE_AUTH_DOMAIN=x.firebaseapp.com"
frontFbAuthDRep="REACT_APP_FIREBASE_AUTH_DOMAIN=$authDomain"
sed -i "s/$frontFbAuthD/$frontFbAuthDRep/" "./react_main/.env"
frontFbProjId="REACT_APP_FIREBASE_PROJECT_ID=x"
frontFbProjIdRep="REACT_APP_FIREBASE_PROJECT_ID=$projectId"
sed -i "s/$frontFbProjId/$frontFbProjIdRep/" "./react_main/.env"
frontFbMsgId="REACT_APP_FIREBASE_MESSAGING_SENDER_ID=x"
frontFbMsgIdRep="REACT_APP_FIREBASE_MESSAGING_SENDER_ID=$messagingSenderId"
sed -i "s/$frontFbMsgId/$frontFbMsgIdRep/" "./react_main/.env"
frontFbAppId="REACT_APP_FIREBASE_APP_ID=x"
frontFbAppIdRep="REACT_APP_FIREBASE_APP_ID=$appId"
sed -i "s/$frontFbAppId/$frontFbAppIdRep/" "./react_main/.env"
frontFbMeasureId="REACT_APP_FIREBASE_MEASUREMENT_ID=x"
frontFbMeasureIdRep="REACT_APP_FIREBASE_MEASUREMENT_ID=$measurementId"
sed -i "s/$frontFbMeasureId/$frontFbMeasureIdRep/" "./react_main/.env"
frontFbStorageB="REACT_APP_FIREBASE_STORAGE_BUCKET=x.appspot.com"
frontFbStorageBRep="REACT_APP_FIREBASE_STORAGE_BUCKET=$storageBucket"
sed -i "s/$frontFbStorageB/$frontFbStorageBRep/" "./react_main/.env"
echo ""
echo "Now check the firebase console, go to Project settings (gear icon)"
echo "Then click on the 'Service Accounts' tab, and click on the 'Generate new Private key' button"
echo "rename that file to firebase.json, and copy it into your Ultimafia directory."
echo "Press Enter when you are done."
read endVar
echo "Make sure your firebase project has authentication setup"
echo "Also make sure that it has both EMAIL and GOOGLE providers enabled"
echo "Lastly, for signing in to your page, go to:"
echo "Authentication -> Settings -> Authorized Domains"
echo "Then add: 127.0.0.1 to the list of Authorized domains, and save it."
echo "Press Enter when you are done."
read endVar
echo "Great! Now the rest of this should be automatic… please wait…"
export NVM_DIR=~/nvm;
source $NVM_DIR/nvm.sh;
nvm install 14.16.0
nvm use 14.16.0
npm install
cd react_main
npm install
bash build.sh
cd ..
docker-compose up --build