-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·25 lines (16 loc) · 2.02 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
REV=`curl -s -X GET 'http://localhost:5984/java/classpath' | sed -e 's/.*"_rev":"\([^"]*\)".*/\1/'`
echo ${REV}
curl -s -X DELETE "http://localhost:5984/java/classpath?rev=${REV}"
RES=`curl -s -H "Content-Type: application/octect-stream" -X PUT 'http://localhost:5984/java/classpath/views.jar' --data-binary @views/target/views-0.0.1-SNAPSHOT-jar-with-dependencies.jar`
REV_NEW_JAR="$(echo ${RES} | sed -e 's/.*"rev":"\([^"]*\)".*/\1/')"
echo "Second: $REV_NEW_JAR"
DD_REV=`curl -H "Content-Type: application/json" -s -X GET 'http://localhost:5984/java/_design/java' | sed -e 's/.*"_rev":"\([^"]*\)".*/\1/'`
echo "Deleting existing design doc."
curl -s -X DELETE "http://localhost:5984/java/_design/java?rev=${DD_REV}"
echo "Adding new design doc."
#curl -H "Content-Type: application/json" -X POST 'http://localhost:5984/java' -d "{\"_id\":\"_design/java\",\"language\":\"java\",\"views\":{\"resource-by-date\":{\"map\":\"{\\\"classpath\\\":[\\\"http://127.0.0.1:5984/java/classpath/views.jar\\\"],\\\"rev\\\":\\\"${REV_NEW_JAR}\\\",\\\"classname\\\":\\\"com.sri.learningregistry.couchdb.views.ResourceDataByDateView\\\"}\"},\"simple\":{\"map\":\"{\\\"classpath\\\":[\\\"http://127.0.0.1:5984/java/classpath/views.jar\\\"],\\\"rev\\\":\\\"${REV_NEW_JAR}\\\",\\\"classname\\\":\\\"com.sri.learningregistry.couchdb.views.SampleView\\\"}\"}}}"
curl -H "Content-Type: application/json" -X POST 'http://localhost:5984/java' -d "{\"_id\":\"_design/java\",\"language\":\"java\",\"views\":{\"xmlvalidate\":{\"map\":\"{\\\"classpath\\\":[\\\"http://127.0.0.1:5984/java/classpath/views.jar\\\"],\\\"rev\\\":\\\"${REV_NEW_JAR}\\\",\\\"classname\\\":\\\"com.sri.learningregistry.couchdb.views.XMLSchemaValidationView\\\"}\"},\"simple\":{\"map\":\"{\\\"classpath\\\":[\\\"http://127.0.0.1:5984/java/classpath/views.jar\\\"],\\\"rev\\\":\\\"${REV_NEW_JAR}\\\",\\\"classname\\\":\\\"com.sri.learningregistry.couchdb.views.SampleView\\\"}\"}}}"
#echo "Restart Couch."
#curl -H "Content-Type: application/json" -X POST 'http://localhost:5984/_restart'
echo "Done"