aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xnew44
1 files changed, 44 insertions, 0 deletions
diff --git a/new b/new
new file mode 100755
index 0000000..19a284f
--- /dev/null
+++ b/new
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+set -e
+
+usage () {
+ printf 'usage: %s full-fingerprint\n' "$0" 2>&2
+ exit 1
+}
+
+if test ! $# = 1; then
+ usage
+fi
+
+id="$(printf '%s\n' "$1" | tr a-z A-Z | tr -d ' ')"
+if test "${id::2}" = 0X; then
+ id="${id:2}"
+fi
+
+if test -n "$(printf '%s\n' "${id}" | tr -d 0-9A-F)"; then
+ usage
+fi
+
+if test "$(printf '%s' "${id}" | wc -c)" != 40; then
+ usage
+fi
+
+if test -e "by-fingerprint/${id}"; then
+ printf '%s: key already added\n' "$0" 2>&2
+ exit 1
+fi
+
+gpg --export --armour "${id}" > "by-fingerprint/${id}.pub.asc"
+
+i=1
+while test -e old-keys/maandree~$i.pub.asc; do
+ : $(( i++ ))
+done
+while (( i-- > 1 )); do
+ mv -- old-keys/maandree~$i.pub.asc old-keys/maandree~$(( i + 1 )).pub.asc
+done
+
+ln -s -- "../$(readlink -- maandree.pub.asc)" old-keys/maandree~1.pub.asc
+unlink -- maandree.pub.asc
+ln -s -- "by-fingerprint/${id}.pub.asc" maandree.pub.asc