correct removal of old files with `--force`

`rm` would fail when one of the files is not present, which is quite
undesirable log (not harmful until `set -e` is introduced).
This commit is contained in:
georglauterbach 2024-02-05 11:27:08 +01:00
parent d5efaf95c3
commit a56efc9534
No known key found for this signature in database
GPG Key ID: F367F7C43C118578
1 changed files with 3 additions and 1 deletions

View File

@ -177,7 +177,9 @@ function _create_keys() {
exit 1
else
_log 'info' "Overwriting existing files as the '--force' option was supplied"
rm "${PUBLIC_KEY_FILE}" "${PUBLIC_KEY_DNS_FILE}" "${PRIVATE_KEY_FILE}"
[[ -f ${PUBLIC_KEY_FILE} ]] && rm "${PUBLIC_KEY_FILE}"
[[ -f ${PUBLIC_KEY_DNS_FILE} ]] && rm "${PUBLIC_KEY_DNS_FILE}"
[[ -f ${PRIVATE_KEY_FILE} ]] && rm "${PRIVATE_KEY_FILE}"
fi
fi