Added soft-reset option for init-pki subcommand.
This commit is contained in:
parent
9bd3241a31
commit
48c2df5d11
@ -26,7 +26,7 @@ For a listing of options that can be supplied before the command, use:
|
|||||||
Here is the list of commands available with a short syntax reminder. Use the
|
Here is the list of commands available with a short syntax reminder. Use the
|
||||||
'help' command above to get full usage details.
|
'help' command above to get full usage details.
|
||||||
|
|
||||||
init-pki
|
init-pki [ cmd-opts ]
|
||||||
build-ca [ cmd-opts ]
|
build-ca [ cmd-opts ]
|
||||||
gen-dh
|
gen-dh
|
||||||
gen-req <filename_base> [ cmd-opts ]
|
gen-req <filename_base> [ cmd-opts ]
|
||||||
@ -64,7 +64,10 @@ cmd_help() {
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
init-pki|clean-all) text="
|
init-pki|clean-all) text="
|
||||||
init-pki [ cmd-opts ]
|
init-pki [ cmd-opts ]
|
||||||
Removes & re-initializes the PKI dir for a clean PKI" ;;
|
Removes & re-initializes the PKI dir for a clean PKI"
|
||||||
|
opts="
|
||||||
|
hard-reset - Recursively deletes the PKI directory if it exists.
|
||||||
|
soft-reset - Keeps the vars file and the PKI directory itself intact." ;;
|
||||||
build-ca) text="
|
build-ca) text="
|
||||||
build-ca [ cmd-opts ]
|
build-ca [ cmd-opts ]
|
||||||
Creates a new CA"
|
Creates a new CA"
|
||||||
@ -390,6 +393,16 @@ $help_note"
|
|||||||
init_pki() {
|
init_pki() {
|
||||||
vars_source_check
|
vars_source_check
|
||||||
|
|
||||||
|
reset="soft"
|
||||||
|
while [ -n "$1" ]; do
|
||||||
|
case "$1" in
|
||||||
|
hard-reset|hard) reset="hard" ;;
|
||||||
|
soft-reset|soft) reset="soft" ;;
|
||||||
|
*) warn "Ignoring unknown command option: '$1'" ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
# If EASYRSA_PKI exists, confirm before we rm -rf (skiped with EASYRSA_BATCH)
|
# If EASYRSA_PKI exists, confirm before we rm -rf (skiped with EASYRSA_BATCH)
|
||||||
if [ -e "$EASYRSA_PKI" ]; then
|
if [ -e "$EASYRSA_PKI" ]; then
|
||||||
confirm "Confirm removal: " "yes" "
|
confirm "Confirm removal: " "yes" "
|
||||||
@ -398,7 +411,20 @@ WARNING!!!
|
|||||||
You are about to remove the EASYRSA_PKI at: $EASYRSA_PKI
|
You are about to remove the EASYRSA_PKI at: $EASYRSA_PKI
|
||||||
and initialize a fresh PKI here."
|
and initialize a fresh PKI here."
|
||||||
# now remove it:
|
# now remove it:
|
||||||
rm -rf "$EASYRSA_PKI" || die "Removal of PKI dir failed. Check/correct errors above"
|
case "$reset" in
|
||||||
|
hard)
|
||||||
|
rm -rf "$EASYRSA_PKI" || die "Removal of PKI dir failed. Check/correct errors above"
|
||||||
|
;;
|
||||||
|
soft)
|
||||||
|
files="ca.crt certs_by_serial ecparams index.txt issued private reqs serial"
|
||||||
|
for i in $files; do
|
||||||
|
rm -rf "$EASYRSA_PKI/$i" || die "Removal of PKI dir failed. Check/correct errors above"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Removal of PKI dir failed. Unknown reset type."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# new dirs:
|
# new dirs:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user