blob: 8665af26232b7dffbf85108fcf1ddf56c65d7cfc (
plain) (
blame)
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
|
#!/bin/bash
showmsg() {
if [ -n "$DISPLAY" ]; then
zenity --error --text "$*" &> /dev/null && return 0
xmessage "$*" &> /dev/null && return 0
fi
echo "$*"
}
mountpoint=
servers=
start=
file=
nfs=
while (( $# > 0 )); do
case "$1" in
--start)
start="$2"
shift
;;
--nfs)
nfs=1
;;
--file)
file="$2"
shift
;;
--servers)
servers="$2"
shift
;;
*)
break
;;
esac
shift
done
if [ -z "$file" ]; then
if mountpoint; then
file=$( find /mnt/vmstore -type f -printf "%s\t%p\n" | sort -n | tail -n 1 | awk '{print $2}' )
else
showmsg "Not using NFS, cannot test automatically"
exit 1
fi
else
if [ -n "$nfs" ]; then
file=$( find /mnt/vmstore/"$file"* -type f -printf "%s\t%p\n" | sort -n | tail -n 1 | awk '{print $2}' )
else
if [ -z "$servers" ]; then
. /opt/openslx/config
servers="$SLX_DNBD3_SERVERS"
fi
mountpoint="/tmp/speedtest-$$-$RANDOM"
mkdir "$mountpoint"
rid="${file##*:}"
if [ "$rid" = "$file" ] || ! [ "$rid" -gt 0 ]; then
rid=0
fi
file="${file%:*}"
if ! dnbd3-fuse -S -h "$servers" -i "$file" -r "$rid" "$mountpoint"; then
showmsg "Cannot start dnb3-fuse from $servers"
exit 1
fi
if ! mountpoint "$mountpoint"; then
showmsg "is not mountpoint"
exit 1
fi
file="${mountpoint}/img"
fi
fi
if [ -z "$file" ]; then
showmsg "Cannot test, no image found"
exit 1
fi
if [ -n "$start" ]; then
now="$( date +%s )"
diff="$(( start - now ))"
(( diff > 120 )) && diff=0
if (( diff > 0 )); then
echo "Waiting $diff seconds for synchronized start"
sleep "$diff"
fi
fi
speedcheck --auto "$file"
[ -n "$mountpoint" ] && fusermount -u "$mountpoint"
exit 0
|