-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathentrypoint.sh
executable file
·67 lines (56 loc) · 2.5 KB
/
entrypoint.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
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
#!/bin/sh
##################################################################
# Check for required environment variables #
# In case they are not set, use default config.json file instead #
##################################################################
if [ -z "${ENDPOINT_URL}" ]; then
echo "ENDPOINT_URL is not set, let's keep the current config.json file."
exit 0
fi
#########################################################
# Set default values for optional environment variables #
#########################################################
if [ -z "${SPARQL_CONSOLE_URL}" ]; then
echo "SPARQL_CONSOLE_URL is not set, let's use 'http://example.com/sparql/#query' as default value."
SPARQL_CONSOLE_URL="http://example.com/sparql/#query"
fi
if [ -z "${GRAPH_EXPLORER_URL}" ]; then
echo "GRAPH_EXPLORER_URL is not set, let's use 'http://example.com/graph-explorer/?resource' as default value."
GRAPH_EXPLORER_URL="http://example.com/graph-explorer/?resource"
fi
if [ -z "${FULL_TEXT_SEARCH_DIALECT}" ]; then
echo "FULL_TEXT_SEARCH_DIALECT is not set, let's use 'fuseki' as default value."
FULL_TEXT_SEARCH_DIALECT="fuseki"
fi
if [ -z "${NEPTUNE_FTS_ENDPOINT}" ]; then
# Check if the full-text search endpoint is set to "neptune", and only display the warning message in this case
if [ "${FULL_TEXT_SEARCH_DIALECT}" = "neptune" ]; then
echo "NEPTUNE_FTS_ENDPOINT is not set, let's use 'http://example.com/' as default value."
fi
NEPTUNE_FTS_ENDPOINT="http://example.com/"
fi
########################################################
# Generate config.json file from environment variables #
########################################################
echo "Generating config.json file with the following values:"
echo "- ENDPOINT_URL: ${ENDPOINT_URL}"
echo "- SPARQL_CONSOLE_URL: ${SPARQL_CONSOLE_URL}"
echo "- GRAPH_EXPLORER_URL: ${GRAPH_EXPLORER_URL}"
echo "- FULL_TEXT_SEARCH_DIALECT: ${FULL_TEXT_SEARCH_DIALECT}"
echo "- NEPTUNE_FTS_ENDPOINT: ${NEPTUNE_FTS_ENDPOINT}"
jq -n \
--arg endpointUrl "${ENDPOINT_URL}" \
--arg sparqlConsoleUrl "${SPARQL_CONSOLE_URL}" \
--arg graphExplorerUrl "${GRAPH_EXPLORER_URL}" \
--arg fullTextSearchDialect "${FULL_TEXT_SEARCH_DIALECT}" \
--arg ftsEndpoint "${NEPTUNE_FTS_ENDPOINT}" \
'{
"endpointUrl": $endpointUrl,
"sparqlConsoleUrl": $sparqlConsoleUrl,
"graphExplorerUrl": $graphExplorerUrl,
"fullTextSearchDialect": $fullTextSearchDialect,
"neptune": {
"ftsEndpoint": $ftsEndpoint
}
}' > /app/config.json
exit 0