2016-09-19 21:55:08 +00:00
|
|
|
#! /bin/bash
|
|
|
|
set -e
|
2017-02-01 23:17:25 +00:00
|
|
|
QUAYPATH=${QUAYPATH:-"."}
|
2018-08-23 17:33:57 +00:00
|
|
|
QUAYCONF=${QUAYCONF:-"$QUAYPATH/conf"}
|
2018-07-18 18:21:25 +00:00
|
|
|
QUAYCONFIG=${QUAYCONFIG:-"$QUAYCONF/stack"}
|
2018-08-23 17:33:57 +00:00
|
|
|
CERTDIR=${CERTDIR:-"$QUAYCONFIG/extra_ca_certs"}
|
2018-08-16 19:42:01 +00:00
|
|
|
|
|
|
|
# If we're running under kube, the previous script (02_get_kube_certs.sh) will put the certs in a different location
|
|
|
|
if [[ "$KUBERNETES_SERVICE_HOST" != "" ]];then
|
|
|
|
CERTDIR=${KUBE_EXTRA_CA_CERTDIR:-"$QUAYPATH/conf/kube_extra_certs"}
|
|
|
|
fi
|
2017-02-01 23:17:25 +00:00
|
|
|
|
2018-07-11 20:03:36 +00:00
|
|
|
cd ${QUAYDIR:-"/quay-registry"}
|
2016-09-19 21:55:08 +00:00
|
|
|
|
|
|
|
# Add the custom LDAP certificate
|
2018-07-18 18:01:07 +00:00
|
|
|
if [ -e $QUAYCONFIG/ldap.crt ]
|
2016-09-19 21:55:08 +00:00
|
|
|
then
|
2018-07-18 18:01:07 +00:00
|
|
|
cp $QUAYCONFIG/ldap.crt /usr/local/share/ca-certificates/ldap.crt
|
2016-09-19 21:55:08 +00:00
|
|
|
fi
|
|
|
|
|
2016-11-30 19:04:26 +00:00
|
|
|
# Add extra trusted certificates (as a directory)
|
2018-08-16 19:42:01 +00:00
|
|
|
if [ -d $CERTDIR ]; then
|
|
|
|
if test "$(ls -A "$CERTDIR")"; then
|
|
|
|
echo "Installing extra certificates found in $CERTDIR directory"
|
|
|
|
cp $CERTDIR/* /usr/local/share/ca-certificates/
|
|
|
|
cat $CERTDIR/* >> venv/lib/python2.7/site-packages/requests/cacert.pem
|
|
|
|
cat $CERTDIR/* >> venv/lib/python2.7/site-packages/certifi/cacert.pem
|
2017-01-26 20:17:18 +00:00
|
|
|
fi
|
2016-09-19 21:55:08 +00:00
|
|
|
fi
|
|
|
|
|
2016-11-30 19:04:26 +00:00
|
|
|
# Add extra trusted certificates (as a file)
|
2018-08-16 19:42:01 +00:00
|
|
|
if [ -f $CERTDIR ]; then
|
|
|
|
echo "Installing extra certificates found in $CERTDIR file"
|
|
|
|
csplit -z -f /usr/local/share/ca-certificates/extra-ca- $CERTDIR '/-----BEGIN CERTIFICATE-----/' '{*}'
|
|
|
|
cat $CERTDIR >> venv/lib/python2.7/site-packages/requests/cacert.pem
|
|
|
|
cat $CERTDIR >> venv/lib/python2.7/site-packages/certifi/cacert.pem
|
2016-11-30 19:04:26 +00:00
|
|
|
fi
|
|
|
|
|
2017-05-25 21:50:25 +00:00
|
|
|
# Add extra trusted certificates (prefixed)
|
2018-08-23 17:33:57 +00:00
|
|
|
for f in $(find $QUAYCONFIG/ -maxdepth 1 -type f -name "extra_ca*")
|
2017-05-23 17:59:09 +00:00
|
|
|
do
|
|
|
|
echo "Installing extra cert $f"
|
2017-05-23 19:43:21 +00:00
|
|
|
cp "$f" /usr/local/share/ca-certificates/
|
2017-02-01 23:17:25 +00:00
|
|
|
cat "$f" >> venv/lib/python2.7/site-packages/requests/cacert.pem
|
2017-12-15 22:26:44 +00:00
|
|
|
cat "$f" >> venv/lib/python2.7/site-packages/certifi/cacert.pem
|
2017-05-23 17:59:09 +00:00
|
|
|
done
|
|
|
|
|
2016-11-30 19:04:26 +00:00
|
|
|
# Update all CA certificates.
|
2016-09-19 21:55:08 +00:00
|
|
|
update-ca-certificates
|