diff options
| author | cassio <cassiopc@gmail.com> | 2015-08-30 22:11:57 +0000 |
|---|---|---|
| committer | cassio <cassiopc@gmail.com> | 2015-08-30 22:11:57 +0000 |
| commit | dd3152be0442e577692067c5523da4f5ab9d9957 (patch) | |
| tree | dd11e8e3bd71404dd7675b8bc8d49f3655a0df61 /tools/etc | |
| parent | 9a3077369831bc66fd51bc9c5c276980dd74e046 (diff) | |
| download | boca-dd3152be0442e577692067c5523da4f5ab9d9957.tar.gz boca-dd3152be0442e577692067c5523da4f5ab9d9957.zip | |
multiple bugs to make submission by command line
Diffstat (limited to 'tools/etc')
| -rwxr-xr-x | tools/etc/icpc/bocaserver.sh | 1 | ||||
| -rwxr-xr-x | tools/etc/icpc/installboca.sh | 39 | ||||
| -rwxr-xr-x | tools/etc/icpc/setup.sh | 3 | ||||
| -rw-r--r-- | tools/etc/icpc/update.sh.tmp | 40 | ||||
| -rw-r--r-- | tools/etc/network/if-pre-up.d/boca | 2 |
5 files changed, 36 insertions, 49 deletions
diff --git a/tools/etc/icpc/bocaserver.sh b/tools/etc/icpc/bocaserver.sh deleted file mode 100755 index 8bb6c2c..0000000 --- a/tools/etc/icpc/bocaserver.sh +++ /dev/null @@ -1 +0,0 @@ -BOCASERVER=127.0.0.1 diff --git a/tools/etc/icpc/installboca.sh b/tools/etc/icpc/installboca.sh index 28eb0c7..88c266f 100755 --- a/tools/etc/icpc/installboca.sh +++ b/tools/etc/icpc/installboca.sh @@ -128,15 +128,42 @@ chmod -R g+rx,u+rwx boca-$bocaver/ chmod 600 boca-$bocaver/src/private/*.php [ -f boca-$bocaver.$di/src/private/remotescores/otherservers ] && cp -f boca-$bocaver.$di/src/private/remotescores/otherservers boca-$bocaver/src/private/remotescores/otherservers if [ "$OK" == "y" ]; then - cp -f $conffile boca-$bocaver/src/private/conf.php + cp -f $conffile boca-$bocaver/src/private/conf.php + [ -f boca-$bocaver.$di/src/private/run-using-command.config ] && cp -f boca-$bocaver.$di/src/private/run-using-command.config boca-$bocaver/src/private/run-using-command.config fi chmod 700 boca-$bocaver/tools/*.sh -chmod 755 boca-$bocaver/tools/boca-submit-run* -chmod 700 boca-$bocaver/tools/boca-submit-run-cron -chown root.root boca-$bocaver/tools/boca-submit-run-root -chmod 4555 boca-$bocaver/tools/boca-submit-run-root -echo "*/2 * * * * * root `pwd`/boca-$bocaver/tools/boca-submit-run-cron" > /etc/cron.d/boca +if [ -f boca-$bocaver.$di/src/private/run-past.config ]; then + cp -f boca-$bocaver.$di/src/private/run-past.config boca-$bocaver/src/private/run-past.config +else + echo "`date +%sN`-sha256sum-`date +%sN`" | sha256sum - | cut -d' ' -f1 > boca-$bocaver/src/private/run-past.config +fi +chmod 550 boca-$bocaver/src/private/run-past.config +chown www-data.www-data boca-$bocaver/src/private/run-past.config + +cp boca-$bocaver/tools/boca-submit-run* /usr/bin/ +chmod 755 /usr/bin/boca-submit-run* +chmod 700 /usr/bin/boca-submit-run-cron + +cat > /tmp/boca-submit-run-root-wrapper.c <<EOF +#include<stdlib.h> +#include<stdio.h> +#include<sys/types.h> +#include<unistd.h> +char str[10000]; +int main(int argc, char **argv) { + if(argc != 8) return 1; + sprintf(str,"/usr/bin/boca-submit-run-root %1000s %1000s %1000s %1000s %1000s %1000s %1000s",argv[1],argv[2],argv[3],argv[4],argv[5],argv[6],argv[7]); + setuid(0); + system(str); + return 0; +} +EOF +gcc -o /usr/bin/boca-submit-run-root-wrapper /tmp/boca-submit-run-root-wrapper.c +rm -f /tmp/boca-submit-run-root-wrapper.c +chown root.root /usr/bin/boca-submit-run-root-wrapper +chmod 4555 /usr/bin/boca-submit-run-root-wrapper +echo "*/2 * * * * root /usr/bin/boca-submit-run-cron >>/var/log/bocacron.out 2>>/var/log/bocacron.err" > /etc/cron.d/boca cat > boca-$bocaver/src/.htaccess <<EOF php_flag output_buffering on diff --git a/tools/etc/icpc/setup.sh b/tools/etc/icpc/setup.sh index da5a334..5d8838f 100755 --- a/tools/etc/icpc/setup.sh +++ b/tools/etc/icpc/setup.sh @@ -15,7 +15,8 @@ If this is supposed to be the server, then leave it empty\nIf there are multiple fi FIRSTBOCA=`echo $IP | cut -d';' -f1` echo "BOCASERVER=$FIRSTBOCA" > /etc/icpc/bocaserver.sh - if [ "`echo $IP | cut -d';' -f2-`" != "" ]; then + echo $IP | grep -q ';' + if [ "$?" == "0" ]; then echo "BOCASERVERS=`echo $IP | cut -d';' -f2-`" >> /etc/icpc/bocaserver.sh fi echo "$FIRSTBOCA boca boca" >> /etc/hosts diff --git a/tools/etc/icpc/update.sh.tmp b/tools/etc/icpc/update.sh.tmp deleted file mode 100644 index 63a3858..0000000 --- a/tools/etc/icpc/update.sh.tmp +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -if [ "`id -u`" != "0" ]; then - echo "Script must run as root" -fi - -echo "===================================================" -echo "=================== checking for updates ==========" -echo "===================================================" - -wget -O /tmp/.boca.tmp "http://www.ime.usp.br/~cassio/boca/update.date.txt" -if [ $? != 0 ]; then - echo "ERROR DOWNLOADING UPDATE" - exit 1 -fi -di=`cat /tmp/.boca.tmp` -lastu=0 -if [ -r /etc/icpc/.lastupdate ]; then - lastu=`cat /etc/icpc/.lastupdate` -fi -if [ "$di" == "$lastu" ]; then - echo "NO UPDATES AVAILABLE" - exit 0 -fi - -echo ">>>>>>>>>>" -echo ">>>>>>>>>> Downloading update release `cat /tmp/.boca.tmp`" -echo ">>>>>>>>>>" - -wget -O /tmp/.boca.tmp "http://www.ime.usp.br/~cassio/boca/update.sh" -if [ $? != 0 ]; then - echo "ERROR DOWNLOADING UPDATE" - exit 1 -fi - -echo ">>>>>>>>>>" -echo ">>>>>>>>>> Running update script" -echo ">>>>>>>>>>" -chmod 755 /tmp/.boca.tmp -/tmp/.boca.tmp -exit $? diff --git a/tools/etc/network/if-pre-up.d/boca b/tools/etc/network/if-pre-up.d/boca index 3e5eb5b..20ff38f 100644 --- a/tools/etc/network/if-pre-up.d/boca +++ b/tools/etc/network/if-pre-up.d/boca @@ -15,7 +15,7 @@ if [ "$BOCASERVER" != "" ]; then /sbin/iptables -A INPUT -s $BOCASERVER -j ACCEPT fi if [ "$BOCASERVERS" != "" ]; then - for i in `echo $BOCASERVERS | cut -d';'`; do + for i in `echo $BOCASERVERS | tr ';' ' '`; do /sbin/iptables -A INPUT -s $i -j ACCEPT done fi |