forked from dice-group/gerbil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·192 lines (164 loc) · 5.9 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
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
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
# This script is part of the GERBIL project.
# It reuses functions from Mitch Frazier (http://www.linuxjournal.com/content/asking-yesno-question-bash-script)
#####################################################################
# Print warning message.
function warning()
{
echo "$*" >&2
}
#####################################################################
# Print error message and exit.
function error()
{
echo "$*" >&2
exit 1
}
#####################################################################
# Ask yesno question.
#
# Usage: yesno OPTIONS QUESTION
#
# Options:
# --timeout N Timeout if no input seen in N seconds.
# --default ANS Use ANS as the default answer on timeout or
# if an empty answer is provided.
#
# Exit status is the answer.
function yesno()
{
local ans
local ok=0
local timeout=0
local default
local t
while [[ "$1" ]]
do
case "$1" in
--default)
shift
default=$1
if [[ ! "$default" ]]; then error "Missing default value"; fi
t=$(tr '[:upper:]' '[:lower:]' <<<$default)
if [[ "$t" != 'y' && "$t" != 'yes' && "$t" != 'n' && "$t" != 'no' ]]; then
error "Illegal default answer: $default"
fi
default=$t
shift
;;
--timeout)
shift
timeout=$1
if [[ ! "$timeout" ]]; then error "Missing timeout value"; fi
if [[ ! "$timeout" =~ ^[0-9][0-9]*$ ]]; then error "Illegal timeout value: $timeout"; fi
shift
;;
-*)
error "Unrecognized option: $1"
;;
*)
break
;;
esac
done
if [[ $timeout -ne 0 && ! "$default" ]]; then
error "Non-zero timeout requires a default answer"
fi
if [[ ! "$*" ]]; then error "Missing question"; fi
while [[ $ok -eq 0 ]]
do
if [[ $timeout -ne 0 ]]; then
if ! read -t $timeout -p "$*" ans; then
ans=$default
else
# Turn off timeout if answer entered.
timeout=0
if [[ ! "$ans" ]]; then ans=$default; fi
fi
else
read -p "$*" ans
if [[ ! "$ans" ]]; then
ans=$default
else
ans=$(tr '[:upper:]' '[:lower:]' <<<$ans)
fi
fi
if [[ "$ans" == 'y' || "$ans" == 'yes' || "$ans" == 'n' || "$ans" == 'no' ]]; then
ok=1
fi
if [[ $ok -eq 0 ]]; then warning "Valid answers are: yes y no n"; fi
done
[[ "$ans" = "y" || "$ans" == "yes" ]]
}
#####################################################################
# Check for dependencies
echo "Checking dependencies..."
file="gerbil_data/gerbil_data.zip"
url="https://files.dice-research.org/projects/GERBIL/gerbil_data-1.2.10.zip"
if [ ! -d "gerbil_data" ]; then
mkdir -p "gerbil_data" || error "Could not create gerbil_data directory"
mkdir -p "gerbil_data/cache" || error "Could not create gerbil_data/cache directory"
if [ ! -f "$file" ]; then
echo "Downloading dependencies ... ($url)"
curl --retry 4 -L -o "$file" "$url"
if [ ! -f "$file" ]; then
error "Couldn't downloading dependency data: $file"
else
echo "Extracting dependencies ... "
unzip "$file"
fi
fi
fi
#####################################################################
# Check for property file
echo "Checking properties files..."
dir="src/main/properties"
file="$dir/gerbil_keys.properties"
if [ ! -f "$file" ]; then
echo "Creating empty $file file"
mkdir -p "$dir" || error "Could not create $dir directory"
echo "##############################################################################" > $file
echo "# This is the properties file for keys of several annotator web services. #" >> $file
echo "# IT SHOULD NOT BE DISTRIBUTED!!! #" >> $file
echo "##############################################################################" >> $file
fi
#####################################################################
# Check for dbpedia sameAs index
echo "Checking dbpedia sameAs index..."
if [ ! -d "gerbil_data/indexes/dbpedia" ]; then
echo "Couldn't find a dbpedia sameAs index"
if yesno "Should the index be downloaded (~1GB zipped, ~2GB extracted)? (yes/no): "; then
mkdir -p "gerbil_data/indexes/dbpedia" || error "Could not create gerbil_data/indexes/dbpedia directory"
file="gerbil_data/indexes/dbpedia/dbpedia_index.zip"
url="https://hobbitdata.informatik.uni-leipzig.de/gerbil/dbpedia_index_2016.zip"
echo "Downloading index ... ($url)"
curl --retry 4 -L -o "$file" "$url"
if [ ! -f "$file" ]; then
echo "Couldn't downloading index file: $file"
else
echo "Extracting index ... "
unzip "$file" -d "gerbil_data/indexes/dbpedia"
fi
fi
fi
#####################################################################
# Check for dbpedia entity check index
echo "Checking dbpedia entity check index..."
if [ ! -d "gerbil_data/indexes/dbpedia_check" ]; then
echo "Couldn't find a dbpedia entity check index"
if yesno "Should the index be downloaded (~0.3GB zipped, ~0.7GB extracted)? (yes/no): "; then
mkdir -p "gerbil_data/indexes/dbpedia_check" || error "Could not create gerbil_data/indexes/dbpedia_check directory"
file="gerbil_data/indexes/dbpedia_check/dbpedia_check_index.zip"
url="https://hobbitdata.informatik.uni-leipzig.de/gerbil/dbpedia_check_index_2017.zip"
echo "Downloading index ... ($url)"
curl --retry 4 -L -o "$file" "$url"
if [ ! -f "$file" ]; then
echo "Couldn't downloading index file: $file"
else
echo "Extracting index ... "
unzip "$file" -d "gerbil_data/indexes/dbpedia_check"
fi
fi
fi
echo "Building and starting GERBIL..."
mvn clean package cargo:run -DskipTests -Dmaven.javadoc.skip=true