This repository was archived by the owner on Nov 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdeleteAndLoadSnapsets.sh
More file actions
executable file
·59 lines (48 loc) · 1.51 KB
/
deleteAndLoadSnapsets.sh
File metadata and controls
executable file
·59 lines (48 loc) · 1.51 KB
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
#!/bin/sh
STATIC_DATA_DIR=${STATIC_DATA_DIR:-/home/node/universal/testData/dbData}
BUILD_DATA_DIR=${BUILD_DATA_DIR:-/home/node/universal/build/dbData/snapset}
log() {
echo "$(date +'%Y-%m-%d %H:%M:%S') - $1"
}
# Verify variables
if [ -z "$COUCHDB_URL" ]; then
echo "COUCHDB_URL environment variable must be defined"
exit 1
fi
if [ ! -d "$STATIC_DATA_DIR" -o ! "$(ls -A $STATIC_DATA_DIR/*.json)" ]; then
echo "STATIC_DATA_DIR ($STATIC_DATA_DIR) must exist and contain data"
exit 1
fi
if [ ! -d "$BUILD_DATA_DIR" -o ! "$(ls -A $BUILD_DATA_DIR/*.json)" ]; then
echo "BUILD_DATA_DIR ($BUILD_DATA_DIR) must exist and contain data"
exit 1
fi
log "Starting"
log "CouchDB: $COUCHDB_URL"
log "Clear index: $CLEAR_INDEX"
log "Static: $STATIC_DATA_DIR"
log "Build: $BUILD_DATA_DIR"
log "Working directory: `pwd`"
# Set up universal
git clone --depth 1 https://github.com/GPII/universal.git
cd universal
npm install json5
npm install fs
npm install rimraf
npm install mkdirp
npm install infusion
rm -f package-lock.json
node scripts/convertPrefs.js testData/preferences/ build/dbData/snapset snapset
# Initialize (possibly clear) data base
if [ ! -z "$CLEAR_INDEX" ]; then
log "Deleting database at $COUCHDB_URL"
if ! curl -fsS -X DELETE "$COUCHDB_URL"; then
log "Error deleting database"
fi
fi
log "Creating database at $COUCHDB_URL"
if ! curl -fsS -X PUT "$COUCHDB_URL"; then
log "Database already exists at $COUCHDB_URL"
fi
# Submit data
node scripts/deleteAndLoadSnapsets.js $COUCHDB_URL $STATIC_DATA_DIR $BUILD_DATA_DIR