#!/bin/bash KEY="`gpg --homedir <%= basedir %>/.gnupg --with-colon --list-secret-keys | cut -d : -f 5 | head -n 1`" if [ ! -z "$KEY" ]; then tempfile=$(mktemp) gpg --homedir <%= basedir %>/.gnupg --export --armor $KEY > "$tempfile" mv "$tempfile" <%= basedir %>/key.asc chmod 0664 <%= basedir %>/key.asc fi