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

Enable public user #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions 90-public.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# Configure web public user if enabled
# Waits for OMERO to start before creating necessary accounts so there is a very
# brief window on first startup when OMERO.server and OMERO.web may be available
# but the public user is not yet created

set -eu

omero=/opt/omero/server/OMERO.server/bin/omero
CONFIG_omero_web_public_enabled=${CONFIG_omero_web_public_enabled:-false}

function createPublicUser {
PUBLIC_GROUP=${PUBLIC_GROUP:-public-group}
CONFIG_omero_web_public_user=${CONFIG_omero_web_public_user:-public-user}
CONFIG_omero_web_public_password=${CONFIG_omero_web_public_password:-omero}

$omero -s localhost -p 4064 -u root -w $ROOTPASS group info $PUBLIC_GROUP \
&& echo "Skipping existing public group ($PUBLIC_GROUP) creation" \
|| $omero -s localhost -p 4064 -u root -w $ROOTPASS group add --type read-only $PUBLIC_GROUP
$omero -s localhost -p 4064 -u root -w $ROOTPASS user info $CONFIG_omero_web_public_user \
&& echo "Skipping existing public user ($CONFIG_omero_web_public_user) creation" \
|| $omero -s localhost -p 4064 -u root -w $ROOTPASS user add --group-name $PUBLIC_GROUP -P $CONFIG_omero_web_public_password $CONFIG_omero_web_public_user Public User
}

# Never time out as there could be steps of unknown duration between this and
# OMERO server successfully starting.
function waitForOmero {
while ! $omero -s localhost -p 4064 -u root -w $ROOTPASS login >/dev/null 2>&1; do
echo "$(date) - waiting for OMERO server..."
sleep 5
done
echo "OMERO server connection established"
createPublicUser
}

if [ "$CONFIG_omero_web_public_enabled" = true ]; then
waitForOmero &
fi
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN curl -L -o /usr/local/bin/dumb-init \
https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && \
chmod +x /usr/local/bin/dumb-init
ADD entrypoint.sh /usr/local/bin/
ADD 50-config.py 60-database.sh 99-run.sh /startup/
ADD 50-config.py 60-database.sh 90-public.sh 99-run.sh /startup/

USER omero-server

Expand Down