Fix gpg signing when sudo unavailable. (#3100)

Signed-off-by: Vyacheslav Bocharov <devel@lexina.in>
This commit is contained in:
Vyacheslav
2021-09-02 22:57:41 +03:00
committed by GitHub
parent fab9ff1dba
commit 3ab1bff470

View File

@@ -825,8 +825,13 @@ create_image()
cd ${DESTIMG}
if [[ -n $GPG_PASS ]]; then
display_alert "GPG signing" "${version}.img${compression_type}" "info"
[[ -n ${SUDO_USER} ]] && sudo chown -R ${SUDO_USER}:${SUDO_USER} "${DESTIMG}"/
echo "${GPG_PASS}" | sudo -H -u ${SUDO_USER} bash -c "gpg --passphrase-fd 0 --armor --detach-sign --pinentry-mode loopback --batch --yes ${DESTIMG}/${version}.img${compression_type}" || exit 1
if [[ -n $SUDO_USER ]]; then
sudo chown -R ${SUDO_USER}:${SUDO_USER} "${DESTIMG}"/
SUDO_PREFIX="sudo -H -u ${SUDO_USER}"
else
SUDO_PREFIX=""
fi
echo "${GPG_PASS}" | $SUDO_PREFIX bash -c "gpg --passphrase-fd 0 --armor --detach-sign --pinentry-mode loopback --batch --yes ${DESTIMG}/${version}.img${compression_type}" || exit 1
else
display_alert "GPG signing skipped - no GPG_PASS" "${version}.img" "wrn"
fi