cleanup: Make "clean line" respect silent, batch and quiet modes

Improve two comments and information() output

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
Richard T Bonhomme 2022-08-22 22:37:27 +01:00
parent 55a213c0b4
commit e24bf0a72e
No known key found for this signature in database
GPG Key ID: 2D767DB92FB6C246

View File

@ -525,8 +525,7 @@ notice() {
print " print "
Notice Notice
------ ------
$1 $1"
"
} # => notice() } # => notice()
# Helpful information # Helpful information
@ -534,7 +533,7 @@ information() {
[ "$EASYRSA_SILENT" ] && return [ "$EASYRSA_SILENT" ] && return
[ "$EASYRSA_BATCH" ] && return [ "$EASYRSA_BATCH" ] && return
[ "$EASYRSA_QUIET" ] && return [ "$EASYRSA_QUIET" ] && return
print "* $1" print "$1"
} # => notice() } # => notice()
# yes/no case-insensitive match (operates on stdin pipe) # yes/no case-insensitive match (operates on stdin pipe)
@ -656,6 +655,13 @@ cleanup() {
*) warn "Host OS undefined." *) warn "Host OS undefined."
esac esac
if [ "$EASYRSA_SILENT" ] || [ "$EASYRSA_BATCH" ] || [ "$EASYRSA_QUIET" ]
then
: # ok
else
print # just to get a clean line
fi
# Exit with error 1, if an error ocured... # Exit with error 1, if an error ocured...
if [ "$easyrsa_error_exit" ]; then if [ "$easyrsa_error_exit" ]; then
# Set by verify_cert() for full error-out # Set by verify_cert() for full error-out
@ -665,7 +671,6 @@ cleanup() {
exit 0 exit 0
else else
# if 'cleanup' is called without 'ok' then an error occurred # if 'cleanup' is called without 'ok' then an error occurred
[ "$EASYRSA_SILENT" ] || print # just to get a clean line
exit 1 exit 1
fi fi
} # => cleanup() } # => cleanup()
@ -981,8 +986,7 @@ Your newly created PKI dir is:
: # ok - No message required : # ok - No message required
else else
information "\ information "\
IMPORTANT: Easy-RSA 'vars' file has now been moved to your PKI above. IMPORTANT: Easy-RSA 'vars' file has now been moved to your PKI above."
"
fi fi
} # => init_pki() } # => init_pki()
@ -1114,7 +1118,6 @@ install_data_to_pki () {
#[ -e "${EASYRSA_PKI}/${vars_file}" ] || return #[ -e "${EASYRSA_PKI}/${vars_file}" ] || return
#[ -e "${EASYRSA_PKI}/${vars_file_example}" ] || return #[ -e "${EASYRSA_PKI}/${vars_file_example}" ] || return
[ -e "${EASYRSA_PKI}/${ssl_cnf_file}" ] || return [ -e "${EASYRSA_PKI}/${ssl_cnf_file}" ] || return
#[ -e "${EASYRSA_PKI}/${x509_types_dir}" ] || return
# EASYRSA_EXT_DIR must be found! No exceptions! # EASYRSA_EXT_DIR must be found! No exceptions!
# The shellcheck warning 2015 is valid, however, this code works correctly. # The shellcheck warning 2015 is valid, however, this code works correctly.
@ -1123,7 +1126,7 @@ install_data_to_pki () {
[ "$EASYRSA_EXT_DIR" ] && [ -e "$EASYRSA_EXT_DIR" ] || \ [ "$EASYRSA_EXT_DIR" ] && [ -e "$EASYRSA_EXT_DIR" ] || \
die "x509-types folder cannot be found: $EASYRSA_EXT_DIR" die "x509-types folder cannot be found: $EASYRSA_EXT_DIR"
# Complete or error # Create a safe ssl file, Complete or error
require_safe_ssl_conf=1 # Always required require_safe_ssl_conf=1 # Always required
[ -e "$EASYRSA_SAFE_CONF" ] || easyrsa_openssl makesafeconf || return [ -e "$EASYRSA_SAFE_CONF" ] || easyrsa_openssl makesafeconf || return