Skip to content

Commit 8bc5177

Browse files
committed
Do not rm -rf with a trailing empty var
1 parent cb40686 commit 8bc5177

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/letsencrypt_service

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ update_certs() {
8383
acme_ca_uri="https://acme-staging.api.letsencrypt.org/directory"
8484
if [[ ! -f /etc/nginx/certs/.${base_domain}.test ]]; then
8585
# Remove old certificates
86-
rm -rf /etc/nginx/certs/${base_domain}
86+
[[ -n "${base_domain// }" ]] && rm -rf /etc/nginx/certs/${base_domain}
8787
for domain in "${!hosts_array}"; do
8888
rm -f /etc/nginx/certs/$domain.{crt,key,dhparam.pem}
8989
done
@@ -93,7 +93,7 @@ update_certs() {
9393
acme_ca_uri="$ACME_CA_URI"
9494
if [[ -f /etc/nginx/certs/.${base_domain}.test ]]; then
9595
# Remove old test certificates
96-
rm -rf /etc/nginx/certs/${base_domain}
96+
[[ -n "${base_domain// }" ]] && rm -rf /etc/nginx/certs/${base_domain}
9797
for domain in "${!hosts_array}"; do
9898
rm -f /etc/nginx/certs/$domain.{crt,key,dhparam.pem}
9999
done
@@ -127,7 +127,7 @@ update_certs() {
127127

128128
for altnames in "${hosts_array_expanded[@]:1}"; do
129129
# Remove old CN domain that now are altnames
130-
rm -rf /etc/nginx/certs/$altnames
130+
[[ -n "${altnames// }" ]] && rm -rf /etc/nginx/certs/${altnames}
131131
done
132132

133133
for domain in "${!hosts_array}"; do

0 commit comments

Comments
 (0)