blob: 0fac46016827554c52a8e1843e605f6898199e66 (
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
|
#!/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
if [ "$2" == "old" ]; then
for i in `ls /root/submissions/*.bocarun.processed`; do
if [ "$i" != "/root/submissions/placeholder.bocarun" ]; 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
echo "BOCASERVER=`echo $1 | tr -cd '[[:alnum:]]._+-/'`" > "$nom"
echo "user=`echo $2 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom"
echo "pass=`echo $3 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom"
echo "problem=`echo $4 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom"
echo "language=`echo $5 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom"
echo "name=`echo $6 | tr -cd '[[:alnum:]]._+-/'`" >> "$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`
comp="error"
if [ -r /root/submissions/comp ]; then
comp=`cat /root/submissions/comp`
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" ] && rm -f $nom
fi
fi
fi
|