summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authortv <tv@also>2011-07-24 20:15:22 +0200
committertv <tv@also>2011-07-24 20:16:06 +0200
commit367eaf05de54be22de75793f0b1a49fa0ad45e24 (patch)
treea863372c23c060f0609e0e8968c8052c3b07c1b6 /util
parent5b5b3937d8e9e3615bd535fc9d436ade2fda0de4 (diff)
rm kvutils and move anonbox.net to proper place
Diffstat (limited to 'util')
-rwxr-xr-xutil/bin/anonbox.net57
1 files changed, 57 insertions, 0 deletions
diff --git a/util/bin/anonbox.net b/util/bin/anonbox.net
new file mode 100755
index 00000000..d038cd0a
--- /dev/null
+++ b/util/bin/anonbox.net
@@ -0,0 +1,57 @@
+#! /bin/bash
+#### anonbox.net [--check]
+#### anonbox account creator
+set -euf
+
+##
+script_begin_date="`date --rfc-3339=ns`"
+
+##
+GET() {
+ wget --quiet --no-check-certificate -O- https://anonbox.net/en/
+}
+
+## retrieve data
+eval "$(${GET-GET} |
+ sed -rn '
+s^<dd><p>([[:alnum:]@.]+)</p></dd>$\
+ email="\1" ; p
+s^<dd><p><a href="([^"\\]+)">.*</a></p></dd>$\
+ uri="\1/" ; p
+s^<dd><p>([0-9]+)/([0-9]+)/([0-9]+) ([0-9]+):([0-9]+) ([ap]).m.</p></dd>$\
+ Y=20\3 ; \
+ m=\1 ; \
+ d=\2 ; \
+ H=\4 ; \
+ M=\5 ; \
+ p=\6 ; p')"
+
+## make best-before-date RFC-3339-(seconds)-conform
+case "$p" in
+ p) H="`echo $H+12 | bc`" ;;
+esac
+s=00
+z=+02:00
+best_before="$Y-$m-$d $H:$M$z"
+
+##
+script_end_date="`date --rfc-3339=ns`"
+
+##
+for key in email uri best_before script_begin_date script_end_date ; do
+ eval "val=\"\$$key\""
+ echo "$key=\"$val\""
+done
+
+##
+if echo "$*" | tr "$IFS" ' ' | egrep -q "(^| )--check( |$)"; then
+ file="/tmp/save-$email"
+ echo "file=\"$file\""
+ echo >&2
+ echo "# downloading email..." >&2
+ while ! curl -ksS "$uri" | tee "$file" | grep .; do
+ sleep 10
+ done
+fi
+
+#### end of file.