diff --git a/images/assets/pulp-api b/images/assets/pulp-api index 9d165496..e28dfebb 100755 --- a/images/assets/pulp-api +++ b/images/assets/pulp-api @@ -4,18 +4,19 @@ mkdir -p /var/lib/pulp/media \ /var/lib/pulp/assets \ /var/lib/pulp/tmp -/usr/bin/wait_on_postgres.py - -# Get list of installed plugins via pip -# Assumes they are all named like "pulp-file" -> "file", with no 2nd dash. -# (Was previously needed when we ran `pulpcore-manager makemigrations`) -# PLUGINS=$(pip list | awk -F '[[:space:]]+|[-]' '/pulp-/{printf $2 " " }') - -/usr/local/bin/pulpcore-manager migrate --noinput - -set +x +if [ "${SKIP_MIGRATIONS}" = false ]; then + /usr/bin/wait_on_postgres.py + + # Get list of installed plugins via pip + # Assumes they are all named like "pulp-file" -> "file", with no 2nd dash. + # (Was previously needed when we ran `pulpcore-manager makemigrations`) + # PLUGINS=$(pip list | awk -F '[[:space:]]+|[-]' '/pulp-/{printf $2 " " }') + + /usr/local/bin/pulpcore-manager migrate --noinput +fi if [ -n "${PULP_SIGNING_KEY_FINGERPRINT}" ]; then + echo "Configuring the signing service..." /usr/local/bin/pulpcore-manager add-signing-service "${COLLECTION_SIGNING_SERVICE}" /var/lib/pulp/scripts/collection_sign.sh "${PULP_SIGNING_KEY_FINGERPRINT}" /usr/local/bin/pulpcore-manager add-signing-service "${CONTAINER_SIGNING_SERVICE}" /var/lib/pulp/scripts/container_sign.sh "${PULP_SIGNING_KEY_FINGERPRINT}" --class container:ManifestSigningService fi diff --git a/images/assets/pulp-common-entrypoint.sh b/images/assets/pulp-common-entrypoint.sh index 7acedda3..5fb195ba 100755 --- a/images/assets/pulp-common-entrypoint.sh +++ b/images/assets/pulp-common-entrypoint.sh @@ -5,10 +5,55 @@ # # We still want conatiner users to call pulp-* command names, not paths, so we # can change our scripts' locations in the future, and call special logic in this -# script based solely on theo command name. +# script based solely on the command name. -if [[ "$@" = "pulp-content" || "$@" = "pulp-api" || "$@" = "pulp-worker" || "$@" = "pulp-resource-manager" ]]; then - exec "/usr/bin/$@" +# Default value for the migration flag +skip_migrations=false + +# Define the usage function +usage() { + echo "Usage: [pulp-api|pulp-content|pulp-worker|any command] [-s|--skip-migrations]" + exit 1 +} + +# Parse command line options using getopt +OPTS=$(getopt -o s --long skip-migrations -n 'pulp-common-entrypoint.sh' -- "$@") + +if [ $? != 0 ]; then + usage +fi + +eval set -- "$OPTS" + +# Process command line options +while true; do + case "$1" in + -s|--skip-migrations) + skip_migrations=true + shift + ;; + --) + shift + break + ;; + *) + usage + ;; + esac +done + +# Get the command argument +command="$1" + +# Check if the skip_migrations flag is set +# Check if a command was provided +if [[ -n "$command" && "$command" = "pulp-content" || "$command" = "pulp-api" || "$command" = "pulp-worker" ]]; then + + if [ "$skip_migrations" = true ]; then + echo "Skipping migrations..." + fi + + SKIP_MIGRATIONS=skip_migrations exec "/usr/bin/$command" else - exec "$@" + exec "$command" fi diff --git a/images/assets/pulp-content b/images/assets/pulp-content index 12550287..ad837d32 100755 --- a/images/assets/pulp-content +++ b/images/assets/pulp-content @@ -1,7 +1,8 @@ #!/bin/bash -x - -/usr/bin/wait_on_postgres.py -/usr/bin/wait_on_database_migrations.sh +if [ "${SKIP_MIGRATIONS}" = false ]; then + /usr/bin/wait_on_postgres.py + /usr/bin/wait_on_database_migrations.sh +fi if which pulpcore-content then diff --git a/images/assets/pulp-worker b/images/assets/pulp-worker index 886baa30..e94fc62e 100755 --- a/images/assets/pulp-worker +++ b/images/assets/pulp-worker @@ -1,7 +1,9 @@ #!/bin/bash -x -/usr/bin/wait_on_postgres.py -/usr/bin/wait_on_database_migrations.sh +if [ "${SKIP_MIGRATIONS}" = false ]; then + /usr/bin/wait_on_postgres.py + /usr/bin/wait_on_database_migrations.sh +fi export PULP_SETTINGS=/etc/pulp/settings.py export PATH=/usr/local/bin:/usr/bin/