summaryrefslogtreecommitdiff
path: root/receive-all-keys
blob: b4f1c0dd52fb02e5b9fff761e309dcf109d97e5e (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
#!/bin/bash

test_domain="$(dirname "$(readlink -f "$0")")/test-domain"
receive_key="$(dirname "$(readlink -f "$0")")/receive-key"

tmp_dir="$(mktemp -d)"

pushd "${tmp_dir}" > /dev/null

grep '@' ~/.thunderbird/*.default/ImapMail/imap.gmx.net/INBOX | \
  sed 's|\s\+|\n|g' | \
  tr ' \t<>();"[]~=+#:,$|&/?%{}/\\!*^`'"'" '\n' | \
  grep '^[^@]\+@[^@]\+\.[^@]\+$' | \
  pv --line-mode | \
  grep '^[_0-9a-zA-Z.-]\+@[_0-9a-zA-Z.-]\+$' > \
  adressen

sort -uf adressen | \
  tee adressen.sorted | \
  wc -l

mv adressen.sorted adressen

cut -d@ -f2 adressen | \
  sort -uf | \
  tee domains | \
  wc -l

parallel -j 100 "${test_domain}" '{}' \; < domains > domains.ok

mv domains.ok domains

(
  sed 's|$| 0|' domains
  sed 's|^\(.*\)@\(.*\)$|\2 1 \1@\2|' adressen
) | \
  sort -k1,1 -k2n,2 | \
  while read -r a b c; do
    if [ "${b}" == "0" ]; then
      domain="${a}"
      continue
    fi
    if [ "${a}" == "${domain}" ] && [ "${b}" == "1" ]; then
      echo "${c}"
    fi
  done | \
  tee adressen.ok | \
  wc -l

mv adressen.ok adressen

xargs -n1 "${receive_key}" < adressen

popd > /dev/null

rm -rf --one-file-system "${tmp_dir}"