summaryrefslogtreecommitdiff
path: root/submit_to_web_batch
diff options
context:
space:
mode:
Diffstat (limited to 'submit_to_web_batch')
-rwxr-xr-xsubmit_to_web_batch47
1 files changed, 47 insertions, 0 deletions
diff --git a/submit_to_web_batch b/submit_to_web_batch
index 09a9a6a..b6775f6 100755
--- a/submit_to_web_batch
+++ b/submit_to_web_batch
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+USER="$1"
+[ -z "$USER" ] && echo "Provide a user as the first arg" && exit 1
+[ -z "$HOST" ] && HOST="$(hostname -s)"
+[ "$HOST" == "localhost" ] && HOST="$(hostname)"
+
+CURL="`which curl`"
+[ ! -x "$CURL" ] && echo "No curl, please install" && exit 1
+
+RETRY_LOG=back.log
+
+trap clear_backlog INT TERM
+clear_backlog() {
+ # The fun stuff goes here
+ trap - INT TERM
+ submit
+}
+
+submit() {
+ echo "Buffer $buf"
+ curl --max-time 5 --retry 10 --retry-delay 2 -F user="$USER" -F host="$HOST" \
+ -F input_batch="$buf" "http://timhatch.com/projects/md5game/?a=submit&api=1"
+ if [ $? -ne 0 ]; then
+ echo "$buf" >> "$RETRY_LOG"
+ fi
+ buf=''
+ i=0
+}
+
+i=0
+buf=''
+while read f; do
+ echo "$f" | grep -q 'Benchmark\|Starting\|0x\|rough';
+ if [ $? -eq 0 ]; then echo "> $f"; continue; fi;
+ f="$(echo "$f" | sed -e 's/ .*//')"
+ echo "$f queued"
+ buf="$buf
+$f"
+ i=$(($i+1))
+ if [ $i -gt 10 ]; then
+ echo "Submitting..."
+ submit
+ fi
+done
+
+clear_backlog