forked from quay/quay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quay-entrypoint.sh
executable file
·137 lines (127 loc) · 4.79 KB
/
quay-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/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"}
export CONFIG_APP_PASSWORD=${CONFIG_APP_PASSWORD:-"\"\""}
export OPERATOR_ENDPOINT=${OPERATOR_ENDPOINT:-"\"\""}
export QUAY_CONFIG_READ_ONLY_FIELD_GROUPS=${QUAY_CONFIG_READ_ONLY_FIELD_GROUPS:-"\"\""}
case "$QUAYENTRY" in
"shell")
echo "Entering shell mode"
exec /bin/bash
;;
"config")
echo ""; echo "Startup timestamp: "; date; echo ""
if [ -z "${QUAY_SERVICES}" ]; then
echo "Running all default config services"
else
echo "Running services ${QUAY_SERVICES}"
fi
if [ $CONFIG_APP_PASSWORD = "\"\"" ]; then
CONFIG_APP_PASSWORD=$2
fi
: "${CONFIG_APP_PASSWORD:?Missing password argument for configuration tool}"
export CONFIG_APP_PASSWORD="${CONFIG_APP_PASSWORD}"
if [ $OPERATOR_ENDPOINT = "\"\"" ]; then
if [ -n "$3" ]; then
OPERATOR_ENDPOINT=$3
fi
fi
export OPERATOR_ENDPOINT="${OPERATOR_ENDPOINT}"
"${QUAYPATH}/conf/init/certs_install.sh" || exit
"${QUAYPATH}/conf/init/client_certs.sh" || exit
"${QUAYPATH}/conf/init/supervisord_conf_create.sh" config || exit
exec supervisord -c "${QUAYCONF}/supervisord.conf" 2>&1
;;
"migrate")
echo ""; echo "Startup timestamp: "; date; echo ""
: "${MIGRATION_VERSION:=$2}"
: "${MIGRATION_VERSION:?Missing version argument}"
"${QUAYPATH}/conf/init/client_certs.sh" || exit
echo "Entering migration mode to version: ${MIGRATION_VERSION}"
PYTHONPATH="${QUAYPATH}" alembic upgrade "${MIGRATION_VERSION}"
;;
"registry-nomigrate")
echo ""; echo "Startup timestamp: "; date; echo ""
echo "Running all default registry services without migration"
for f in "${QUAYCONF}"/init/*.sh; do
if [ "$f" != "/quay-registry/conf/init/runmigration.sh" ]; then
echo "Running init script '$f'"
ENSURE_NO_MIGRATION=true "$f" || exit
fi
done
exec supervisord -c "${QUAYCONF}/supervisord.conf" 2>&1
;;
"registry")
echo ""; echo "Startup timestamp: "; date; echo ""
if [ -z "${QUAY_SERVICES}" ]; then
echo "Running all default registry services"
else
echo "Running services ${QUAY_SERVICES}"
fi
for f in "${QUAYCONF}"/init/*.sh; do
echo "Running init script '$f'"
"$f" || exit
done
exec supervisord -c "${QUAYCONF}/supervisord.conf" 2>&1
;;
"repomirror-nomigrate")
echo ""; echo "Startup timestamp: "; date; echo ""
echo "Entering repository mirroring mode"
export QUAY_SERVICES="${QUAY_SERVICES}${QUAY_SERVICES:+,}repomirrorworker,pushgateway"
echo "Running services ${QUAY_SERVICES}"
for f in "${QUAYCONF}"/init/*.sh; do
if [ "$f" != "/quay-registry/conf/init/runmigration.sh" ]; then
echo "Running init script '$f'"
ENSURE_NO_MIGRATION=true "$f" || exit
fi
done
exec supervisord -c "${QUAYCONF}/supervisord.conf" 2>&1
;;
"repomirror")
echo ""; echo "Startup timestamp: "; date; echo ""
echo "Entering repository mirroring mode"
export QUAY_SERVICES="${QUAY_SERVICES}${QUAY_SERVICES:+,}repomirrorworker,pushgateway"
echo "Running services ${QUAY_SERVICES}"
for f in "${QUAYCONF}"/init/*.sh; do
echo "Running init script '$f'"
"$f" || exit
done
exec supervisord -c "${QUAYCONF}/supervisord.conf" 2>&1
;;
*)
echo "Running '$QUAYENTRY'"
eval exec "$@"
;;
esac