Merge branch 'TinCanTech-renew-cleanup'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
commit
3cd149275d
@ -638,6 +638,11 @@ cleanup() {
|
|||||||
rm -rf "$EASYRSA_EC_DIR"
|
rm -rf "$EASYRSA_EC_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Restore files when renew is interrupted
|
||||||
|
if [ "$on_error_undo_renew_move" ]; then
|
||||||
|
renew_restore_move
|
||||||
|
fi
|
||||||
|
|
||||||
# shellcheck disable=SC3040 # In POSIX sh, set option [name] is undefined
|
# shellcheck disable=SC3040 # In POSIX sh, set option [name] is undefined
|
||||||
case "$easyrsa_host_os" in
|
case "$easyrsa_host_os" in
|
||||||
nix) [ -t 1 ] && stty echo ;;
|
nix) [ -t 1 ] && stty echo ;;
|
||||||
@ -2153,10 +2158,11 @@ with the following subject:
|
|||||||
|
|
||||||
# move renewed files so we can reissue certificate with the same name
|
# move renewed files so we can reissue certificate with the same name
|
||||||
renew_move
|
renew_move
|
||||||
|
on_error_undo_renew_move=1
|
||||||
|
|
||||||
# renew certificate
|
# renew certificate
|
||||||
if build_full "$cert_type" "$file_name_base" "$opt_nopass"; then
|
if build_full "$cert_type" "$file_name_base" "$opt_nopass"; then
|
||||||
: # ok
|
unset on_error_undo_renew_move
|
||||||
else
|
else
|
||||||
# If renew failed then restore cert, key and req. Otherwise, issue a warning
|
# If renew failed then restore cert, key and req. Otherwise, issue a warning
|
||||||
# If *restore* fails then at least the file-names are not serial-numbers
|
# If *restore* fails then at least the file-names are not serial-numbers
|
||||||
@ -2176,7 +2182,7 @@ been deployed, use 'revoke-renewed $file_name_base reason' ('reason' is optional
|
|||||||
|
|
||||||
# Restore files on failure to renew
|
# Restore files on failure to renew
|
||||||
renew_restore_move() {
|
renew_restore_move() {
|
||||||
unset -v rrm_err
|
unset -v rrm_err on_error_undo_renew_move
|
||||||
# restore crt, key and req file to PKI folders
|
# restore crt, key and req file to PKI folders
|
||||||
if mv "$restore_crt_out" "$restore_crt_in"; then
|
if mv "$restore_crt_out" "$restore_crt_in"; then
|
||||||
: # ok
|
: # ok
|
||||||
@ -2209,7 +2215,7 @@ renew_restore_move() {
|
|||||||
if [ "$rrm_err" ]; then
|
if [ "$rrm_err" ]; then
|
||||||
warn "Failed to restore renewed files."
|
warn "Failed to restore renewed files."
|
||||||
else
|
else
|
||||||
notice "Renewed files have been successfully restored."
|
notice "Renew FAILED but files have been successfully restored."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user