-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathVerifyInstall.sh
More file actions
275 lines (224 loc) · 8.29 KB
/
Copy pathVerifyInstall.sh
File metadata and controls
275 lines (224 loc) · 8.29 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#!/usr/bin/env bash
set -euo pipefail
#
# Helper functions
#
check_dirs_nonempty() {
local dirs=("$@")
for d in "${dirs[@]}"; do
if [ ! -d "$d" ]; then
echo "[MISSING DIRECTORY:] $d"
exit 1
fi
echo "Found: $d"
if [ ! "$(ls -A "$d")" ]; then
echo " $d is EMPTY."
exit 1
fi
done
echo "All directories found and non-empty."
}
check_files() {
local files=("$@")
for f in "${files[@]}"; do
if [ -f "$f" ]; then
echo "Found file: $f"
else
echo "[MISSING FILE:] File not found: $f"
return 1
fi
done
echo "Most relevant files found."
return 0
}
print_header() {
local COLOR='\033[1;34m' # Light blue color
local NC='\033[0m' # No Color
echo
echo -e "=================================================================="
echo -e ">>> ${COLOR}$1${NC}"
echo "=================================================================="
}
########################################################
# Check if the output contains "MISSING PREREQUISITES"
########################################################
if [ -z "${SIGMA_SRC-}" ]; then
echo "The \$SIGMA_SRC environment variable is not set or is empty. Did you restart your command line interface after installation?"
echo "Technical note: the \$SIMGA_SRC environment variable is set in the ~/.bashrc file, and should be set to wherever the workspace/sigmakee folder is."
exit 1
fi
print_header "Checking that prerequisites were installed correctly"
output=$(source $SIGMA_SRC/VerifyInstallationPrerequisites.sh | tee /dev/tty)
if echo "$output" | grep -q "MISSING PREREQUISITES"; then
echo "Error: Missing prerequisites detected. Exiting script."
exit 1
fi
echo "All prerequisites met. Proceeding with checks."
######################################################################
######################################################################
## Note: This next section roughly follows the build.xml script. ##
## If it fails, look for the <target name="install" section. ##
######################################################################
######################################################################
########################################################
# Check if folders exist and are not empty
########################################################
print_header "Checking relevant directories/files exist"
dir_list=(
"$ONTOLOGYPORTAL_GIT"
"$ONTOLOGYPORTAL_GIT/SigmaUtils"
"$ONTOLOGYPORTAL_GIT/TPTP-ANTLR"
"$ONTOLOGYPORTAL_GIT/sumo"
"$ONTOLOGYPORTAL_GIT/sigmaAntlr"
"$HOME/Programs"
"$CATALINA_HOME/bin"
"$CATALINA_HOME/webapps"
"$HOME/Programs/WordNet-3.0"
"$HOME/Programs/E"
"$HOME/Programs/vampire"
"$HOME/Programs/vampire/z3"
"$HOME/Programs/vampire/z3/build"
"$SIGMA_HOME/KBs"
"$SIGMA_HOME/KBs/WordNetMappings"
)
check_dirs_nonempty "${dir_list[@]}"
########################################################
# Check if certain files exist, that various copying
# commands executed successfully.
########################################################
files=(
"$SIGMA_HOME/KBs/Merge.kif"
"$SIGMA_HOME/KBs/Mid-level-ontology.kif"
"$SIGMA_HOME/KBs/config.xml"
"$HOME/Programs/E/configure"
"$HOME/Programs/E/PROVER/e_ltb_runner"
"$HOME/Programs/vampire/build/vampire"
"$HOME/Programs/vampire/z3/build/z3"
)
check_files "${files[@]}"
######################################################################
# Check if config.xml has been appropriately configured.
######################################################################
print_header "Checking .sigmakee/KBs/config.xml has proper configurations"
target_string="/home/theuser"
config_file="$SIGMA_HOME/KBs/config.xml"
if grep -qF "$target_string" "$config_file"; then
echo "String \"$target_string\" found in $config_file. Exiting."
exit 0
fi
strings=(
"$HOME/Programs/E/PROVER/e_ltb_runner"
"$HOME/Programs/vampire/build/vampire"
)
for s in "${strings[@]}"; do
if ! grep -qF -- "$s" "$config_file"; then
echo "Missing string from $config_file: $s"
exit 1
fi
done
echo "$config_file properly configured."
########################################################
# Vampire checks
########################################################
print_header "Verifying vampire build"
# Check if vampire exists and is in PATH
if ! command -v vampire > /dev/null 2>&1; then
echo "vampire is NOT installed or not in PATH."
exit 1
fi
# Run vampire --version and check exit status
vampire --version > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo "vampire is installed, on PATH, and runs correctly."
else
echo "vampire is in PATH, but failed to run correctly."
exit 1
fi
echo
echo "***VERIFIED SUCCESSFUL Sigma download and configuration (ant install)***"
echo
######################################################################
######################################################################
## Check ant build. (ant) ##
######################################################################
######################################################################
print_header "Verifying Sigma build (i.e., ant)"
########################################################
# Check if folders exist and are not empty
########################################################
print_header "Checking directories and files created during build process"
dir_list=(
"$ONTOLOGYPORTAL_GIT/sigmakee/.ivy"
)
check_dirs_nonempty "${dir_list[@]}"
########################################################
# Check if certain files exist, that various copying
# commands executed successfully.
########################################################
files=(
"$ONTOLOGYPORTAL_GIT/sigmaAntlr/sigmaAntlr.jar"
"$ONTOLOGYPORTAL_GIT/sigmakee/build/sigmakee.jar"
"$CATALINA_HOME/webapps/sigma.war"
"$CATALINA_HOME/bin/startup.sh"
"$CATALINA_HOME/bin/shutdown.sh"
)
check_files "${files[@]}"
############################################################
# Run a basic test of the knowledge base.
# java -Xmx20g -cp "$SIGMA_CP" com.articulate.sigma.KB -t
############################################################
print_header "Knowledge Base stress test"
echo "Building and testing knowledge base ... This may take several minutes."
if java -Xmx20g -cp "$SIGMA_CP" com.articulate.sigma.KB -t 2>/dev/null | grep -qF "KB.test()"; then
echo "Successfully built and ran stress tests on Knowledge Base."
else
echo "Did not successfully run knowledge tests: java -Xmx20g -cp \"$SIGMA_CP\" com.articulate.sigma.KB -t"
exit 1
fi
########################################################
# Check if tomcat actually works and starts.
########################################################
print_header "Sigmakee web server verification"
timeout=60 # seconds
interval=3 # seconds between attempts
elapsed=0
echo "Sigmakee is launched by a Tomcat server. Checking if Tomcat is functional."
if startup.sh | grep -qF "Tomcat started."; then
echo "Tomcat successfully running."
else
echo "There is a problem running 'startup.sh' found in $CATALINA_HOME/bin, used to start the Tomcat server."
exit 1
fi
while true; do
# Sometimes it takes some time to unpack the .war file, keep trying for a minute.
output=$(curl -s --fail "http://localhost:8080/sigma/login.html") || {
echo "Waiting for server to load Sigmakee ..."
sleep $interval
elapsed=$((elapsed + interval))
continue
}
if echo "$output" | grep -qF "<title>Sigma Login</title>"; then
echo "Sigmakee is successfully running."
break
fi
sleep $interval
elapsed=$((elapsed + interval))
if (( elapsed >= timeout )); then
echo "Timeout waiting for Sigma login page after Tomcat startup."
echo "Last curl output was:"
echo "$output"
if [ ! -d "$CATALINA_HOME/webapps/sigma" ]; then
echo "[MISSING DIRECTORY:] $CATALINA_HOME/webapps/sigma"
echo "Try running 'bash $ONTOLOGYPORTAL_GIT/sigmakee/VerifyInstallation.sh' in a couple minutes, sometimes it takes a while for the Tomcat server to build the sigmakee website from the sigma.war file."
fi
exit 1
fi
done
# Shutdown Tomcat server
shutdown.sh > /dev/null 2>&1
###################################################################
#
# Success, probably!!!!
#
###################################################################
echo -e "\n\nFinished build verification. Checks indicate a successful installation!"