diff --git a/CHANGES/417.feature b/CHANGES/417.feature new file mode 100644 index 00000000..8ff26406 --- /dev/null +++ b/CHANGES/417.feature @@ -0,0 +1 @@ +Added logic for ``PULP_DEFAULT_ADMIN_PASSWORD`` to the pulp-minimal startup scripts. diff --git a/images/assets/pulp-api b/images/assets/pulp-api index 9d165496..655d4ea5 100755 --- a/images/assets/pulp-api +++ b/images/assets/pulp-api @@ -20,14 +20,23 @@ if [ -n "${PULP_SIGNING_KEY_FINGERPRINT}" ]; then /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 -ADMIN_PASSWORD_FILE=/etc/pulp/pulp-admin-password -if [[ -f "$ADMIN_PASSWORD_FILE" ]]; then - echo "pulp admin can be initialized." - PULP_ADMIN_PASSWORD=$(cat $ADMIN_PASSWORD_FILE) -fi - -if [ -n "${PULP_ADMIN_PASSWORD}" ]; then - /usr/local/bin/pulpcore-manager reset-admin-password --password "${PULP_ADMIN_PASSWORD}" +if [[ -n "$PULP_DEFAULT_ADMIN_PASSWORD" ]] +then + PASSWORD_SET=$(/usr/local/bin/pulpcore-manager shell -c "from django.contrib.auth import get_user_model; print(get_user_model().objects.filter(username=\"admin\").exists())") + if [ "$PASSWORD_SET" = "False" ] + then + /usr/local/bin/pulpcore-manager reset-admin-password --password "${PULP_DEFAULT_ADMIN_PASSWORD}" + fi +else + ADMIN_PASSWORD_FILE=/etc/pulp/pulp-admin-password + if [[ -f "$ADMIN_PASSWORD_FILE" ]]; then + echo "pulp admin can be initialized." + PULP_ADMIN_PASSWORD=$(cat $ADMIN_PASSWORD_FILE) + fi + + if [ -n "${PULP_ADMIN_PASSWORD}" ]; then + /usr/local/bin/pulpcore-manager reset-admin-password --password "${PULP_ADMIN_PASSWORD}" + fi fi set -x diff --git a/images/compose/compose.folders.yml b/images/compose/compose.folders.yml index 1530b890..4b16e8aa 100644 --- a/images/compose/compose.folders.yml +++ b/images/compose/compose.folders.yml @@ -51,7 +51,7 @@ services: - "./assets/certs:/etc/pulp/certs:z" - "../../pulp_storage:/var/lib/pulp:z" environment: - PULP_ADMIN_PASSWORD: password + PULP_DEFAULT_ADMIN_PASSWORD: password pulp_content: image: "pulp/pulp-minimal:latest" diff --git a/images/compose/compose.yml b/images/compose/compose.yml index 5b0a99d6..40c93161 100644 --- a/images/compose/compose.yml +++ b/images/compose/compose.yml @@ -59,7 +59,7 @@ services: - "./assets/certs:/etc/pulp/certs:z" - "pulp:/var/lib/pulp" environment: - PULP_ADMIN_PASSWORD: password + PULP_DEFAULT_ADMIN_PASSWORD: password restart: always pulp_content: