From 3df9e69d46bb0b2ccb16f7ed23630a4dc077a5a9 Mon Sep 17 00:00:00 2001 From: dpwrussell Date: Tue, 6 Jun 2017 17:39:19 +0100 Subject: [PATCH 1/3] Add public user --- 90-public.sh | 35 +++++++++++++++++++++++++++++++++++ Dockerfile | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 90-public.sh diff --git a/90-public.sh b/90-public.sh new file mode 100644 index 00000000..87e89a36 --- /dev/null +++ b/90-public.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -eu + +omero=/opt/omero/server/OMERO.server/bin/omero + +CONFIG_omero_web_public_enabled=${CONFIG_omero_web_public_enabled:-false} +function createPublicUser { + # Configure public user if appropriate + if [ "$CONFIG_omero_web_public_enabled" = true ]; then + 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 + fi +} + +# 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 +} + +waitForOmero & diff --git a/Dockerfile b/Dockerfile index fc884cf4..24ca5a0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,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 From 15ed16a1c207ff13a7197577a1659e703282dc5c Mon Sep 17 00:00:00 2001 From: dpwrussell Date: Tue, 18 Jul 2017 16:41:23 -0400 Subject: [PATCH 2/3] Correct execute permissions on public startup script --- 90-public.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 90-public.sh diff --git a/90-public.sh b/90-public.sh old mode 100644 new mode 100755 From 17d19ff61664e4f4a654a0a2531303398a727850 Mon Sep 17 00:00:00 2001 From: dpwrussell Date: Fri, 21 Jul 2017 16:25:06 -0400 Subject: [PATCH 3/3] Do not wait for OMERO to start if not enabling public user Also tidy indentation and add comment --- 90-public.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/90-public.sh b/90-public.sh index 87e89a36..a8a314b1 100755 --- a/90-public.sh +++ b/90-public.sh @@ -1,24 +1,25 @@ #!/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 { - # Configure public user if appropriate - if [ "$CONFIG_omero_web_public_enabled" = true ]; then - 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} + 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 - fi + $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 @@ -32,4 +33,6 @@ function waitForOmero { createPublicUser } -waitForOmero & +if [ "$CONFIG_omero_web_public_enabled" = true ]; then + waitForOmero & +fi