init can be "non-interactive"
This commit is contained in:
parent
6cc29fb1f8
commit
10edbb19fa
22
shellpki
22
shellpki
|
@ -171,7 +171,7 @@ init() {
|
||||||
# Parse options
|
# Parse options
|
||||||
# based on https://gist.github.com/deshion/10d3cb5f88a21671e17a
|
# based on https://gist.github.com/deshion/10d3cb5f88a21671e17a
|
||||||
while :; do
|
while :; do
|
||||||
case $1 in
|
case ${1:-} in
|
||||||
--non-interactive)
|
--non-interactive)
|
||||||
non_interactive=1
|
non_interactive=1
|
||||||
;;
|
;;
|
||||||
|
@ -200,17 +200,27 @@ init() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "${CA_KEY}" ]; then
|
if [ -f "${CA_KEY}" ]; then
|
||||||
printf "%s already exists, do you really want to erase it ? [y/N] " "${CA_KEY}"
|
if [ "${non_interactive}" -eq 1 ]; then
|
||||||
read -r REPLY
|
error "${CA_KEY} already exists, erase it manually if you want to start over."
|
||||||
resp=$(echo "${REPLY}" | tr 'Y' 'y')
|
else
|
||||||
if [ "${resp}" = "y" ]; then
|
printf "%s already exists, do you really want to erase it ? [y/N] " "${CA_KEY}"
|
||||||
rm -f "${CA_KEY}" "${CA_CERT}"
|
read -r REPLY
|
||||||
|
resp=$(echo "${REPLY}" | tr 'Y' 'y')
|
||||||
|
if [ "${resp}" = "y" ]; then
|
||||||
|
rm -f "${CA_KEY}" "${CA_CERT}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
passout_arg=""
|
||||||
|
if [ -n "${CA_PASSWORD:-}" ]; then
|
||||||
|
passout_arg="-passout pass:${CA_PASSWORD}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -f "${CA_KEY}" ]; then
|
if [ ! -f "${CA_KEY}" ]; then
|
||||||
"${OPENSSL_BIN}" genrsa \
|
"${OPENSSL_BIN}" genrsa \
|
||||||
-out "${CA_KEY}" \
|
-out "${CA_KEY}" \
|
||||||
|
${passout_arg} \
|
||||||
-aes256 \
|
-aes256 \
|
||||||
"${CA_KEY_LENGTH}" \
|
"${CA_KEY_LENGTH}" \
|
||||||
>/dev/null 2>&1
|
>/dev/null 2>&1
|
||||||
|
|
Loading…
Reference in a new issue