summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@also>2010-04-13 21:00:33 +0200
committertv <tv@also>2011-07-24 20:13:43 +0200
commitc289f95e377bb73741554074748a31b147191ce2 (patch)
treebe3229415e0d563e6a449b1b28a7233102a4df51
parent8b225805bcffc476f8c7fce4c8391e8035ee1c9c (diff)
Initial commit: anonbox, kvutils
-rwxr-xr-xanonbox/anonbox.sh45
-rwxr-xr-xkvutils/kv2csv5
-rwxr-xr-xkvutils/kv2sh3
3 files changed, 53 insertions, 0 deletions
diff --git a/anonbox/anonbox.sh b/anonbox/anonbox.sh
new file mode 100755
index 00000000..db35a5b4
--- /dev/null
+++ b/anonbox/anonbox.sh
@@ -0,0 +1,45 @@
+#! /bin/bash
+#### anonbox.net - 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
+
+#### end of file.
diff --git a/kvutils/kv2csv b/kvutils/kv2csv
new file mode 100755
index 00000000..f075229c
--- /dev/null
+++ b/kvutils/kv2csv
@@ -0,0 +1,5 @@
+#! /bin/sh
+set -euf
+kv="`cat`"
+echo "$kv" | cut -f 1 | tr '\n' , | sed 's/,$//' ; echo
+echo "$kv" | cut -f 2 | tr '\n' , | sed 's/,$//' ; echo
diff --git a/kvutils/kv2sh b/kvutils/kv2sh
new file mode 100755
index 00000000..be6fc85a
--- /dev/null
+++ b/kvutils/kv2sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+# TODO escape and ensure correct sh syntax
+sed -r 's/\t/="/;s/$/"/'