#!/bin/bash export PATH="/bin:/sbin:/usr/bin:/usr/sbin" if [[ ! -e /etc/bocaip ]] ; then echo "O IP do servidor boca nao configurado. Abort." exit 1 fi #Check if this script is running in a user in sudo group or root if groups | egrep -q "(sudo|root)" ; then echo "Este script deve ser executado por um usuario normal" echo "Na Maratona este usuario, geralmente, eh o 'icpc'" exit 1 fi runroot=`which boca-submit-run-root-wrapper` if [ "$runroot" == "" ]; then runroot=/usr/bin/boca-submit-run-root-wrapper fi if [ "`basename $0`" == "boca-submit-oldlist" ]; then $runroot list old list list list list list else if [ "`basename $0`" == "boca-submit-list" ]; then $runroot list list list list list list list else source /etc/bocaip BOCASERVER=$BOCAIP if [ "$BOCASERVER" != "" ]; then if [ "$BOCASERVERS" == "" ]; then BOCASERVERS=$BOCASERVER else BOCASERVERS="$BOCASERVERS;$BOCASERVER" fi fi if [ "$BOCASERVERS" == "" ]; then echo "This computer has no configured BOCA server. Ask an admin to update /etc/icpc/bocaserver.sh (usually resetting everything is an easy way)" exit 1 fi for i in uuencode wget tr perl sha256sum cut; do p=`which $i` if [ -x "$p" ]; then echo -n "" else echo "$i" not found exit 1 fi done if [ "$1" == "" ]; then echo "Usage: $0 USER PASSWORD PROBLEM LANGUAGE FILE" echo "" echo "where USER is your username" echo "PASSWORD is your password" echo "FILE is your submission file" echo "PROBLEM and LANGUAGE are according to defined in BOCA" echo "==>>You can check at your BOCA interface to be sure<<==" echo "PROBLEM is usually a single letter e.g. A or B or C etc" echo "LANGUAGE is usually one of { c cpp cc java }" echo "==>>You can check at your BOCA interface to be sure<<==" exit 1 fi if [ -r "$5" ]; then if [ "$4" != "C" -a "$4" != "C++11" -a "$4" != "Java" -a "$4" != "Python2" -a "$4" != "Python3" ]; then echo "Warning: language name is not standard, be sure it is correct (this is not necessarily an error)" fi nom=`echo -n "$5" | perl -MURI::Escape -lne 'print uri_escape($_)'` for BOCASERVER in `echo $BOCASERVERS | tr ';' ' '`; do $runroot "$BOCASERVER" "$1" "$2" "$3" "$4" "`basename $5`" "$5" done else echo "file $5 not found/readable" fi fi fi