From e42af2183cbd9d4e5b11966d062eec0cd3ef28e6 Mon Sep 17 00:00:00 2001 From: Jeremy Dubois Date: Tue, 29 Mar 2022 18:18:01 +0200 Subject: [PATCH] Fix --non-interactive behavior: there were still some prompts to the user --- shellpki | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/shellpki b/shellpki index e3d66f5..e8aae25 100755 --- a/shellpki +++ b/shellpki @@ -239,6 +239,8 @@ init() { passout_arg="" if [ -n "${CA_PASSWORD:-}" ]; then passout_arg="-passout pass:${CA_PASSWORD}" + elif [ "${non_interactive}" -eq 1 ]; then + error "In non-interactive mode, you must pass CA_PASSWORD as environment variable." fi if [ ! -f "${CA_KEY}" ]; then @@ -255,11 +257,15 @@ init() { fi if [ -f "${CA_CERT}" ]; then - printf "%s already exists, do you really want to erase it ? [y/N] " "${CA_CERT}" - read -r REPLY - resp=$(echo "${REPLY}" | tr 'Y' 'y') - if [ "${resp}" = "y" ]; then - rm "${CA_CERT}" + if [ "${non_interactive}" -eq 1 ]; then + error "${CA_CERT} already exists, erase it manually if you want to start over." + else + printf "%s already exists, do you really want to erase it ? [y/N] " "${CA_CERT}" + read -r REPLY + resp=$(echo "${REPLY}" | tr 'Y' 'y') + if [ "${resp}" = "y" ]; then + rm "${CA_CERT}" + fi fi fi