summaryrefslogtreecommitdiffstats
path: root/util/bin/anonbox.net
blob: 7e26477d05c70e6f88d55f546284b4bdb027c71a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/sh
#### 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 -n '
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.