-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal-run.sh
executable file
·182 lines (141 loc) · 5.87 KB
/
local-run.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/env bash
source ./terminal.sh
customize_terminal_output
help()
{
# Display Help
echo
echo "${header}******************** Usage and Options ********************${reset}"
echo "Usage:"
echo " ./local-run.sh [OPTIONS]"
echo " Starts an RDFox container with an injected license."
echo
echo "Options:"
echo " -u User."
echo " -p Password."
echo " -r HTTP port number."
echo " -n Repository name. "
echo " -t Repository type: par-simple-nn, par-simple-nw, par-simple-ww, par-complex-nn, par-complex-nw, par-complex-ww. Refer to the RDFox documentation for more details."
echo " -h Help."
echo
exit 0
}
echo "${header}Set and validate input parameters${reset}"
while getopts ":u:p:r:n:t:h:" opt; do
case $opt in
u) user="$OPTARG"
;;
p) password="$OPTARG"
;;
r) port="$OPTARG"
;;
n) repositoryname="$OPTARG"
;;
t) repositorytype="$OPTARG"
;;
h) help
;;
*)
echo "${error}ERROR${reset}: Invalid parameter."
help
;;
u|p|r|n|t|h)
;;
esac
case $OPTARG in
-*) echo "Option $opt needs a valid argument"
exit 1
;;
esac
done
if [[ -z "${repositorytype}" ]] ; then
repositorytype="par-complex-nn"
fi
if [[ -z "${port}" ]] ; then
port="12110"
fi
if [[ -z "${user}" ]] || [[ -z "${password}" ]] || [[ -z "${repositoryname}" ]] ; then
echo "${error}ERROR${reset}: A mandatory paramenter is missing."
help
fi
echo "user: "$user
echo "password: "$password
echo "port: "$port
echo "repositoryname: "$repositoryname
echo "repositorytype: "$repositorytype
echo "Parameter validation complete. "
echo "${header}Build Image${reset}"
./local-build.sh || exit $?
echo "${header}Run Container, Start RDFox Server and Create Repository${reset}"
{
# cap-drop ALL: oxfordsemantic/rdfox repositoryname have been designed to run with no superuser capabilities
docker run --rm --cap-drop ALL --name rdfoxcontainer \
--env RDFOX_LICENSE_BASE64=${RDFOX_LICENSE_BASE64} \
--env RDFOX_USER=${user} \
--env RDFOX_PASSWORD=${password} \
--env RDFOX_PORT=${port} \
--env RDFOX_REPOSITORYNAME=${repositoryname} \
--env RDFOX_REPOSITORYTYPE=${repositorytype} \
-v $(pwd)/data:/home/rdfox/data -v $(pwd)/ontology:/home/rdfox/ontology \
-p 12110:12110 $(< image.id)
}& # Start the RDFox Container in the background
test=1
while [ ${test} != 0 ]; do
# It will try to connect to the server every second until the server is available. Failed attempts to connect will not throw errors.
curl -X POST --user "${user}":"${password}" "localhost:${port}/datastores/${repositoryname}?type=${repositorytype}" 2>/dev/null
test="${?}"
sleep 0.5
done
# Grant full access to all downloaded data files and ontologies, rules and queries.
chmod -R u+rwx data
chmod -R u+rwx ontology
chmod -R u+rwx rules
chmod -R u+rwx queries
# ls -al data
# ls -al ontology
# Include the Northwind Sample Data Store for Demos
echo "${header}Set up Nothwind sample data store${reset}"
# Create the Northwind repository
curl -X POST \
--user "${user}":"${password}" "localhost:${port}/datastores/Northwind?type=par-complex-nn"
# Import the data into the dataGraph
curl -X POST -G \
--data-urlencode "default-graph-name=http://www.mysparql.com/resource/northwind/dataGraph" \
--user "${user}":"${password}" "localhost:${port}/datastores/Northwind/content" -H "Content-Type:" -T "data/dumpdataNTRIPLE7.nt"
# Import the rules
curl -X POST -G \
--data-urlencode "default-graph-name=http://www.mysparql.com/resource/northwind/dataGraph" \
--user "${user}":"${password}" -H "Content-Type:" -T "rules/nwrule1.dlog" "localhost:12110/datastores/Northwind/content"
# curl -X POST --user admin:admin -H "Content-Type:" -T "rules/nwrule1.dlog" "localhost:12110/datastores/Northwind/content"
# curl PATCH --user "${user}":"${password}" -H "Content-Type:" "localhost:${port}/datastores/Northwind/content?operation=add-axioms&source-graph-name=dataGraph&destination-graph-name=axiomGraph"
# curl PATCH --user "admin":"admin" "localhost:12110/datastores/Northwind/content?operation=add-axioms&source-graph-name=#data&destination-graph-name=axiomGraph"
echo "${header}List Repositories${reset}"
curl -X GET --user "${user}":"${password}" "localhost:${port}/datastores"
echo "${header}Download LUBM Test Datasets${reset}"
# Download the test dataset from gcloud
# TODO: Automate authentication, which is currently done via browser login.
gsutil -o GSUtil:parallel_process_count=1 rsync -r gs://lubm-benchmark ./data
echo "${header}Import Data${reset}"
curl -X POST -G \
--data-urlencode "default-graph-name=http://swat.cse.lehigh.edu/onto/univ-bench.owl#data" \
--user "${user}":"${password}" "localhost:${port}/datastores/${repositoryname}/content" \
-H "Content-Type:" -T "data/lubm-10-universities.nt"
echo "${header}Import LUBM Ontology${reset}"
curl -X POST -G \
--data-urlencode "default-graph-name=http://swat.cse.lehigh.edu/onto/univ-bench.owl#ontology" \
--user "${user}":"${password}" -H "Content-Type:text/turtle" -T "ontology/univ-bench.ttl" \
"localhost:${port}/datastores/${repositoryname}/content"
echo "${header}Import LUBM Rules${reset}"
curl -X POST -G \
--data-urlencode "default-graph-name=http://swat.cse.lehigh.edu/onto/univ-bench.owl#ontology" \
--user "${user}":"${password}" -H "Content-Type:" -T "rules/rule2.dlog" \
"localhost:${port}/datastores/${repositoryname}/content"
curl -X POST -G \
--data-urlencode "default-graph-name=http://swat.cse.lehigh.edu/onto/univ-bench.owl#ontology" \
--user "${user}":"${password}" -H "Content-Type:" -T "rules/rule9.dlog" \
"localhost:${port}/datastores/${repositoryname}/content"
# TODO: remaining tasks here...
# dstore create LUBM par-complex-nn -persist-df=file
# -persist-roles=file -init-resource-capacity=1000000
# -init-triple-capacity=140000000 auto-update-statistics true
echo "${header}******************* THE END *******************${reset}"