forked from vivo-project/VIVO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
79 lines (69 loc) · 2.67 KB
/
start.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
#!/bin/bash
# set -e
# allow easier debugging with `docker run -e VERBOSE=yes`
if [[ "$VERBOSE" = "yes" ]]; then
set -x
fi
# allow easier reset home with `docker run -e RESET_HOME=true`
if [[ "$RESET_HOME" = "true" ]]; then
echo 'Clearing VIVO HOME /usr/local/vivo/home'
rm -rf /usr/local/vivo/home/*
fi
# copy home bin if not exists
if [ ! -d /usr/local/vivo/home/bin ]; then
echo "Copying home bin directory to /usr/local/vivo/home/bin"
cp -r /vivo-home/bin /usr/local/vivo/home/bin
fi
# copy home config if not exists
if [ ! -d /usr/local/vivo/home/config ]; then
echo "Copying home config directory to /usr/local/vivo/home/config"
cp -r /vivo-home/config /usr/local/vivo/home/config
fi
# copy home rdf if not exists
if [ ! -d /usr/local/vivo/home/rdf ]; then
echo "Copying home rdf directory to /usr/local/vivo/home/rdf"
cp -r /vivo-home/rdf /usr/local/vivo/home/rdf
fi
# copy runtime.properties if it does not already exist in target home directory
if [ -f /usr/local/vivo/home/config/example.runtime.properties ]; then
if [ ! -f /usr/local/vivo/home/config/runtime.properties ]
then
echo "Copying example.runtime.properties to /usr/local/vivo/home/config/runtime.properties"
cp /usr/local/vivo/home/config/example.runtime.properties /usr/local/vivo/home/config/runtime.properties
# template runtime.properties vitro.local.solr.url value to $SOLR_URL value
echo "Templating runtime.properties vitro.local.solr.url = $SOLR_URL"
sed -i "s,http://localhost:8983/solr/vivocore,$SOLR_URL,g" /usr/local/vivo/home/config/runtime.properties
else
echo "Using existing /usr/local/vivo/home/config/runtime.properties"
fi
fi
# copy applicationSetup.n3 if it does not already exist in target home directory
if [ -f /usr/local/vivo/home/config/example.applicationSetup.n3 ]; then
if [ ! -f /usr/local/vivo/home/config/applicationSetup.n3 ]
then
echo "Copying example.applicationSetup.n3 to /usr/local/vivo/home/config/applicationSetup.n3"
cp /usr/local/vivo/home/config/example.applicationSetup.n3 /usr/local/vivo/home/config/applicationSetup.n3
else
echo "Using existing /usr/local/vivo/home/config/applicationSetup.n3"
fi
fi
echo "Waiting for solr"
# Run a few SOLR startup wait tests before starting tomcat
SOLR_STATUS_URL=$(grep '/solr/' /usr/local/vivo/home/config/runtime.properties |\
grep -v '#' | cut -f 2 -d '=' | tr -d ' ' | \
sed 's,vivocore,admin/cores?action=STATUS,g')
x=1
while [ $x -le 10 ] ; do
RESULT=$(curl -s -o /dev/null -I -w '%{http_code}' $SOLR_STATUS_URL)
if [ "$RESULT" -eq '200' ]; then
echo 'solr run'
break
else
echo 'waiting for solr'
sleep 2
x=$(( $x + 1 ))
fi
done
echo "Starting VIVO"
sleep 5
catalina.sh run