-
Notifications
You must be signed in to change notification settings - Fork 12
/
utils.sh
71 lines (65 loc) · 1.41 KB
/
utils.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
function wait_for_start {
(
HOST=${1}
PORT=${2}
DELAY=${3}
# Wait for stardog to be running
RC=1
COUNT=0
set +e
while [[ ${RC} -ne 0 ]];
do
if [[ ${COUNT} -gt ${DELAY} ]]; then
return 1;
fi
COUNT=$(expr 1 + ${COUNT} )
sleep 1
curl -v http://${HOST}:${PORT}/admin/healthcheck
RC=$?
done
return 0
)
}
function change_pw {
(
set +ex
HOST=${1}
PORT=${2}
echo "/opt/stardog/bin/stardog-admin --server http://${HOST}:${PORT} user passwd -N xxxxxxxxxxxxxx"
NEW_PW=$(cat /etc/stardog-password/adminpw)
/opt/stardog/bin/stardog-admin --server http://${HOST}:${PORT} user passwd -N ${NEW_PW}
if [[ $? -eq 0 ]];
then
echo "Password successfully changed"
return 0
else
curl --fail -u admin:${NEW_PW} http://${HOST}:${PORT}/admin/status
RC=$?
if [[ $RC -eq 0 ]];
then
echo "Default password was already changed"
return 0
elif [[ $RC -eq 22 ]]
then
echo "HTTP 4xx error"
return $RC
else
echo "Something else went wrong"
return $RC
fi
fi
)
}
function make_temp {
(
set +e
TEMP_PATH=${1}
if [ ! -d "$TEMP_PATH" ]; then
mkdir -p $TEMP_PATH
if [ $? -ne 0 ]; then
echo "Could not create stardog tmp directory ${TEMP_PATH}" >&2
return 1
fi
fi
)
}