Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting initial admin password with #289

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES/189.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Support setting initial admin password with the env var PULP_DEFAULT_ADMIN_PASSWORD

8 changes: 8 additions & 0 deletions s6_images/assets/init/postgres-prepare
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,13 @@ fi

export DJANGO_SETTINGS_MODULE=pulpcore.app.settings
export PULP_CONTENT_ORIGIN=localhost
echo -e "${PREFIX} ${GREEN}running Pulp migrations${ENDCOLOR}"
su -m pulp -c "/usr/local/bin/pulpcore-manager migrate"
if [ -n "$PULP_DEFAULT_ADMIN_PASSWORD" ]; then
PASSWORD_SET=$(su -m pulp -c '/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
echo -e "${PREFIX} ${GREEN}Setting Pulp admin password${ENDCOLOR}"
su -m pulp -c "/usr/local/bin/pulpcore-manager reset-admin-password --password ${PULP_DEFAULT_ADMIN_PASSWORD}"
fi
fi
echo -e "ready" > /database/status
2 changes: 2 additions & 0 deletions s6_images/assets/s6-rc.d/postgres-prepare/up
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/execlineb -S0

with-contenv

foreground { s6-echo "Calling /etc/init/postgres-prepare" }
/etc/init/postgres-prepare
2 changes: 1 addition & 1 deletion s6_images/assets/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ docker run --detach \
--publish 8080:$port \
--volume "/$(pwd)/settings:/etc/pulp:Z" \
--device /dev/fuse \
-e PULP_DEFAULT_ADMIN_PASSWORD=password \
"$image"
sleep 10
for _ in $(seq 30)
Expand All @@ -41,7 +42,6 @@ done
curl --insecure --fail $scheme://localhost:8080/pulp/api/v3/status/ | jq

if [[ ${image} != *"galaxy"* ]];then
docker exec pulp pulpcore-manager reset-admin-password --password password
echo 127.0.0.1 pulp | sudo tee -a /etc/hosts
git clone --depth=1 https://github.com/pulp/pulp-cli.git
cd pulp-cli
Expand Down