diff --git a/check.pl b/check.pl index 4c87106b..147e5ca0 100755 --- a/check.pl +++ b/check.pl @@ -88,23 +88,26 @@ for my $f (readdir $dh) # Register solve if ($good == -1) { - say localtime().": Exercice $exercice doesn't exist ; given by team $team in theme $theme."; + say STDERR localtime().": Exercice $exercice doesn't exist ; given by team $team in theme $theme."; } elsif ($good == 1) { # Check if the exercice exists $sth = query($dbh, "SELECT `require` FROM exercices E WHERE E.id_theme = $theme AND E.id = ".$dbh->quote($exercice)); - if ($sth->rows && (my $row = get_row($sth))) + if ($sth->rows) { + my $row = get_row($sth); + # Check if the team has solved dependancies - $sth = query($dbh, "SELECT COUNT(S.id) FROM solved S WHERE S.id_exercice = ".$dbh->quote(@$row[0])) if @$row[0]; - if (! (@$row[0] && $sth->rows)) + $sth = query($dbh, "SELECT S.id FROM solved S WHERE S.id_exercice = ".$dbh->quote(@$row[0])) if @$row[0]; + if (! @$row[0] || $sth->rows) { # Check if the team has not already solved this exercice - $sth = query($dbh, "SELECT COUNT(S.id) FROM solved S WHERE S.id_exercice = ".$dbh->quote($exercice)); + $sth = query($dbh, "SELECT S.id FROM solved S WHERE S.id_exercice = ".$dbh->quote($exercice)); if (! $sth->rows) { - say localtime().": Team $team solve exercice $exercice in $theme"; + say $team; + say STDERR localtime().": Team $team solve exercice $exercice in $theme"; query($dbh, "INSERT INTO solved (id_team, id_exercice, time) VALUES ($team, ".$dbh->quote($exercice).", CURRENT_TIMESTAMP);"); $exit++; } @@ -121,7 +124,7 @@ for my $f (readdir $dh) } } else { - say localtime().": Team $team didn't give the correct answer for exercice $exercice."; + say STDERR localtime().": Team $team didn't give the correct answer for exercice $exercice."; } # Remove the file diff --git a/clear_cache.sh b/clear_cache.sh new file mode 100755 index 00000000..cb528dd4 --- /dev/null +++ b/clear_cache.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +cd `dirname "$0"` + +for n in "$@" +do + MD5=`echo -n $n | md5sum | cut -d " " -f 1` + if [ -f "onyx/cache/$MD5.cache.php" ] + then + rm -f "onyx/cache/$MD5.cache.php" + echo "--- $n deleted" + else + echo "/!\\ $n not found ($MD5)" + fi +done diff --git a/gen_site.sh b/gen_site.sh index 974eeb67..4667aea2 100755 --- a/gen_site.sh +++ b/gen_site.sh @@ -4,7 +4,7 @@ BASEURL="localhost" SALT_TEAM="connected" OUT_TEAM="./teams" -MAX_PARAL=9 +MAX_PARAL=10 DEBUG=0 @@ -34,8 +34,13 @@ then WGET_OPT="-q" fi +./clear_cache.sh top + mkdir -p out -cd out + +ORIG_DIR=`pwd` +MYTMPDIR=`mktemp -d` +cd "$MYTMPDIR" # First, remove existing version if any rm -rf "$BASEURL" "$OUT_TEAM" @@ -43,15 +48,38 @@ rm -rf "$BASEURL" "$OUT_TEAM" wget $WGET_OPT -m -b "http://$BASEURL/" -o /dev/null mkdir -p "$BASEURL" -ln -sf "`pwd`/../files/" "$BASEURL/files" +ln -sf "$ORIG_DIR/files/" "$BASEURL/files" + +# Get list of teams +TEAMS= +if [ $# -gt 0 ] +then + while [ $# -gt 0 ] + do + TEAMS="$TEAMS /$SALT_TEAM/$1/" + shift + done + FULLSYNC=0 +else + for l in $(curl -k "http://$BASEURL/$SALT_TEAM/" 2> /dev/null | grep -oE "/[^/]+/[0-9]+/") + do + TEAMS="$TEAMS $l" + done + FULLSYNC=1 +fi + +echo "Team list to generate: $TEAMS" NB=0 PIDLIST= -# Get list of teams and fetch them in parallel -for l in $(curl -k "http://$BASEURL/$SALT_TEAM/" 2> /dev/null | grep -oE "/[^/]+/[0-9]+/") +# Fetch them in parallel +for l in $TEAMS do ( - wget $WGET_OPT -m "http://$BASEURL/$l" + if ! wget $WGET_OPT -m "http://$BASEURL/$l" + then + exit 1 + fi for m in $(grep -R "