From 03bc710cdb225694b34b3aefedd6098d28920680 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 9 Feb 2025 10:59:22 +0100 Subject: Add script for adding new keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- new | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 new 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 -- cgit v1.2.3-70-g09d2