forked from ianblenke/safehouse
-
Notifications
You must be signed in to change notification settings - Fork 2
/
safehouse-server.sh
executable file
·33 lines (29 loc) · 1.02 KB
/
safehouse-server.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
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${DIR}"
export PATH=${DIR}/node_modules/.bin:$PATH
export ES_URL=${ES_URL:-http://localhost:9200}
export ES_HTTP_AUTH=${ES_HTTP_AUTH:-admin:changeme}
if [ -n "$CHANGE_SFALGO_MAPPING" ]; then
# Delete the existing sfalgo index
curl -viH "Content-Type: application/json" -sXDELETE -u ${ES_HTTP_AUTH} $ES_URL'/sfalgo'
# Create an index mapping for sfalgo index so that epoch DateTime field is treated as a date
curl -viH "Content-Type: application/json" -sXPUT -u ${ES_HTTP_AUTH} $ES_URL'/sfalgo' --data-binary '{
"mappings": {
"_doc": {
"properties": {
"DateTime": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}
}
}'
# Insert seed data
curl -viH "Content-Type: application/json" -sXPOST -u ${ES_HTTP_AUTH} $ES_URL'/sfalgo/_doc' --data-binary '{
"DateTime": 1523387640161,
"Status": 1
}'
fi
exec npm run ${LIFECYCLE:-prod} $@