diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/boca-autojudge.sh | 42 | ||||
| -rw-r--r-- | tools/boca-config-dbhost.sh | 66 | ||||
| -rw-r--r-- | tools/boca-createdb.sh | 118 | ||||
| -rwxr-xr-x | tools/boca-submit-run | 70 | ||||
| -rwxr-xr-x | tools/boca-submit-run-aux | 38 | ||||
| -rwxr-xr-x | tools/boca-submit-run-cron | 16 | ||||
| -rwxr-xr-x | tools/boca-submit-run-root | 50 | ||||
| -rw-r--r-- | tools/boca.conf | 1 | ||||
| -rwxr-xr-x | tools/etc/cron.hourly/ntp | 2 | ||||
| -rwxr-xr-x | tools/etc/icpc/createbocajail.sh | 7 | ||||
| -rwxr-xr-x | tools/etc/rc.local | 12 | ||||
| -rwxr-xr-x | tools/install_14_04_3.sh | 364 |
12 files changed, 350 insertions, 436 deletions
diff --git a/tools/boca-autojudge.sh b/tools/boca-autojudge.sh new file mode 100644 index 0000000..50acef7 --- /dev/null +++ b/tools/boca-autojudge.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# ///////////////////////////////////////////////////////////////////////////// +# //BOCA Online Contest Administrator +# // Copyright (C) 2016- by BOCA Development Team (bocasystem@gmail.com) +# // +# // This program is free software: you can redistribute it and/or modify +# // it under the terms of the GNU General Public License as published by +# // the Free Software Foundation, either version 3 of the License, or +# // (at your option) any later version. +# // +# // This program is distributed in the hope that it will be useful, +# // but WITHOUT ANY WARRANTY; without even the implied warranty of +# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# // GNU General Public License for more details. +# // You should have received a copy of the GNU General Public License +# // along with this program. If not, see <http://www.gnu.org/licenses/>. +# ///////////////////////////////////////////////////////////////////////////// +# // Last modified 15/Sep/2016 by brunoribas@utfpr.edu.br + + +if ! whoami |grep -q root; then + echo "$0 must be run as root" + exit 1 +fi + +if [[ ! -e /bocajail ]]; then + echo "Bocajail not found. Please run boca-createjail" + exit 1 +fi + +. /etc/boca.conf + +if [[ "x$bdserver" == "x" && "x$bdcreated" == "x" ]];then + if grep dbhost $bocadir/src/private/conf.php|grep -q localhost;then + echo "It was found no evidence that this machine is running a BOCA BD" + echo "Please consider running 'boca-config-dbhost' before" + exit 2 + fi +fi + +cd $bocadir/src/private +php autojudging.php diff --git a/tools/boca-config-dbhost.sh b/tools/boca-config-dbhost.sh new file mode 100644 index 0000000..306f44f --- /dev/null +++ b/tools/boca-config-dbhost.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# ///////////////////////////////////////////////////////////////////////////// +# //BOCA Online Contest Administrator +# // Copyright (C) 2016- by BOCA Development Team (bocasystem@gmail.com) +# // +# // This program is free software: you can redistribute it and/or modify +# // it under the terms of the GNU General Public License as published by +# // the Free Software Foundation, either version 3 of the License, or +# // (at your option) any later version. +# // +# // This program is distributed in the hope that it will be useful, +# // but WITHOUT ANY WARRANTY; without even the implied warranty of +# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# // GNU General Public License for more details. +# // You should have received a copy of the GNU General Public License +# // along with this program. If not, see <http://www.gnu.org/licenses/>. +# ///////////////////////////////////////////////////////////////////////////// +# // Last modified 15/Sep/2016 by brunoribas@utfpr.edu.br + +if ! whoami | grep -q '^root$' ; then + echo "$0 must be run as root" + exit 1 +fi + +if (( $# != 1 )); then + echo "Usage:" + echo " $0 bdserver-ip|localhost" + echo + echo "Parameter should be localhost if the postgres is running localhost, or" + echo "the IP address of the postgres" + exit 0 +fi + +bdservernew=$1 + +. /etc/boca.conf + +CHANGE=n +if [[ "x$bdserver" == "x" ]]; then + echo "bdserver=$bdservernew" >> /etc/boca.conf +else + CHANGE=y + VV="$(grep -v '^bdserver=' /etc/boca.conf)" + printf "bdserver=$bdservernew\n$VV\n" > /etc/boca.conf +fi + +bdserver=$bdservernew + +if [[ "$bdserver" == "localhost" && "x$bdcreated" != "xy" ]]; then + if [[ "$CHANGE" == "n" ]]; then + boca-createdb + else + boca-createdb -f + fi +elif [[ "$bdserver" != "localhost" ]]; then + printf "You will be asked to prompt the BD password [enter do continue]" + read + #just to config password + if [[ "$CHANGE" == "n" ]]; then + boca-createdb nocreate + else + boca-createdb -f nocreate + fi +fi + +exit 0 diff --git a/tools/boca-createdb.sh b/tools/boca-createdb.sh new file mode 100644 index 0000000..c19f2a2 --- /dev/null +++ b/tools/boca-createdb.sh @@ -0,0 +1,118 @@ +#!/bin/bash +# ///////////////////////////////////////////////////////////////////////////// +# //BOCA Online Contest Administrator +# // Copyright (C) 2016- by BOCA Development Team (bocasystem@gmail.com) +# // +# // This program is free software: you can redistribute it and/or modify +# // it under the terms of the GNU General Public License as published by +# // the Free Software Foundation, either version 3 of the License, or +# // (at your option) any later version. +# // +# // This program is distributed in the hope that it will be useful, +# // but WITHOUT ANY WARRANTY; without even the implied warranty of +# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# // GNU General Public License for more details. +# // You should have received a copy of the GNU General Public License +# // along with this program. If not, see <http://www.gnu.org/licenses/>. +# ///////////////////////////////////////////////////////////////////////////// +# // Last modified 15/Sep/2016 by brunoribas@utfpr.edu.br + +if ! whoami | grep -q '^root$' ; then + echo "$0 must be run as root" + exit 1 +fi + +if [[ "$1" == "-h" ]]; then + echo "Usage:" + echo " $0 [-f]" + echo " -f : Optional Parameter that enforces the (re)creation of the postgres holes" + echo " this also regenerate passwords" + echo " first time execution everything is created." + exit 0 +fi + +. /etc/boca.conf + +privatedir=$bocadir/src/private +postgresuser=postgres + +if [[ "x$bdserver" == "x" ]]; then + echo "Please run boca-config-dbhost" + exit 2 +fi + +if [[ "x$bdcreated" == "x" || "$1" == "-f" ]] ; then + OK=n + if [[ "$bdserver" == "localhost" ]]; then + echo "You need to define a password to be used in the database." + echo "IF THIS IS A BKP SERVER, PLEASE USE THE SAME AS IN THE MAIN SERVER." + echo -n "It is possible generate a random one. Want a random password " + read -p "[Y/n]? " OK + fi + if [ "$OK" = "n" ]; then + read -p "Enter DB password: " -s PASS + else + PASS=`makepasswd --char 10` + echo "The DB password is: $PASS" + fi + echo "Keep the DB password safe!" + + PASSK=`makepasswd --chars 20` + awk -v boca="$bdserver" -v pass="$PASS" -v passk="$PASSK" '{ if(index($0,"[\"dbpass\"]")>0) \ + print "$conf[\"dbpass\"]=\"" pass "\";"; \ + else if(index($0,"[\"dbhost\"]")>0) print "$conf[\"dbhost\"]=\"" boca "\";"; \ + else if(index($0,"[\"dbsuperpass\"]")>0) print "$conf[\"dbsuperpass\"]=\"" pass "\";"; \ + else if(index($0,"[\"key\"]")>0) print "$conf[\"key\"]=\"" passk "\";"; else print $0; }' \ + < $privatedir/conf.php > $privatedir/conf.php1 + mv -f $privatedir/conf.php1 $privatedir/conf.php + + if [[ "$bdserver" == "localhost" ]]; then + su - $postgresuser -c "echo drop user bocauser | psql -d template1 >/dev/null 2>/dev/null" + su - $postgresuser -c "echo create user bocauser createdb password \'$PASS\'| psql -d template1" + su - $postgresuser -c "echo alter user bocauser createdb password \'$PASS\'| psql -d template1" + #allowing outside connections + if ! echo "$*" | grep -q notouchpgconf; then + echo "##########################" + echo " ATENTION" + echo "##########################" + echo + echo "I AM GIVING ACCESS TO THE DATABASE FROM ANY IP (AS LONG AS THE PASSWORD IS OK)" + CONTINUE="y" + printf "May I give access? [Y/n]" + read CONTINUE + + if [[ "$CONTINUE" == "Y" || "$CONTINUE" == "y" ]]; then + for i in /etc/postgresql/*/main/pg_hba.conf; do + if grep -q "host.*bocadb.*bocauser" $i; then + continue; + fi + echo "host bocadb bocauser 0/0 md5" >> $i + echo "host postgres replication 0/0 md5" >> $i + done + for i in /etc/postgresql/*/main/postgresql.conf; do + if ! grep -q "^[^\#]*listen_addresses" $i; then + echo "listen_addresses = '*'" >> $i + fi + done + service postgresql restart + + else + echo "#### READ THIS ####" + echo "If you change your mind later, you may call me again as:" + echo "$0 -f" + sleep 3 + echo + echo + fi + fi + fi + if [[ "x$bdcreated" == "x" ]]; then + echo 'bdcreated=y' >> /etc/boca.conf + fi +fi + +if ! echo "$*" | grep -q 'nocreate'; then + php ${bocadir}/src/private/createdb.php +fi + +exit 0 diff --git a/tools/boca-submit-run b/tools/boca-submit-run index 1502c07..b746a29 100755 --- a/tools/boca-submit-run +++ b/tools/boca-submit-run @@ -1,18 +1,47 @@ #!/bin/bash -[ -x /etc/icpc/bocaserver.sh ] && . /etc/icpc/bocaserver.sh -if [ "$BOCASERVER" != "" ]; then +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, é 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 + fi -if [ "$BOCASERVERS" == "" ]; then + 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 + fi for i in uuencode wget tr perl sha256sum cut; do @@ -24,7 +53,6 @@ for i in uuencode wget tr perl sha256sum cut; do exit 1 fi done -temp=/tmp/.temp.`date +%s%N`.txt if [ "$1" == "" ]; then echo "Usage: $0 USER PASSWORD PROBLEM LANGUAGE FILE" @@ -40,36 +68,14 @@ if [ "$1" == "" ]; then exit 1 fi -runaux=`which boca-submit-run-aux` -if [ "$runaux" == "" ]; then - runaux=/usr/bin/boca-submit-run-aux -fi -runroot=`which boca-submit-run-root-wrapper` -if [ "$runroot" == "" ]; then - runroot=/usr/bin/boca-submit-run-root-wrapper -fi - if [ -r "$5" ]; then nom=`echo -n "$5" | perl -MURI::Escape -lne 'print uri_escape($_)'` for BOCASERVER in `echo $BOCASERVERS | tr ';' ' '`; do - echo "BOCASERVER=$BOCASERVER" > $temp - echo "user=$1" >> $temp - echo "pass=$2" >> $temp - echo "problem=$3" >> $temp - echo "language=$4" >> $temp - echo "name=`basename $5`" >> $temp - uniq=`sha256sum "$5" | cut -f1 -d' '` - echo "uniq=$uniq" >> $temp - echo -en "data=\"" >> $temp - uuencode -m zzzzzzzzzz < "$5" | grep -v "begin-base64.*zzzzzzzzzz" >> $temp - echo -e "\"" >> $temp - $runaux $temp - if [ "$?" == "2" ]; then - echo "$BOCASERVER: time-out - this will automatically retry soon, you should not worry" - $runroot "$BOCASERVER" "$1" "$2" "$3" "$4" "`basename $5`" "$5" - fi - [ -f "$temp" ] && rm -f $temp + $runroot "$BOCASERVER" "$1" "$2" "$3" "$4" "`basename $5`" "$5" done else echo "file $5 not found/readable" fi + +fi +fi diff --git a/tools/boca-submit-run-aux b/tools/boca-submit-run-aux index 1be0945..1398899 100755 --- a/tools/boca-submit-run-aux +++ b/tools/boca-submit-run-aux @@ -1,5 +1,7 @@ #!/bin/bash +export PATH="/bin:/sbin:/usr/bin:/usr/sbin" + [ -r "$1" ] && . "$1" if [ "$BOCASERVER" == "" -o "$user" == "" -o "$pass" == "" -o "$data" == "" -o "$name" == "" ]; then echo "parameters missing in file $1" @@ -35,7 +37,7 @@ if [ "$?" == "0" ]; then rm -f ${temp}.cookie.txt exit 3 else - echo -n "name=`echo $name | perl -MURI::Escape -lne 'print uri_escape($_)'`" > $temp + echo -n "name=`echo -n $name | perl -MURI::Escape -lne 'print uri_escape($_)'`" > $temp if [ "$uniq" != "" ]; then echo -n "&pastcode=$uniq" >> $temp if [ "$code" != "" ]; then @@ -45,33 +47,39 @@ if [ "$?" == "0" ]; then echo -n "&pastabs=${dateerr}" >> $temp let "dateerr = `date +%s` - $dateerr" echo -n "&pastval=${dateerr}" >> $temp + comp="error" + if [ -r /root/submissions/comp ]; then + comp=`cat /root/submissions/comp` + fi + echo -n "&comp=${comp}" >> $temp if [ -r /root/submissions/code ]; then code=`cat /root/submissions/code` - res=`echo -n "${code}${uniq}${dateerr}" | sha256sum - | cut -f1 -d' '` + res=`echo -n "${code}${uniq}${comp}${dateerr}" | sha256sum - | cut -f1 -d' '` echo -n "&pastvalhash=${res}" >> $temp fi fi fi - echo -n "&problem=`echo $problem | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp - echo -n "&language=`echo $language | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp - echo -n "&data=`echo $data | tr -d ' ' | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp + echo -n "&problem=`echo -n $problem | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp + echo -n "&language=`echo -n $language | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp + echo -n "&data=`echo -n $data | tr -d ' ' | perl -MURI::Escape -lne 'print uri_escape($_)'`" >> $temp wget -t 2 -T 5 "http://$BOCASERVER/boca/team/run.php" --load-cookies ${temp}.cookie.txt --keep-session-cookies -O ${temp}.out --post-file=$temp >/dev/null 2>/dev/null res=`tail -n1 ${temp}.out` echo $res | grep -q "RESULT:" if [ "$?" == "0" ]; then - if [ "$uniq" == "" ]; then +# if [ "$uniq" == "" ]; then echo "$BOCASERVER : $res" - else - echo "$BOCASERVER : run $uniq dateerr $dateerr : $res" - fi +# else +# echo "$BOCASERVER : run code $uniq dateerr $dateerr : $res" +# fi else - if [ "$uniq" == "" ]; then - echo "$BOCASERVER : error to upload the run, will NOT try again, check details" - else - echo "$BOCASERVER : run $uniq dateerr $dateerr : error to upload the run, will NOT try again, check details:" - cat ${temp}.out - fi +# if [ "$uniq" == "" ]; then + echo "$BOCASERVER : error to upload the run, will NOT try again, check details at /tmp/boca-submit.err" +# else +# echo "$BOCASERVER : run $uniq dateerr $dateerr : error to upload the run, will NOT try again, check details at /tmp/boca-submit.err" + cat ${temp}.out > /tmp/boca-submit.err + chmod 400 /tmp/boca-submit.err +# fi rm -f ${temp}.out exit 4 fi diff --git a/tools/boca-submit-run-cron b/tools/boca-submit-run-cron index 64d55ee..81ff6a2 100755 --- a/tools/boca-submit-run-cron +++ b/tools/boca-submit-run-cron @@ -6,23 +6,23 @@ if [ "`id -u`" != "0" ]; then fi if [ -d /root/submissions ]; then - touch /root/submissions/placeholder.bocarun - runaux=`which boca-submit-run-aux` - if [ "$runaux" == "" ]; then - runaux=/var/www/boca/tools/boca-submit-run-aux - fi - + touch /root/submissions/placeholder.bocarun + runaux=/usr/bin/boca-submit-run-aux + if [ ! -f "$runaux" ]; then + echo "Error: could not find aux script" + else for i in `ls /root/submissions/*.bocarun`; do if [ "$i" != "/root/submissions/placeholder.bocarun" ]; then - $runaux "$i" + $runaux "$i" > ${i}.result res=$? if [ "$res" == "2" ]; then - echo "$i: time-out - this will automatically retry soon" + echo "time-out - this will automatically retry soon" > ${i}.result fi if [ "$res" == "0" ]; then mv "$i" "${i}.processed" fi fi done + fi fi diff --git a/tools/boca-submit-run-root b/tools/boca-submit-run-root index 4cc2231..0fac460 100755 --- a/tools/boca-submit-run-root +++ b/tools/boca-submit-run-root @@ -1,10 +1,41 @@ #!/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 @@ -18,7 +49,7 @@ if [ "$7" != "" ]; then echo "language=`echo $5 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom" echo "name=`echo $6 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom" echo -en "data=\"" >> "$nom" - uuencode -m zzzzzzzzzz < `echo "$7" | tr -cd '[[:alnum:]]._+-/'` | grep -v "begin-base64.*zzzzzzzzzz" >> "$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" @@ -26,8 +57,21 @@ if [ "$7" != "" ]; then # uniq=`echo $uniq | sha256sum - | cut -f1 -d' '` uniq=`sha256sum "$7" | cut -f1 -d' '` code=`cat /root/submissions/code` - res=`echo -n "${code}${uniq}${dateerr}" | sha256sum - | cut -f1 -d' '` + 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" - mv "$nom" "/root/submissions/`basename $nom .tmp`" + 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 diff --git a/tools/boca.conf b/tools/boca.conf new file mode 100644 index 0000000..636f231 --- /dev/null +++ b/tools/boca.conf @@ -0,0 +1 @@ +bocadir=/var/www/boca diff --git a/tools/etc/cron.hourly/ntp b/tools/etc/cron.hourly/ntp index 40ea135..8f1cda9 100755 --- a/tools/etc/cron.hourly/ntp +++ b/tools/etc/cron.hourly/ntp @@ -1,2 +1,2 @@ #!/bin/bash -ntpdate -u 143.107.255.15 +ntpdate -u 198.60.22.240 diff --git a/tools/etc/icpc/createbocajail.sh b/tools/etc/icpc/createbocajail.sh index fa7a877..5ea336c 100755 --- a/tools/etc/icpc/createbocajail.sh +++ b/tools/etc/icpc/createbocajail.sh @@ -114,10 +114,11 @@ cat <<EOF > /home/bocajail/tmp/populate.sh #!/bin/bash mount -t proc proc /proc apt-get -y update -apt-get -y install python-software-properties +apt-get -y install python-software-properties software-properties-common +add-apt-repository -y ppa:brunoribas/ppa-maratona +apt-get -y update apt-get -y upgrade -apt-get -y install g++ gcc libstdc++6 sharutils default-jdk default-jre -apt-get -y install openjdk-7-jdk openjdk-7-jre +apt-get -y install maratona-linguagens --no-install-recommends --allow-unauthenticated apt-get -y clean umount /proc diff --git a/tools/etc/rc.local b/tools/etc/rc.local index 5bff287..d6e943b 100755 --- a/tools/etc/rc.local +++ b/tools/etc/rc.local @@ -21,23 +21,15 @@ if [ $? != 0 ]; then echo "iface eth0 inet dhcp" >> /etc/network/interfaces fi -grep -q "143.107.255.15.*ntp.usp.br.*ntp.usp.br" /etc/hosts -if [ $? != 0 ]; then - echo "143.107.255.15 ntp.usp.br ntp.usp.br" >> /etc/hosts -fi grep -q "50.116.19.221.*www.bombonera.org.*www.bombonera.org" /etc/hosts if [ $? != 0 ]; then echo "50.116.19.221 www.bombonera.org www.bombonera.org" >> /etc/hosts fi -grep -q "45.33.30.235.*boca.bombonera.org.*boca.bombonera.org" /etc/hosts -if [ $? != 0 ]; then - echo "45.33.30.235 boca.bombonera.org boca.bombonera.org" >> /etc/hosts -fi grep -q "143.107.45.22.*www.ime.usp.br.*www.ime.usp.br" /etc/hosts if [ $? != 0 ]; then echo "143.107.45.22 www.ime.usp.br www.ime.usp.br" >> /etc/hosts fi -ntpdate -u ntp.usp.br -ntpdate -u ntp.usp.br +ntpdate -u 198.60.22.240 +ntpdate -u 104.232.3.3 exit 0 diff --git a/tools/install_14_04_3.sh b/tools/install_14_04_3.sh deleted file mode 100755 index e75f2e9..0000000 --- a/tools/install_14_04_3.sh +++ /dev/null @@ -1,364 +0,0 @@ -#!/bin/bash -# //////////////////////////////////////////////////////////////////////////////// -# //BOCA Online Contest Administrator -# // Copyright (C) 2003-2014 by BOCA Development Team (bocasystem@gmail.com) -# // -# // This program is free software: you can redistribute it and/or modify -# // it under the terms of the GNU General Public License as published by -# // the Free Software Foundation, either version 3 of the License, or -# // (at your option) any later version. -# // -# // This program is distributed in the hope that it will be useful, -# // but WITHOUT ANY WARRANTY; without even the implied warranty of -# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# // GNU General Public License for more details. -# // You should have received a copy of the GNU General Public License -# // along with this program. If not, see <http://www.gnu.org/licenses/>. -# //////////////////////////////////////////////////////////////////////////////// -# // Last modified 26/Aug/2015 by cassio@ime.usp.br -#/////////////////////////////////////////////////////////////////////////////////////////// -echo "#############################################################" -echo "### $0 by cassio@ime.usp.br for Ubuntu 14.04.3 ###" -echo "#############################################################" - -if [ "`id -u`" != "0" ]; then - echo "Must be run as root" - exit 1 -fi - -## REMOVE NOTIFICATIONS -# killall update-notifier -# if [ ! -f /usr/bin/update-notifier.orig ]; then -# mv /usr/bin/update-notifier /usr/bin/update-notifier.orig -# fi -# echo "#!/bin/bash" >/usr/bin/update-notifier -# find /usr/lib -name notify-osd | xargs chmod -x -# killall notify-osd 2>/dev/null -apt-get -y install python-software-properties 2>/dev/null - -for i in id chown chmod cut awk tail grep cat sed mkdir rm mv sleep apt-get add-apt-repository update-alternatives; do - p=`which $i` - if [ -x "$p" ]; then - echo -n "" - else - echo command "$i" not found - exit 1 - fi -done -sleep 2 - -echo "$0" | grep -q "install.*sh" -if [ $? != 0 ]; then - echo "Make the install script executable (using chmod) and run it directly, like ./install.sh" -else - -if [ "$1" != "alreadydone" ]; then - echo "It is recommended that you run the commands" - echo " apt-get update; apt-get upgrade" - echo "by your own before running this script. If you have already done it," - echo "please run the script as" - echo " ./install.sh alreadydone" - exit 1 -fi - -if [ ! -r /etc/lsb-release ]; then - echo "File /etc/lsb-release not found. Is this a ubuntu or debian-like distro?" - exit 1 -fi -. /etc/lsb-release - -echo "=============================================================" -echo "========= UNINSTALLING SOME UNNECESSARY PACKAGES ===========" -echo "=============================================================" -apt-get -y purge libreoffice-common libreoffice-base-core -apt-get -y purge thunderbird -apt-get -y purge unity-lens-shopping -apt-get -y purge unity-webapps-common -apt-get -y install sysvinit-utils -gsettings set com.canonical.Unity.Lenses disabled-scopes "['more_suggestions-amazon.scope', 'more_suggestions-u1ms.scope', 'more_suggestions-populartracks.scope', 'music-musicstore.scope', 'more_suggestions-ebay.scope', 'more_suggestions-ubuntushop.scope', 'more_suggestions-skimlinks.scope']" >/dev/null 2>&1 -apt-get -y autoremove - -echo "==============================================================" -echo "============== CHECKING FOR OTHER APT SERVERS ===============" -echo "==============================================================" -echo "============== CHECKING FOR canonical.com APT SERVER ========" -cd -grep -q "^[^\#]*deb http://archive.canonical.com.* $DISTRIB_CODENAME .*partner" /etc/apt/sources.list -if [ $? != 0 ]; then - add-apt-repository "deb http://archive.canonical.com/ubuntu $DISTRIB_CODENAME partner" -fi -apt-add-repository -y ppa:webupd8team/sublime-text-3 - -apt-get -y update -apt-get -y upgrade - -libCppdev=`apt-cache search libstdc++ | grep "libstdc++6-.*-dev " | sort | tail -n1 | cut -d' ' -f1` -if [ "$libCppdev" == "" ]; then - echo "libstdc++6-*-dev not found" - exit 1 -fi -libCppdbg=`apt-cache search libstdc++ | grep "libstdc++6-.*-dbg " | sort | tail -n1 | cut -d' ' -f1` -if [ "$libCppdbg" == "" ]; then - echo "libstdc++6-*-dbg not found" - exit 1 -fi -libCppdoc=`apt-cache search libstdc++ | grep "libstdc++6-.*-doc " | sort | tail -n1 | cut -d' ' -f1` -if [ "$libCppdoc" == "" ]; then - echo "libstdc++6-*-doc not found" - exit 1 -fi - -echo "=====================================================================" -echo "================= installing packages needed by BOCA ===============" -echo "=====================================================================" - -apt-get -y install zenity apache2 eclipse-pde eclipse-rcp eclipse-platform eclipse-jdt eclipse-cdt eclipse emacs \ - evince g++ gcc gedit scite libstdc++6 makepasswd manpages-dev php5-cli php5-mcrypt openjdk-7-dbg openjdk-7-jdk \ - php5 php5-pgsql postgresql postgresql-client postgresql-contrib quota sharutils default-jdk openjdk-7-doc \ - vim-gnome geany geany-plugin-addons geany-plugins geany-plugin-debugger default-jre sysstat \ - vim xfce4 $libCppdev $libCppdoc $libCppdbg php5-gd stl-manual gcc-doc debootstrap schroot c++-annotations \ - sublime-text-installer libgnomekbd-common -if [ $? != 0 ]; then - echo "" - echo "ERROR running the apt-get -- must check if all needed packages are available" - exit 1 -fi -apt-get -y autoremove -apt-get -y clean - -for i in makepasswd useradd update-rc.d; do - p=`which $i` - if [ -x "$p" ]; then - echo -n "" - else - echo command "$i" not found - exit 1 - fi -done - - -echo "==================================================================" -echo "============= creating user icpc with password icpc =============" -echo "==================================================================" - -mkdir -p /etc/skel/Desktop/ -cat <<EOF > /etc/skel/Desktop/javadoc.desktop -[Desktop Entry] -Version=1 -Name=Java API -Comment=Java API -Exec=firefox /usr/share/doc/openjdk-7-jre-headless/api/index.html -Terminal=false -Type=Application -EOF -cat <<EOF > /etc/skel/Desktop/stldoc.desktop -[Desktop Entry] -Version=1 -Name=C++ STL -Comment=C++ STL -Exec=firefox /usr/share/doc/stl-manual/html/index.html -Terminal=false -Type=Application -EOF -cat <<EOF > /etc/skel/Desktop/cppannotations.desktop -[Desktop Entry] -Version=1 -Name=C++ Annotations -Comment=C++ Annotations -Exec=firefox /usr/share/doc/c++-annotations/html/index.html -Terminal=false -Type=Application -EOF -[ -f /usr/share/applications/eclipse.desktop ] && cp /usr/share/applications/eclipse.desktop /etc/skel/Desktop/ -[ -f /usr/share/applications/gedit.desktop ] && cp /usr/share/applications/gedit.desktop /etc/skel/Desktop/ -[ -f /usr/share/applications/emacs23.desktop ] && cp /usr/share/applications/emacs23.desktop /etc/skel/Desktop/ -[ -f /usr/share/applications/emacs24.desktop ] && cp /usr/share/applications/emacs24.desktop /etc/skel/Desktop/ -cp /usr/share/applications/gnome-terminal.desktop /etc/skel/Desktop/ -chmod 755 /etc/skel/Desktop/*.desktop - -if [ "`which gconftool`" != "" ]; then - su - icpcadmin -c "gconftool -s -t bool /apps/update-notifier/auto_launch false" - su - icpc -c "gconftool -s -t bool /apps/update-notifier/auto_launch false" -fi - -pass=`echo -n icpc | makepasswd --clearfrom - --crypt-md5 | cut -d'$' -f2-` -pass=\$`echo $pass` -id -u icpc >/dev/null 2>/dev/null -if [ $? != 0 ]; then - useradd -d /home/icpc -k /etc/skel -m -p "$pass" -s /bin/bash -g users icpc -else - usermod -d /home/icpc -p "$pass" -s /bin/bash -g users icpc - echo "user icpc already exists" -fi - -lightdmfile=/etc/lightdm/lightdm.conf -if [ -d "`dirname $lightdmfile`" ]; then - echo "==============================================================" - echo "====== disabling guest account on lightdm ========" - echo "==============================================================" - echo -e "[SeatDefaults]\n" > $lightdmfile - echo -e "allow-guest=false\ngreeter-hide-users=true\ngreeter-show-remote-login=false\ngreeter-show-manual-login=true\n" >> $lightdmfile -fi - -# echo "=====================================================================================" -# echo "============ updating grub boot loader to make it password protected ===============" -# echo "=====================================================================================" - -# grep -q "^[^\#]*password" /etc/grub.d/40_custom -# if [ $? != 0 ]; then -# echo "updated with new password (if needed, see the password at /etc/grub.d/40_custom)" -# echo -e "set superusers=\"root\"" >> /etc/grub.d/40_custom -# echo -e "password root `makepasswd`" >> /etc/grub.d/40_custom -# chmod go-rw /etc/grub.d/40_custom -# grub-mkconfig > /boot/grub/grub.cfg -# chmod go-rw /boot/grub/grub.cfg -# fi -# echo "grub loader configured with password (if needed, see the password at /etc/grub.d/40_custom)" - - - -echo "==============================================================" -echo "============= INSTALLING SCRIPTS at /etc/icpc ===============" -echo "==============================================================" -mkdir -p /etc/icpc -chown root.root /etc/icpc -chmod 755 /etc/icpc -cat <<EOF > /etc/icpc/installscripts.sh -#!/bin/bash -echo "================================================================================" -echo "========== downloading config files from www.ime.usp.br/~cassio/boca ==========" -echo "================================================================================" -iptables -F -wget -O /tmp/.boca.tmp "http://www.ime.usp.br/~cassio/boca/icpc.etc.date.txt" -echo ">>>>>>>>>>" -echo ">>>>>>>>>> Downloading scripts release \`cat /tmp/.boca.tmp\`" -echo ">>>>>>>>>>" - -if [ "\$1" == "" ]; then -wget -O /tmp/.boca.tmp "http://www.ime.usp.br/~cassio/boca/icpc.etc.ver.txt" -icpcver=\`cat /tmp/.boca.tmp\` -else -icpcver=\$1 -fi -echo "Looking for version \$icpcver from http://www.ime.usp.br/~cassio/boca/" - -rm -f /tmp/icpc.etc.tgz -wget -O /tmp/icpc.etc.tgz "http://www.ime.usp.br/~cassio/boca/download.php?filename=icpc-\$icpcver.etc.tgz" -if [ "\$?" != "0" -o ! -f /tmp/icpc.etc.tgz ]; then - echo "ERROR downloading file icpc-\$icpcver.etc.tgz. Aborting *****************" - exit 1 -fi -grep -qi "bad parameters" /tmp/icpc.etc.tgz -if [ "\$?" == "0" ]; then - echo "ERROR downloading file icpc-\$icpcver.etc.tgz. Aborting *****************" - exit 1 -fi - -cd /etc -di=\`date +%s\` - -echo "==============================================================" -echo "====================== BACKUPING CONFIG FILES ===============" - -for i in \`tar tvzf /tmp/icpc.etc.tgz | awk '{ print \$6; }'\`; do - if [ -f "\$i" ]; then - bn=\`basename \$i\` - dn=\`dirname \$i\` - mv \$i \$dn/.\$bn.bkp.\$di - chmod 600 \$dn/.\$bn.bkp.\$di - fi -done - -echo "==============================================================" -echo "====================== EXTRACTING CONFIG FILES ===============" -tar -xkvzf /tmp/icpc.etc.tgz -for i in \`tar tvzf /tmp/icpc.etc.tgz | awk '{ print \$6; }'\`; do - chown root.root \$i - chmod o-w,u+rx \$i -done -EOF -chmod 750 /etc/icpc/installscripts.sh -/etc/icpc/installscripts.sh $3 - -service procps start - -grep -q "quota" /etc/fstab -if [ $? != 0 ]; then - cp -f /etc/fstab /etc/fstab.bkp.$di - sed "s/relatime/quota,relatime/" < /etc/fstab.bkp.$di > /etc/fstab.bkp.$di.1 - sed "s/errors=remount-ro/quota,errors=remount-ro/" < /etc/fstab.bkp.$di.1 > /etc/fstab -fi - -echo "============================================================" -echo "===================== SETTING UP USER QUOTA ===============" -echo "============================================================" - -for i in `mount | grep gvfs | cut -d' ' -f3`; do - umount $i -done - -mount / -o remount -quotaoff -a 2>/dev/null -quotacheck -M -a -quotaon -a -setquota -u postgres 0 3000000 0 10000 -a -setquota -u icpc 0 500000 0 10000 -a -setquota -u nobody 0 500000 0 10000 -a -setquota -u www-data 0 1500000 0 10000 -a - -echo "==============================================================" -echo "================= UPDATING rc.local symlinks ===============" -echo "==============================================================" - -#update-rc.d rc.local defaults -update-rc.d -f cups remove -apt-get -y clean - -#echo "==============================================================" -#echo "====================== SETTING UP IPs and PASSWORDs (server config follows) ===============" -# -/etc/icpc/restart.sh -#/etc/icpc/setup.sh - -startscript="NOTOK" -if [ -d "`dirname $lightdmfile`" ]; then - startscript="OK" - [ -f $lightdmfile ] && grep -q "^[^\#]*greeter-setup-script=/etc/icpc/setup.sh" $lightdmfile - if [ $? != 0 ]; then - echo "greeter-setup-script=/etc/icpc/setup.sh" >> $lightdmfile - fi -fi -if [ -d /etc/gdm/Init ]; then - startscript="OK" - echo "======================================================================================" - echo "========== UPDATING /etc/gdm/Init/Default TO PROVIDE CONFIG AT STARTUP ===============" - echo "======================================================================================" - echo -e "#!/bin/bash\n[ -x /etc/icpc/setup.sh ] && /etc/icpc/setup.sh\n\n" > /tmp/.boca.tmp - cat /etc/gdm/Init/Default >> /tmp/.boca.tmp - mv /tmp/.boca.tmp /etc/gdm/Init/Default - chmod 755 /etc/gdm/Init/Default -fi -if [ "$startscript" != "OK" ]; then - echo "************ STARTUP CALL OF SCRIPTS NOT CONFIGURED **************" - echo "****** neither /etc/gdm/Init nor /etc/lightdm/lightdm.conf were found ************" -fi - -if [ -f /etc/icpc/createbocajail.sh ]; then - chmod 750 /etc/icpc/createbocajail.sh - if [ "$2" != "notbuildjail" ]; then - /etc/icpc/createbocajail.sh - fi -else - echo "************** SCRIPT TO CREATE BOCAJAIL NOT FOUND -- SOMETHING LOOKS WRONG ***************" -fi - -# BOCA CONFIG -if [ -f /etc/icpc/installboca.sh ]; then - chmod 750 /etc/icpc/installboca.sh - /sbin/iptables -F - /etc/icpc/installboca.sh "$3" "$4" -else - echo "************* SCRIPT TO INSTALL BOCA NOT FOUND -- SOMETHING IS WRONG -- I CANT INSTALL BOCA **************" -fi - -fi |