From b53add279853b934335438d65e2bb2443064c749 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 3 Jul 2021 00:46:31 +0100 Subject: [PATCH] Make output from setup scripts a little bit less noisy --- setup/management.sh | 2 +- setup/pgp.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/setup/management.sh b/setup/management.sh index 2600a16..c5bbf92 100755 --- a/setup/management.sh +++ b/setup/management.sh @@ -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 diff --git a/setup/pgp.sh b/setup/pgp.sh index 92a0084..3f00909 100755 --- a/setup/pgp.sh +++ b/setup/pgp.sh @@ -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