File tree Expand file tree Collapse file tree 1 file changed +32
-4
lines changed
Expand file tree Collapse file tree 1 file changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -201,17 +201,45 @@ 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+ if [ " $backend " == 1 ]; then
213+ couchdb=" https://$APP_URL /db/couchdb"
214+ else
215+ couchdb=" https://$APP_URL /db"
216+ fi
217+
218+ # Needs to be in CouchDB '/_bulk_docs' format: https://docs.couchdb.org/en/stable/api/database/bulk-api.html#updating-documents-in-bulk
219+ curl -u " admin:$COUCHDB_PASSWORD " -d " @baseConfigs/$baseConfig /entities.json" -H ' Content-Type: application/json' " $couchdb /app/_bulk_docs"
220+ if [ -d " baseConfigs/$baseConfig /attachments" ]; then
221+ # Uploading attachments - ONLY IMAGES ARE SUPPORTED
222+ # create folder inside 'attachments' with name of the entity containing images with name of the property
223+ for dir in baseConfigs/" $baseConfig " /attachments/*
224+ do
225+ entity=${dir##*/ }
226+ # Create parent document
227+ rev=$( curl -X PUT -u " admin:$COUCHDB_PASSWORD " " $couchdb /app-attachments/$entity " )
228+ rev=" ${rev#* \" rev\" : \" } "
229+ rev=" ${rev%% \" * } "
230+ for file in dir/*
231+ do
232+ prop=" ${file##*/ } "
233+ ext=" ${prop##* .} "
234+ prop=" ${prop%% .* } "
235+ # Upload image
236+ rev=$( curl -X PUT -u " admin:$COUCHDB_PASSWORD " -H " Content-Type: image/$ext " -d " @$file " " $couchdb /app-attachments/$entity /$prop ?rev=$rev " )
237+ rev=" ${rev#* \" rev\" : \" } "
238+ rev=" ${rev%% \" * } "
239+ done
240+ done
241+ fi
214242 fi
215- fi
243+ # fi
216244
217245echo " app is now available under https://$APP_URL "
You can’t perform that action at this time.
0 commit comments