forked from FIWARE/tutorials.Understanding-At-Context
-
Notifications
You must be signed in to change notification settings - Fork 0
/
services
executable file
·76 lines (66 loc) · 2.05 KB
/
services
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# Command Line Interface to start all services associated with the Tutorial
# For this tutorial the commands are merely a convenience script to run docker or docker-compose
#
# Each services script can be run using either docker-compose (the external tool with the hyphen -)
# or docker compose (the newer version directly bundled with Docker with a space )
#
# if you start up with the following command:
#
# ./services start legacy
#
# This will force the script to use docker-compose which may be more reliable in
# some cases (or if an older version of Docker is being used)
set -e
if (( $# < 1 )); then
echo "Illegal number of parameters"
echo "usage: services [create|markdown|ngsi|jsonld|validate]"
exit 1
fi
command="$1"
file=""
if (( $# == 2 )); then
file="$2"
fi
case "${command}" in
"help")
echo "usage: services [create|markdown|ngsi|jsonld|validate]"
;;
"create")
export $(cat .env | grep "#" -v)
export $(cat .env | grep "#" -v)
docker build -t contextgen ./context-file-generator
;;
"markdown")
echo "Creating Documentation for the Data Models"
docker run --rm -v $(pwd)/:/files contextgen markdown -i "/files/${file}" > datamodels.md
echo "datamodels.md created"
;;
"ngsi")
echo "Creating a NGSI-LD @context file for normalized interactions"
docker run --rm -v $(pwd)/:/files contextgen ngsi -i "/files/${file}" > datamodels.context-ngsi.jsonld
echo "datamodels.context-ngsi.jsonld created"
;;
"jsonld")
echo "Creating a JSON-LD @context file for key-values interactions"
docker run --rm -v $(pwd)/:/files contextgen jsonld -i "/files/${file}" > datamodels.context.jsonld
echo "datamodels.context.jsonld created"
;;
"validate")
docker run --rm -v $(pwd)/:/files contextgen validate -i "/files/${file}"
;;
"start")
export $(cat .env | grep "#" -v)
./services ngsi $2
;;
"stop")
export $(cat .env | grep "#" -v)
echo "no services running."
;;
*)
echo "Command not Found."
echo "usage: services [create|markdown|ngsi|jsonld|validate]"
exit 127;
;;
esac