Make output from setup scripts a little bit less noisy

This commit is contained in:
David 2021-07-03 00:46:31 +01:00
parent e1aabc4504
commit b53add2798
No known key found for this signature in database
GPG key ID: 913FE0F2477D7D6B
2 changed files with 7 additions and 7 deletions

View file

@ -156,5 +156,5 @@ if [[ -f mailinabox-ca.crt ]]; then
echo "Custom CA certificate detected. Installing..."
rm -f /usr/local/share/ca-certificates/mailinabox-ca.crt
cp mailinabox-ca.crt /usr/local/share/ca-certificates/
update-ca-certificates --fresh
hide_output update-ca-certificates --fresh
fi

View file

@ -15,7 +15,7 @@ apt_install gnupg
function gpg_keygen {
# Generates a private key.
gpg --generate-key --batch << EOF;
gpg --generate-key --batch 2> /tmp/gpg_keygen_log << EOF;
%no-protection
Key-Type: RSA
Key-Length: 4096
@ -31,21 +31,21 @@ EOF
# - There isn't a fingerprint on /etc/mailinabox.conf
# - The configured fingerprint doesn't actually exist
if [ "${PGPKEY-}" = "" -o "$(gpg --list-secret-keys 2> /dev/null | grep ${PGPKEY-})" = "" ]; then
if [ "${PGPKEY-}" == "" -o "$(gpg --list-secret-keys 2> /dev/null | grep ${PGPKEY-})" = "" ]; then
echo "No keypair found. Generating daemon's PGP keypair..."
FPR_TMP=$(gpg_keygen 2>&1)
gpg_keygen
if [ $? -ne 0 ]; then
echo ""
echo "Key generation failed!" 1>&2
echo "============================" 1>&2
echo $FPR_TMP 1>&2
cat /tmp/gpg_keygen_log 1>&2
echo "============================" 1>&2
exit 1
fi
FPR=$(echo $FPR_TMP | sed -r 's/.*([0-9A-F]{40}).*/\1/g')
echo "Generated key $FPR"
FPR=$(cat /tmp/gpg_keygen_log | tr -d '\n' | sed -r 's/.*([0-9A-F]{40}).*/\1/g')
echo "Generated key with fingerprint $FPR"
chown -R root:root $GNUPGHOME
# Remove the old key fingerprint from the configuration if it exists, and add the new one