-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrtggo
executable file
·168 lines (161 loc) · 3.01 KB
/
rtggo
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
#!/bin/bash
wd=/data/webrtg
wwwreq="rtgreq.txt"
locreq="rtgreq_done.txt"
wwwsite="http://portal.eiscat.se/db"
export PATH=$PATH:/usr/local/bin
export EISCATSITE=web
fsiz() {
filesize=`ls -l $1 | awk '{print $5}'`
}
mail_it() {
# s-nail -S 'smtp=smtp://www.eiscat.se' -s "$RTG $rundir output files" -r "RTG <[email protected]>" $* <<!
#mutt -e "set crypt_use_gpgme=no" -s "RTG $rundir output files" -e "my_hdr From: RTG <[email protected]>" $* <<!
mutt -F /home/eiscat/muttrc.webgup -e "set crypt_use_gpgme=no" -s "RTG $rundir output files" -e "my_hdr From: RTG <[email protected]>" $* <<!
Enclosed you find result files for your RTG@$rundir process.
EISCAT
!
}
unpack() {
funn=$2
echo $1 | base64 -d > $funn
if [ "`file -b $2`" != "ASCII text" ]
then
7z x $2 >/dev/null
rm $2
t=`ls`
if [ `ls -1 | wc -l` = 1 ] && [ "${t##*.}" = "tar" ]
then
tar xf $t
rm $t
fi
funn="${2%%.*}"
fi
}
cd $wd
rtgdef=""
selfig=""
if [ "$1" ]
then
echo "Doing from command line"
eval $1
echo $dirs
echo $ndumps
echo $maxfsize
echo $REMOTE_ADDR
echo $rtgdef
echo $rtgdefn
echo $selfig
echo $selsub
echo $selfun
echo $selfunn
verb=" -v"
else
if ! wget $wwwsite/$wwwreq -O $wwwreq 2>/dev/null
then
echo "Could not reach HQ"
exit 0
elif cmp -s $wwwreq $locreq
then
echo "All already done"
exit 0
else
QUERY_STRING=`comm -23 $wwwreq $locreq | head -n1`
fi
fsiz $wwwreq
nsiz=$filesize
fsiz $locreq
if [ -z "$QUERY_STRING" ] || [ $nsiz -lt $filesize ]
then
echo "New list"
cp $wwwreq $locreq
exit 0
fi
echo $QUERY_STRING >> $locreq
eval $QUERY_STRING
verb=""
fi
atpos=`expr index "$resultpath" "@"`
if [ -z $resultpath ] || [ $atpos -eq 0 ]
then
echo "Nowhere to send results"
exit 1
fi
rundir=`date +%y%m%dw%H%M`
if [ -d $rundir ]
then
rm -rf $rundir
fi
mkdir $rundir
cd $rundir
if [ -n "$selfig" ] && [ -n "$selsub" ] && [ -n "$selfun" ] && [ -n "$selfunn" ]
then
unpack $selfun $selfunn
selax="-x $selfig,$selsub,$funn"
else
selax=""
fi
if [ -n "$rtgdef" ] && [ -n $rtgdefn ]
then
unpack $rtgdef $rtgdefn
def="-D $funn"
elif [ -n "$rtgdef" ]
then
echo $rtgdef | tr '#' '\n' > rtgd.m
def="-D rtgd.m"
else
def=""
fi
for tar in $dirs
do
curl -o - "$tar" 2>/dev/null | tar xf -
#wget -O - "$tar" 2>/dev/null | tar xf -
done
datapath=`ls -d */* |head -1`
if [ -z $datapath ]
then
echo "No data defined"
exit 1
fi
maxsize=3000000
if [ $maxfsize ]
then
maxsize=$(($maxfsize*730000)) #uuencoding maxes file ~27% bigger
fi
inp=`ls`
/opt/remtg/webtg $verb -t -n $ndumps -d $datapath $def $selax
rm -r $inp
rmdir data #Matlab 2017b bug?
resdir=`ls`
if [ -d $resdir ]
then
cd $resdir
fi
flist=""
for fil in `ls`
do
fsiz $fil
if [ $filesize -gt $maxsize ]
then
split -db $maxsize $fil $fil.
flist="$flist `ls $fil.??`"
else
flist="$flist $fil"
fi
done
nsiz=0
matt=""
for fil in $flist
do
fsiz $fil
if [ $((nsiz+filesize)) -gt $maxsize ] && [ $nsiz -ne 0 ]
then
mail_it $matt -- $resultpath
sleep 30
matt=""
nsiz=0
fi
matt="$matt -a $fil"
nsiz=$((nsiz+filesize))
done
mail_it $matt -- $resultpath