summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-06-01 10:14:32 +0200
committerErich Eckner <git@eckner.net>2017-06-01 10:14:32 +0200
commit5daa51c16e6c17da2429e29c13e5d4eaddaf6fb6 (patch)
tree168890562a27fc81655080ab1a62ac198058d55b
downloadreceive-all-keys-5daa51c16e6c17da2429e29c13e5d4eaddaf6fb6.tar.xz
Initial commit
-rwxr-xr-xreceive-all-keys59
-rwxr-xr-xreceive-key11
-rwxr-xr-xtest-domain5
3 files changed, 75 insertions, 0 deletions
diff --git a/receive-all-keys b/receive-all-keys
new file mode 100755
index 0000000..80abb42
--- /dev/null
+++ b/receive-all-keys
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+test_domain="$(dirname "$(readlink -f "$0")")/test-domain"
+receive_key="$(dirname "$(readlink -f "$0")")/receive-key"
+
+echo "$receive_key"
+exit
+
+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}"
diff --git a/receive-key b/receive-key
new file mode 100755
index 0000000..c777bb6
--- /dev/null
+++ b/receive-key
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+keyIDs="$(
+ gpg --batch --with-colons --search-keys "$1" 2> /dev/null | \
+ grep '^pub:' | \
+ cut -d: -f2
+)"
+
+if [ -n "${keyIDs}" ]; then
+ gpg --recv-keys ${keyIDs}
+fi
diff --git a/test-domain b/test-domain
new file mode 100755
index 0000000..3ada51e
--- /dev/null
+++ b/test-domain
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+if ping -c1 "$1" &> /dev/null; then
+ echo "$1"
+fi