File tree Expand file tree Collapse file tree 1 file changed +33
-4
lines changed
Expand file tree Collapse file tree 1 file changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -201,17 +201,46 @@ if [ "$app" == 0 ] && [ "$UPTIMEROBOT_API_KEY" != "" ] && [ "$UPTIMEROBOT_ALERT_
201201 fi
202202fi
203203
204- if [ " $app " == 0 ]; then
204+ # if [ "$app" == 0 ]; then
205205 if [ -n " $4 " ]; then
206206 baseConfig=" $4 "
207207 else
208208 echo " Which basic config do you want to include?"
209209 read -r baseConfig
210210 fi
211211 if [ -n " $baseConfig " ]; then
212- # Needs to be in CouchDB '/_bulk_docs' format: https://docs.couchdb.org/en/stable/api/database/bulk-api.html#updating-documents-in-bulk
213- curl -u " admin:$COUCHDB_PASSWORD " -d " @baseConfigs/$baseConfig .json" -H ' Content-Type: application/json' " https://$APP_URL /db/app/_bulk_docs"
212+ source " $path /.env"
213+ if [ " $backend " == 1 ]; then
214+ couchdb=" https://$APP_URL /db/couchdb"
215+ else
216+ couchdb=" https://$APP_URL /db"
217+ fi
218+
219+ # Needs to be in CouchDB '/_bulk_docs' format: https://docs.couchdb.org/en/stable/api/database/bulk-api.html#updating-documents-in-bulk
220+ curl -u " admin:$COUCHDB_PASSWORD " -d " @baseConfigs/$baseConfig /entities.json" -H ' Content-Type: application/json' " $couchdb /app/_bulk_docs"
221+ if [ -d " baseConfigs/$baseConfig /attachments" ]; then
222+ # Uploading attachments - ONLY IMAGES ARE SUPPORTED
223+ # create folder inside 'attachments' with name of the entity containing images with name of the property
224+ for dir in baseConfigs/" $baseConfig " /attachments/*
225+ do
226+ entity=${dir##*/ }
227+ # Create parent document
228+ rev=$( curl -X PUT -u " admin:$COUCHDB_PASSWORD " " $couchdb /app-attachments/$entity " )
229+ rev=" ${rev#* \" rev\" : \" } "
230+ rev=" ${rev%% \" * } "
231+ for file in dir/*
232+ do
233+ prop=" ${file##*/ } "
234+ ext=" ${prop##* .} "
235+ prop=" ${prop%% .* } "
236+ # Upload image
237+ rev=$( curl -X PUT -u " admin:$COUCHDB_PASSWORD " -H " Content-Type: image/$ext " -d " @$file " " $couchdb /app-attachments/$entity /$prop ?rev=$rev " )
238+ rev=" ${rev#* \" rev\" : \" } "
239+ rev=" ${rev%% \" * } "
240+ done
241+ done
242+ fi
214243 fi
215- fi
244+ # fi
216245
217246echo " app is now available under https://$APP_URL "
You can’t perform that action at this time.
0 commit comments