forked from bolidozor/js9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs9load
executable file
·78 lines (67 loc) · 1.18 KB
/
js9load
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
#!/bin/sh
# set -x
error() {
echo "ERROR: $1" 1>&2
exit 1
}
# local variables
DONE=false
VERBOSE=false
TRIES=10
SLEEP=1
while [ x"$1" != x ]; do
case $1 in
-id) shift
XARGS="$XARGS -id $1"
shift;;
-s) shift
SLEEP=$1
shift;;
-t) shift
TRIES=$1
shift;;
-v) VERBOSE=true
shift;;
*) break;;
esac
done
# check for required args
if [ $# -lt 1 ]; then
echo "usage: $0 filename"
exit 1
else
PATHNAME="$1"
fi
ROOT=`basename $PATHNAME .fits`
# start the image load
GOT=`js9 $XARGS load $PATHNAME`
if [ x"$GOT" != xOK ]; then
error "$GOT"
fi
# wait for completion
while [ $DONE = false ]; do
# get status of current image
GOT=`js9 $XARGS status $ROOT load`
case $GOT in
error)
error "could not load: $PATHNAME";;
loading|please)
if [ x$VERBOSE = xtrue ] ; then
echo "loading ..."
fi
sleep $SLEEP
continue;;
complete)
if [ x$VERBOSE = xtrue ] ; then
echo "success!"
fi
DONE=true
continue;;
esac
TRIES=`echo "$TRIES - 1" | bc`
if [ $TRIES -le 0 ]; then
error "timeout while loading: $PATHNAME"
fi
done
# signal success
exit 0