Skip to content

Commit

Permalink
merge master -Dorg -Snone: PR 2 (Enable public user)
Browse files Browse the repository at this point in the history
  • Loading branch information
snoopycrimecop committed Feb 13, 2018
2 parents 0e8a533 + 25640e2 commit 93590a6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
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

0 comments on commit 93590a6

Please sign in to comment.