summaryrefslogtreecommitdiff
path: root/files/reprepro-export-key.sh
blob: 6e0b278423fae75b693e2f52d84484286d804a75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
#
# This file is managed by Puppet. Do not edit, any changes will be overwritten!
#

set -e

BASEDIR="$1"
KEY=$(gpg --homedir "$BASEDIR/.gnupg" --with-colon --list-secret-keys | cut -d : -f 5 | head -n 1)

if [ -n "$KEY" ]; then
	TEMPFILE=$(mktemp --tmpdir="$BASEDIR")
	trap "rm -f '$TEMPFILE'" EXIT
	DESTFILE="$BASEDIR/key.asc"
	gpg --homedir "$BASEDIR/.gnupg" --export --armor "$KEY" > "$TEMPFILE"
	mv "$TEMPFILE" "$DESTFILE"
	chown reprepro:reprepro "$DESTFILE"
	chmod 0664 "$DESTFILE"
fi