aboutsummaryrefslogtreecommitdiffstats
path: root/new
blob: 19a284f68c664a89b8c054b8776e77e7ebc5c44f (plain) (blame)
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
#!/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