blob: 686c5ebb49a394c4983e39c449b00ae871ad9b22 (
plain)
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
|
#!/bin/bash
export PATH="/bin:/sbin:/usr/bin:/usr/sbin"
if [ "`id -u`" != "0" ]; then
echo "Must be run as root"
exit 1
fi
if [ "$1" == "list" ]; then
if [ -d /root/submissions ]; then
touch /root/submissions/placeholder.bocarun
touch /root/submissions/placeholder.bocarun.processed
if [ "$2" == "old" ]; then
for i in `ls /root/submissions/*.bocarun.processed`; do
if [ "$i" != "/root/submissions/placeholder.bocarun.processed" ]; then
prob=`grep ^problem $i`
lang=`grep ^language $i`
nam=`grep ^name $i`
res=""
resf="/root/submissions/`basename ${i} .processed`.result"
[ -r "$resf" ] && res=`cat "$resf"`
echo "RUN DONE: $prob $lang $nam $res"
fi
done
else
for i in `ls /root/submissions/*.bocarun`; do
if [ "$i" != "/root/submissions/placeholder.bocarun" ]; then
prob=`grep ^problem $i`
lang=`grep ^language $i`
nam=`grep ^name $i`
res=""
[ -r "${i}.result" ] && res=`cat ${i}.result`
echo "RUN AWAITING: $prob $lang $nam $res"
fi
done
fi
fi
else
if [ "$7" != "" ]; then
mkdir -p /root/submissions
chown root /root/submissions
chmod 700 /root/submissions
nom=/root/submissions/`date +%s%N`.bocarun.tmp
tmpvar=`echo "$1" | tr -cd '[[:alnum:]]._+-/'`
echo "BOCASERVER=$tmpvar" > "$nom"
tmpvar=`echo "$2" | tr -cd '[[:alnum:]]._+-/'`
if [ -f "/root/submissions/user.ok" && "`cat /root/submissions/user.ok`" != "$tmpvar" ]; then
echo "WARNING: different username had been successfully used before - I will try to continue but you better check, this may fail later"
fi
echo "user=$tmpvar" >> "$nom"
tmpuser=$tmpvar
tmpvar=`echo "$3" | tr -cd '[[:alnum:]]._+-/'`
if [ -f "/root/submissions/pass.ok" && "`cat /root/submissions/pass.ok`" != "$tmpvar" ]; then
echo "WARNING: different password had been successfully used before - I will try to continue but you better check, this may fail later"
fi
echo "pass=$tmpvar" >> "$nom"
tmppass=$tmpvar
tmpvar=`echo "$4" | tr -cd '[[:alnum:]]._+-/'`
echo "problem=$tmpvar" >> "$nom"
tmpvar=`echo "$5" | tr -cd '[[:alnum:]]._+-/'`
echo "language=$tmpvar" >> "$nom"
tmpvar=`echo "$6" | tr -cd '[[:alnum:]]._+-/'`
echo "name=$tmpvar" >> "$nom"
echo -en "data=\"" >> "$nom"
uuencode -m zzzzzzzzzz < `echo -n "$7" | tr -cd '[[:alnum:]]._+-/'` | grep -v "begin-base64.*zzzzzzzzzz" >> "$nom"
echo "\"" >> "$nom"
dateerr=`date +%s`
echo "dateerr=$dateerr" >> "$nom"
# uniq=`date +%sN`-`sha256sum "$7"`
# uniq=`echo $uniq | sha256sum - | cut -f1 -d' '`
uniq=`sha256sum "$7" | cut -f1 -d' '`
code=`cat /root/submissions/code 2>/dev/null`
if [ "$code" == "" ]; then
echo "ERROR: this computer is not configured to submit runs -- code missing"
exit 1
fi
comp=`cat /root/submissions/comp 2>/dev/null`
if [ "$comp" == "" ]; then
echo "ERROR: this computer is not configured to submit runs -- comp missing"
exit 1
fi
res=`echo -n "${code}${uniq}${comp}${dateerr}" | sha256sum - | cut -f1 -d' '`
echo "uniq=$uniq" >> "$nom"
echo "code=$res" >> "$nom"
echo "comp=$comp" >> "$nom"
/usr/bin/boca-submit-run-aux $nom
if [ "$?" == "2" ]; then
mv "$nom" "/root/submissions/`basename $nom .tmp`"
echo "Run submission included in the queue -- it shall appear in the system later when connection is available"
else
[ -f "$nom" ] && mv "$nom" "/root/submissions/`basename $nom .tmp`.processed"
echo -n "$tmpuser" > /root/submissions/user.ok
echo -n "$tmpvar" > /root/submissions/pass.ok
fi
fi
fi
|