From c7617ec6c603195a4b5da45145caec0bf6558d97 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 7 Aug 2024 12:31:06 +0200 Subject: [PATCH] simplify enumeration loops for dns & ca --- spcd.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/spcd.sh b/spcd.sh index 68ed45e..457f63e 100644 --- a/spcd.sh +++ b/spcd.sh @@ -528,14 +528,13 @@ spcd_set_https_verification_off() { spcd_set_dns_resolving() { spcd_step "Set DNS resolving" - spcd_sdr__index=1 - eval "spcd_sdr__value=\"\${SPCD_DNS_${spcd_sdr__index}}\"" - while [ -n "${spcd_sdr__value}" ]; do + while true; do + spcd_sdr__index=$((spcd_sdr__index + 1)) + eval "spcd_sdr__value=\"\${SPCD_DNS_${spcd_sdr__index}}\"" + [ -n "${spcd_sdr__value}" ] || break spcd_sdr__text="${spcd_sdr__text}\ nameserver ${spcd_sdr__value} " - spcd_sdr__index=$((spcd_sdr__index + 1)) - eval "spcd_sdr__value=\"\${SPCD_DNS_${spcd_sdr__index}}\"" done spcd_write "${SPCD_DNS_FILE}" "${spcd_sdr__text}" } @@ -558,15 +557,14 @@ spcd_install_ca_certificates() { spcd_write_ca_certificates() { spcd_step "Write CA certificates" spcd_mkdir "${SPCD_CA_ROOT}" - spcd_wcc__index=1 - eval "spcd_wcc__text=\"\${SPCD_CA_${spcd_wcc__index}}\"" - while [ -n "${spcd_wcc__text}" ]; do + while true; do + spcd_wcc__index=$((spcd_wcc__index + 1)) + eval "spcd_wcc__text=\"\${SPCD_CA_${spcd_wcc__index}}\"" + [ -n "${spcd_wcc__text}" ] || break spcd_wcc__path="${SPCD_CA_ROOT}/${spcd_wcc__index}.crt" spcd_split spcd_write "${spcd_wcc__path}" "${spcd_wcc__text}" spcd_openssl "${spcd_wcc__path}" - spcd_wcc__index=$((spcd_wcc__index + 1)) - eval "spcd_wcc__text=\"\${SPCD_CA_${spcd_wcc__index}}\"" done }