#!/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 tmpvar=`echo "$1" | tr -cd '[[:alnum:]]._+-/'` echo "BOCASERVER=$tmpvar" > "$nom" tmpvar=`echo "$2" | tr -cd '[[:alnum:]]._+-/'` echo "user=$tmpvar" >> "$nom" tmpvar=`echo "$3" | tr -cd '[[:alnum:]]._+-/'` echo "pass=$tmpvar" >> "$nom" 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" exit 1 fi 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