-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate.sh
executable file
·222 lines (208 loc) · 9.55 KB
/
generate.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/bin/bash
dockerTag=57d4b5fdb837d1b7f05f2a9d451b4310309b95c5
mongoInitCreds() {
read -p " Database Connection URL: " mongoURL
read -p " Use SSL/TLS (Y/N): " usesTLS
if [ "$usesTLS" = "Y" ] || [ "$usesTLS" = "y" ]; then
read -p " Certificate File Path: " mongoCertificatePath
mongoCertificate=$(cat $mongoCertificatePath)
else
unset mongoCertificate
fi
}
mongoCreds() {
if [ "$mongoURL" ]; then
read -p " Use Existing Mongo Credentials (Y/N): " wantExistingMongoCreds
if [ "$wantExistingMongoCreds" = "N" ] || [ "$wantExistingMongoCreds" = "n" ]; then
mongoInitCreds
fi
else
mongoInitCreds
fi
}
postgresInitCreds() {
read -p " Host: " postgresHost
read -p " Port: " postgresPort
read -p " User: " postgresUser
read -p " Password: " postgresPassword
read -p " Use SSL/TLS (Y/N): " usesTLS
if [ "$usesTLS" = "Y" ] || [ "$usesTLS" = "y" ]; then
read -p " Certificate File Path: " postgresCertificatePath
postgresCertificate=$(cat $postgresCertificatePath)
read -p " Database: " postgresDB
else
unset postgresCertificate
fi
}
postgresCreds() {
if [ "$postgresHost" ]; then
read -p " Use Existing Postgres Credentials (Y/N): " wantExistingPostgresCreds
if [ "$wantExistingPostgresCreds" = "N" ] || [ "$wantExistingPostgresCreds" = "n" ]; then
postgresInitCreds
fi
else
postgresInitCreds
fi
}
couchInitCreds() {
read -p " Database Connection URL: " couchURL
}
couchCreds() {
if [ "$couchURL" ]; then
read -p " Use Existing Couch/Cloudant Credentials (Y/N): " wantExistingCouchCreds
if [ "$wantExistingCouchCreds" = "N" ] || [ "$wantExistingCouchCreds" = "n" ]; then
couchInitCreds
fi
else
couchInitCreds
fi
}
echo "Welcome to the Bee Travels Data Generating Script"
echo "Please answer the following options to configure your data:"
echo ""
read -p "Destination Data (Y/N): " wantsDestinationData
if [ "$wantsDestinationData" = "Y" ] || [ "$wantsDestinationData" = "y" ]; then
read -p " Generate Destination Data (Y/N): " wantsGenerateDestinationData
if [ "$wantsGenerateDestinationData" = "Y" ] || [ "$wantsGenerateDestinationData" = "y" ]; then
generateDestinationData=true
else
generateDestinationData=false
fi
read -p " Database (mongodb/postgres/couchdb/cloudant): " destinationDatabase
if [ "$destinationDatabase" = "mongodb" ]; then
mongoCreds
echo ""
echo "Starting Destination data process"
if [ "$mongoCertificate" ]; then
docker run --net host -e GENERATE_DATA=$generateDestinationData -e DATABASE=mongodb -e DATABASE_CERT="$mongoCertificate" -e MONGO_CONNECTION_URL=$mongoURL beetravels/data-gen-destination:$dockerTag
else
docker run --net host -e GENERATE_DATA=$generateDestinationData -e DATABASE=mongodb -e MONGO_CONNECTION_URL=$mongoURL beetravels/data-gen-destination:$dockerTag
fi
elif [ "$destinationDatabase" = "postgres" ]; then
postgresCreds
echo ""
echo "Starting Destination data process"
if [ "$postgresCertificate" ]; then
docker run --net host -e GENERATE_DATA=$generateDestinationData -e DATABASE=postgres -e DATABASE_CERT="$postgresCertificate" -e PG_HOST=$postgresHost -e PG_PORT=$postgresPort -e PG_USER=$postgresUser -e PG_PASSWORD=$postgresPassword -e PG_DB=$postgresDB beetravels/data-gen-destination:$dockerTag
else
docker run --net host -e GENERATE_DATA=$generateDestinationData -e DATABASE=postgres -e PG_HOST=$postgresHost -e PG_PORT=$postgresPort -e PG_USER=$postgresUser -e PG_PASSWORD=$postgresPassword beetravels/data-gen-destination:$dockerTag
fi
elif [ "$destinationDatabase" = "couchdb" ] || [ "$destinationDatabase" = "cloudant" ]; then
couchCreds
echo ""
echo "Starting Destination data process"
docker run --net host -e GENERATE_DATA=$generateDestinationData -e DATABASE=couchdb -e COUCH_CONNECTION_URL=$couchURL beetravels/data-gen-destination:$dockerTag
fi
echo "Destination data process complete"
fi
echo ""
read -p "Hotel Data (Y/N): " wantsHotelData
if [ "$wantsHotelData" = "Y" ] || [ "$wantsHotelData" = "y" ]; then
read -p " Generate Hotel Data (Y/N): " wantsGenerateHotelData
if [ "$wantsGenerateHotelData" = "Y" ] || [ "$wantsGenerateHotelData" = "y" ]; then
generateHotelData=true
else
generateHotelData=false
fi
read -p " Database (mongodb/postgres/couchdb/cloudant): " hotelDatabase
if [ "$hotelDatabase" = "mongodb" ]; then
mongoCreds
echo ""
echo "Starting Hotel data process"
if [ "$mongoCertificate" ]; then
docker run --net host -e GENERATE_DATA=$generateHotelData -e DATABASE=mongodb -e DATABASE_CERT="$mongoCertificate" -e MONGO_CONNECTION_URL=$mongoURL beetravels/data-gen-hotel:$dockerTag
else
docker run --net host -e GENERATE_DATA=$generateHotelData -e DATABASE=mongodb -e MONGO_CONNECTION_URL=$mongoURL beetravels/data-gen-hotel:$dockerTag
fi
elif [ "$hotelDatabase" = "postgres" ]; then
postgresCreds
echo ""
echo "Starting Hotel data process"
if [ "$postgresCertificate" ]; then
docker run --net host -e GENERATE_DATA=$generateHotelData -e DATABASE=postgres -e DATABASE_CERT="$postgresCertificate" -e PG_HOST=$postgresHost -e PG_PORT=$postgresPort -e PG_USER=$postgresUser -e PG_PASSWORD=$postgresPassword -e PG_DB=$postgresDB beetravels/data-gen-hotel:$dockerTag
else
docker run --net host -e GENERATE_DATA=$generateHotelData -e DATABASE=postgres -e PG_HOST=$postgresHost -e PG_PORT=$postgresPort -e PG_USER=$postgresUser -e PG_PASSWORD=$postgresPassword beetravels/data-gen-hotel:$dockerTag
fi
elif [ "$hotelDatabase" = "couchdb" ] || [ "$hotelDatabase" = "cloudant" ]; then
couchCreds
echo ""
echo "Starting Hotel data process"
docker run --net host -e GENERATE_DATA=$generateHotelData -e DATABASE=couchdb -e COUCH_CONNECTION_URL=$couchURL beetravels/data-gen-hotel:$dockerTag
fi
echo "Hotel data process complete"
fi
echo ""
read -p "Car Rental Data (Y/N): " wantsCarData
if [ "$wantsCarData" = "Y" ] || [ "$wantsCarData" = "y" ]; then
read -p " Generate Car Rental Data (Y/N): " wantsGenerateCarData
if [ "$wantsGenerateCarData" = "Y" ] || [ "$wantsGenerateCarData" = "y" ]; then
generateCarData=true
else
generateCarData=false
fi
read -p " Database (mongodb/postgres/couchdb/cloudant): " carDatabase
if [ "$carDatabase" = "mongodb" ]; then
mongoCreds
echo ""
echo "Starting Car Rental data process"
if [ "$mongoCertificate" ]; then
docker run --net host -e GENERATE_DATA=$generateCarData -e DATABASE=mongodb -e DATABASE_CERT="$mongoCertificate" -e MONGO_CONNECTION_URL=$mongoURL beetravels/data-gen-carrental:$dockerTag
else
docker run --net host -e GENERATE_DATA=$generateCarData -e DATABASE=mongodb -e MONGO_CONNECTION_URL=$mongoURL beetravels/data-gen-carrental:$dockerTag
fi
elif [ "$carDatabase" = "postgres" ]; then
postgresCreds
echo ""
echo "Starting Car Rental data process"
if [ "$postgresCertificate" ]; then
docker run --net host -e GENERATE_DATA=$generateCarData -e DATABASE=postgres -e DATABASE_CERT="$postgresCertificate" -e PG_HOST=$postgresHost -e PG_PORT=$postgresPort -e PG_USER=$postgresUser -e PG_PASSWORD=$postgresPassword -e PG_DB=$postgresDB beetravels/data-gen-carrental:$dockerTag
else
docker run --net host -e GENERATE_DATA=$generateCarData -e DATABASE=postgres -e PG_HOST=$postgresHost -e PG_PORT=$postgresPort -e PG_USER=$postgresUser -e PG_PASSWORD=$postgresPassword beetravels/data-gen-carrental:$dockerTag
fi
elif [ "$carDatabase" = "couchdb" ] || [ "$carDatabase" = "cloudant" ]; then
couchCreds
echo ""
echo "Starting Car Rental data process"
docker run --net host -e GENERATE_DATA=$generateCarData -e DATABASE=couchdb -e COUCH_CONNECTION_URL=$couchURL beetravels/data-gen-carrental:$dockerTag
fi
echo "Car Rental data process complete"
fi
echo ""
echo "WARNING: Flight Data might take a long time to upload"
read -p "Flight Data (Y/N): " wantsFlightData
if [ "$wantsFlightData" = "Y" ] || [ "$wantsFlightData" = "y" ]; then
read -p " Generate Flight Data (Y/N): " wantsGenerateFlightData
if [ "$wantsGenerateFlightData" = "Y" ] || [ "$wantsGenerateFlightData" = "y" ]; then
generateFlightData=true
else
generateFlightData=false
fi
read -p " Database (mongodb/postgres/couchdb/cloudant): " flightDatabase
if [ "$flightDatabase" = "mongodb" ]; then
mongoCreds
echo ""
echo "Starting Flight data process"
if [ "$mongoCertificate" ]; then
docker run --net host -e GENERATE_DATA=$generateFlightData -e DATABASE=mongodb -e DATABASE_CERT="$mongoCertificate" -e MONGO_CONNECTION_URL=$mongoURL beetravels/data-gen-airports:$dockerTag
else
docker run --net host -e GENERATE_DATA=$generateFlightData -e DATABASE=mongodb -e MONGO_CONNECTION_URL=$mongoURL beetravels/data-gen-airports:$dockerTag
fi
elif [ "$flightDatabase" = "postgres" ]; then
postgresCreds
echo ""
echo "Starting Flight data process"
if [ "$postgresCertificate" ]; then
docker run --net host -e GENERATE_DATA=$generateFlightData -e DATABASE=postgres -e DATABASE_CERT="$postgresCertificate" -e PG_HOST=$postgresHost -e PG_PORT=$postgresPort -e PG_USER=$postgresUser -e PG_PASSWORD=$postgresPassword -e PG_DB=$postgresDB beetravels/data-gen-airports:$dockerTag
else
docker run --net host -e GENERATE_DATA=$generateFlightData -e DATABASE=postgres -e PG_HOST=$postgresHost -e PG_PORT=$postgresPort -e PG_USER=$postgresUser -e PG_PASSWORD=$postgresPassword beetravels/data-gen-airports:$dockerTag
fi
elif [ "$flightDatabase" = "couchdb" ] || [ "$flightDatabase" = "cloudant" ]; then
couchCreds
echo ""
echo "Starting Flight data process"
docker run --net host -e GENERATE_DATA=$generateFlightData -e DATABASE=couchdb -e COUCH_CONNECTION_URL=$couchURL beetravels/data-gen-airports:$dockerTag
fi
echo "Flight data process complete"
fi
echo ""
echo "Data generation process complete"