-
Notifications
You must be signed in to change notification settings - Fork 0
/
virtuoso.sh
executable file
·65 lines (54 loc) · 2.15 KB
/
virtuoso.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
#!/bin/sh
cd /data
# Move clean-logs file
mv /virtuoso/clean-logs.sh /data/clean-logs.sh 2>/dev/null
chmod +x /data/clean-logs.sh
mkdir -p /data/dumps
# Create ini file, and convert env to ini entries
echo "Creating virtuoso.ini file..."
mv /virtuoso/virtuoso.ini /data/virtuoso.ini 2>/dev/null
echo "Converting environment variables to ini file..."
printenv | egrep "^VIRT_" | while read setting
do
section=`echo "$setting" | egrep -o "^VIRT_[^_]+" | sed 's/^.\{5\}//g'`
key=`echo "$setting" | egrep -o "_[^_]+=" | sed 's/[_=]//g'`
value=`echo "$setting" | egrep -o "=.*$" | sed 's/^=//g'`
echo "Registering $section[$key] to be $value"
crudini --set /data/virtuoso.ini "$section" "$key" "$value"
done
# Set dba password
touch /sql-query.sql
echo "Updating dba password and sparql update..."
if [ "$DBA_PASSWORD" ]; then echo "user_set_password('dba', '$DBA_PASSWORD');" >> /sql-query.sql ; fi
if [ "$SPARQL_UPDATE" = "true" ]; then echo "GRANT SPARQL_UPDATE to \"SPARQL\";" >> /sql-query.sql ; fi
# Start virtuoso
virtuoso-t +wait
# Enable CORS
isql-v -U dba -P dba < /virtuoso/enable_cors.sql
# Create dump_nquads procedure
isql-v -U dba -P dba < /virtuoso/dump_nquads_procedure.sql
# Install facet browser
echo "vad_install('/usr/local/virtuoso-opensource/share/virtuoso/vad/fct_dav.vad');" | isql-v -U dba -P dba
# Update dba password
isql-v -U dba -P dba < /sql-query.sql
# Stop virtuoso
kill $(ps ax | egrep '[v]irtuoso-t' | awk '{print $1}')
# Load data
if [ -d "toLoad" ] ;
then
echo "Start data loading from toLoad folder..."
pwd="dba"
graph="http://localhost:8890/DAV"
if [ "$DBA_PASSWORD" ]; then pwd="$DBA_PASSWORD" ; fi
if [ "$DEFAULT_GRAPH" ]; then graph="$DEFAULT_GRAPH" ; fi
echo "ld_dir('toLoad', '*', '$graph');" >> /load_data.sql
echo "rdf_loader_run();" >> /load_data.sql
echo "exec('checkpoint');" >> /load_data.sql
echo "WAIT_FOR_CHILDREN; " >> /load_data.sql
echo "$(cat /load_data.sql)"
virtuoso-t +wait && isql-v -U dba -P "$pwd" < /load_data.sql
kill $(ps ax | egrep '[v]irtuoso-t' | awk '{print $1}')
echo `date +%Y-%m-%dT%H:%M:%S%:z` > .data_loaded
fi
# Start virtuoso
exec virtuoso-t +wait +foreground