Skip to content

Commit

Permalink
init: ensure a newline is present before appending certs (PROJQUAY-3881
Browse files Browse the repository at this point in the history
…) (#1352)
  • Loading branch information
kleesc authored May 31, 2022
1 parent f90e5e3 commit 16d9a2c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions conf/init/certs_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ PYTHONUSERBASE_SITE_PACKAGE=${PYTHONUSERBASE_SITE_PACKAGE:-"$(python -m site --u

cd ${QUAYDIR:-"/quay-registry"}

function ensure_newline() {
lastline=$(tail -c 1 $1)
if [ "$lastline" != "" ]; then
echo >> "$1"
fi
}

# Add the custom LDAP certificate
if [ -e $QUAYCONFIG/ldap.crt ]
then
Expand All @@ -20,6 +27,13 @@ if [ -d $CERTDIR ]; then
if test "$(ls -A "$CERTDIR")"; then
echo "Installing extra certificates found in $CERTDIR directory"
cp $CERTDIR/* ${SYSTEM_CERTDIR}

CERT_FILES="$CERTDIR/*"
for f in $CERT_FILES
do
ensure_newline "$f"
done

cat $CERTDIR/* >> $PYTHONUSERBASE_SITE_PACKAGE/certifi/cacert.pem
fi
fi
Expand All @@ -28,6 +42,7 @@ fi
if [ -f $CERTDIR ]; then
echo "Installing extra certificates found in $CERTDIR file"
csplit -z -f ${SYSTEM_CERTDIR}/extra-ca- $CERTDIR '/-----BEGIN CERTIFICATE-----/' '{*}'
ensure_newline "$CERTDIR"
cat $CERTDIR >> $PYTHONUSERBASE_SITE_PACKAGE/certifi/cacert.pem
fi

Expand All @@ -36,6 +51,7 @@ for f in $(find -L $QUAYCONFIG/ -maxdepth 1 -type f -name "extra_ca*")
do
echo "Installing extra cert $f"
cp "$f" ${SYSTEM_CERTDIR}
ensure_newline "$f"
cat "$f" >> $PYTHONUSERBASE_SITE_PACKAGE/certifi/cacert.pem
done

Expand Down

0 comments on commit 16d9a2c

Please sign in to comment.