This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/quay-entrypoint.sh
2019-11-12 11:09:47 -05:00

101 lines
3.1 KiB
Bash
Executable file

#!/usr/bin/env bash
QUAYENTRY=${QUAYENTRY:=$1}
QUAYENTRY=${QUAYENTRY:=registry}
if ! whoami &> /dev/null; then
if [ -w /etc/passwd ]; then
echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
fi
fi
display_usage() {
echo "Usage: ${0} <registry|config|migrate|repomirror|shell|help>"
echo
echo "If the first argument isn't one of the above modes,"
echo "the arguments will be exec'd directly, i.e.:"
echo
echo " ${0} uptime"
}
if [[ "${QUAYENTRY}" = "help" ]]
then
display_usage
exit 0
fi
cat << "EOF"
__ __
/ \ / \ ______ _ _ __ __ __
/ /\ / /\ \ / __ \ | | | | / \ \ \ / /
/ / / / \ \ | | | | | | | | / /\ \ \ /
\ \ \ \ / / | |__| | | |__| | / ____ \ | |
\ \/ \ \/ / \_ ___/ \____/ /_/ \_\ |_|
\__/ \__/ \ \__
\___\ by Red Hat
Build, Store, and Distribute your Containers
EOF
# Custom environment variables for use in conf/supervisord.conf
# The gunicorn-registry process DB_CONNECTION_POOLING must default to true
export DB_CONNECTION_POOLING_REGISTRY=${DB_CONNECTION_POOLING:-"true"}
case "$QUAYENTRY" in
"shell")
echo "Entering shell mode"
exec /usr/bin/scl enable python27 rh-nginx112 /bin/bash
;;
"config")
echo "Entering config mode, only copying config-app entrypoints"
if [ -z "$2" ]
then
if [ -z "${CONFIG_APP_PASSWORD}" ]
then
echo "Missing password for configuration tool"
exit
else
openssl passwd -apr1 "${CONFIG_APP_PASSWORD}" >> $QUAYDIR/config_app/conf/htpasswd
fi
else
openssl passwd -apr1 "$2" >> $QUAYDIR/config_app/conf/htpasswd
fi
/usr/bin/scl enable python27 rh-nginx112 "${QUAYPATH}/config_app/init/certs_create.sh"
/usr/bin/scl enable python27 rh-nginx112 "supervisord -c ${QUAYPATH}/config_app/conf/supervisord.conf 2>&1"
;;
"migrate")
echo "Entering migration mode to version: ${2}"
exec /usr/bin/scl enable python27 rh-nginx112 "PYTHONPATH=${QUAYPATH} ENCRYPTED_ROBOT_TOKEN_MIGRATION_PHASE=remove-old-fields alembic upgrade ${2}"
;;
"repomirror")
echo "Entering repository mirroring mode"
if [ -z "${QUAY_SERVICES}" ]
then
export QUAY_SERVICES=repomirrorworker,prometheus-aggregator
else
export QUAY_SERVICES=${QUAY_SERVICES},repomirrorworker,prometheus-aggregator
fi
;&
"registry")
if [ -z "${QUAY_SERVICES}" ]
then
echo "Running all default registry services"
else
echo "Running services ${QUAY_SERVICES}"
fi
for f in $(ls ${QUAYCONF}/init/*.sh); do
echo "Running init script '$f'"
/usr/bin/scl enable python27 rh-nginx112 "$f" || exit -1;
done
/usr/bin/scl enable python27 rh-nginx112 "supervisord -c ${QUAYCONF}/supervisord.conf 2>&1"
;;
*)
echo "Running '$QUAYENTRY'"
/usr/bin/scl enable python27 rh-nginx112 "$QUAYENTRY" || exit -1;
;;
esac