File: measuresdata-update

package info (click to toggle)
casacore 3.8.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 51,912 kB
  • sloc: cpp: 471,569; fortran: 16,372; ansic: 7,416; yacc: 4,714; lex: 2,346; sh: 1,865; python: 629; perl: 531; sed: 499; csh: 201; makefile: 32
file content (73 lines) | stat: -rwxr-xr-x 1,928 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
#
# measuresdata-update
# Must be executable. Call it with all defaults or arguments for measuresdata
#

echo Calling measuresdata "$@"
measuresdata "$@"
if [ $? -ne 0 ] ; then
    echo Severe error calling measuresdata with "$@"
    exit 1
fi
if [ ! -f measuresdata.rc ] ; then
    echo Severe error: no measuresdata.rc file returned
    exit 1
fi
while grep -qe "^status:\\Wcont" measuresdata.rc ; do
    data=$(grep "^data:" measuresdata.rc | cut -d\  -f2-)
    ftp=$(grep "^ftp:" measuresdata.rc | cut -d\  -f2-)
    http=$(grep "^http:" measuresdata.rc | cut -d\  -f2-)
    https=$(grep "^https:" measuresdata.rc | cut -d\  -f2-)
    dir=$(grep "^dir:" measuresdata.rc | cut -d\  -f2-)
    file=$(grep "^file:" measuresdata.rc | cut -d\  -f2-)
    arg=$(grep "^arg:" measuresdata.rc | cut -d\  -f2-)

    if [ "$data" != "ascii" ] ; then
        echo Severe: only ascii data protocol supported
        exit 1
    elif [ -z "$dir" -o -z "$file" -o -z "$arg" ] ; then
	echo Severe: missing dir, file or arg data
	exit 1
    fi

    if [ -n "$http" ] ; then
	url="http://$http/$dir/$file"
    elif [ -n "$https" ] ; then
	url="https://$https/$dir/$file"
    elif [ -n "$ftp" ] ; then
	url="ftp://$ftp/$dir/$file"
    else
	echo Severe: missing ftp/http/https
        exit 1
    fi
    
    if [ "$url" = "$old_url" ] ; then
	echo Warning: measuresdata requests the same url twice: $url
#	exit 1
    fi
    old_url=$url

    echo Getting $url
    curl -L -O $url
    
    echo Calling measuresdata $arg
    measuresdata $arg
    if [ $? -ne 0 ] ; then
	echo Severe error calling measuresdata with $arg
	exit 1
    fi

    if [ ! -f measuresdata.rc ] ; then
	echo Severe error: no measuresdata.rc file returned
	exit 1
    fi
done

if grep -qe "^status:\\Wend" measuresdata.rc ; then
    echo measuresdata-update finished normally
    exit 0
else
    echo Severe: unknown status given in measuresdata.rc
    exit 1
fi