Skip to content

Commit 0370fe1

Browse files
author
Sengorius
committed
allowed to copy soft-linked certs correctly into a Docker container
1 parent ac1181a commit 0370fe1

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/cert-copy.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ function copy_certs_to_container() {
4848
;;
4949
esac
5050

51-
# collect .crt files from directory
52-
mapfile -t CERT_FILES < <(find "$CERTS_PATH" -maxdepth 1 -type f -name "*.crt")
51+
# collect .crt files from directory (including symlinks pointing to valid files, e.g. from Let's Encrypt companion)
52+
mapfile -t CERT_FILES < <(find -L "$CERTS_PATH" -maxdepth 1 -type f -name "*.crt")
5353

5454
if [[ ${#CERT_FILES[@]} -eq 0 ]]; then
55-
print_error "Keine .crt-Dateien gefunden in: ${CERT_SOURCE_DIR}" 1
55+
print_error "No .crt files located in: ${CERT_SOURCE_DIR}" 1
5656
return
5757
fi
5858

@@ -61,7 +61,8 @@ function copy_certs_to_container() {
6161

6262
for cert in "${CERT_FILES[@]}"; do
6363
filename="$(basename "${cert}")"
64-
docker cp "$cert" "$CONTAINER:$CERT_TARGET_DIR/$filename" > /dev/null
64+
real_cert="$(readlink -f "${cert}")"
65+
docker cp "$real_cert" "$CONTAINER:$CERT_TARGET_DIR/$filename" > /dev/null
6566
docker exec --user root "$CONTAINER" sh -c "chmod 644 '$CERT_TARGET_DIR/$filename'"
6667
done
6768

0 commit comments

Comments
 (0)