2017-07-24 12:21:38 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-04-08 17:43:45 +02:00
|
|
|
# The directory /var/lib/registry is within the container, and used to store image in CI testing.
|
|
|
|
# So for now we need to chown to it to avoid failure in CI.
|
2017-11-02 04:51:32 +01:00
|
|
|
if [ -d /var/lib/registry ]; then
|
|
|
|
chown 10000:10000 -R /var/lib/registry
|
2018-03-23 10:57:26 +01:00
|
|
|
fi
|
2018-04-08 17:43:45 +02:00
|
|
|
|
2017-11-02 04:51:32 +01:00
|
|
|
if [ -d /storage ]; then
|
2018-03-23 10:57:26 +01:00
|
|
|
if ! stat -c '%u:%g' /storage | grep -q '10000:10000' ; then
|
|
|
|
# 10000 is the id of harbor user/group.
|
|
|
|
# Usually NFS Server does not allow changing owner of the export directory,
|
|
|
|
# so need to skip this step and requires NFS Server admin to set its owner to 10000.
|
|
|
|
chown 10000:10000 -R /storage
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-08-16 11:13:44 +02:00
|
|
|
if [ ! -f /etc/pki/tls/certs/ca-bundle.crt.original ]; then
|
|
|
|
cp /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.original
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /etc/registry/custom-ca-bundle.crt ]; then
|
|
|
|
if grep -q "Photon" /etc/lsb-release; then
|
|
|
|
echo "Appending custom ca bundle ..."
|
|
|
|
cp /etc/pki/tls/certs/ca-bundle.crt.original /etc/pki/tls/certs/ca-bundle.crt
|
|
|
|
cat /etc/registry/custom-ca-bundle.crt >> /etc/pki/tls/certs/ca-bundle.crt
|
|
|
|
echo "Done."
|
|
|
|
else
|
|
|
|
echo "Current OS is not Photon, skip appending ca bundle"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-07-24 12:21:38 +02:00
|
|
|
case "$1" in
|
|
|
|
*.yaml|*.yml) set -- registry serve "$@" ;;
|
|
|
|
serve|garbage-collect|help|-*) set -- registry "$@" ;;
|
|
|
|
esac
|
|
|
|
|
2017-11-02 04:51:32 +01:00
|
|
|
sudo -E -u \#10000 "$@"
|