Skip to content

Commit

Permalink
re-working entrypoint/start-up scripts; fixed a few other things alon…
Browse files Browse the repository at this point in the history
…g the way.
  • Loading branch information
John Gasper committed May 21, 2018
1 parent 27040f3 commit bbbda9d
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 39 deletions.
4 changes: 4 additions & 0 deletions container_files/usr-local-bin/daemon
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

. /usr/local/bin/library.sh

prepDaemon

export GSH_JVMARGS="-DENV=$ENV -DUSERTOKEN=$USERTOKEN"

exec bin/gsh -loader > /tmp/loggrouper
2 changes: 1 addition & 1 deletion container_files/usr-local-bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

. /usr/local/bin/library.sh
prepDaemon
prepConf

exec "$@"
4 changes: 4 additions & 0 deletions container_files/usr-local-bin/gsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

. /usr/local/bin/library.sh

prepDaemon

export GSH_JVMARGS="-DENV=$ENV -DUSERTOKEN=$USERTOKEN"

exec bin/gsh "$@" | tee /tmp/loggrouper
91 changes: 70 additions & 21 deletions container_files/usr-local-bin/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,37 @@ setupPipe() {
mkfifo -m 666 $1
}

# Make a "console" logging pipe that anyone can write too regardless of who owns the process.
setupPipe /tmp/logpipe
cat <> /tmp/logpipe &
setupLoggingPipe() {
# Make a "console" logging pipe that anyone can write too regardless of who owns the process.
setupPipe /tmp/logpipe
cat <> /tmp/logpipe &
}

# Make loggers pipes for the supervisord connected apps' console, so that we can prepend the streams.
setupPipe /tmp/loggrouper
(cat <> /tmp/loggrouper | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "grouper;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &

setupPipe /tmp/loghttpd
(cat <> /tmp/loghttpd | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "httpd;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
setupGrouperLogPipe() {
setupPipe /tmp/loggrouper
(cat <> /tmp/loggrouper | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "grouper;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
}

setupPipe /tmp/logshibd
(cat <> /tmp/logshibd | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "shibd;console;%s;%s;%s", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
setupHttpdLogPipe() {
setupPipe /tmp/loghttpd
(cat <> /tmp/loghttpd | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "httpd;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
}

setupPipe /tmp/logtomcat
(cat <> /tmp/logtomcat | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "tomcat;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
setupShibdLogPipe() {
setupPipe /tmp/logshibd
(cat <> /tmp/logshibd | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "shibd;console;%s;%s;%s", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
}

setupPipe /tmp/logsuperd
(cat <> /tmp/logsuperd | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "supervisord;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
setupTomcatLogPipe() {
setupPipe /tmp/logtomcat
(cat <> /tmp/logtomcat | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "tomcat;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
}

setupSupervisordLogPipe() {
setupPipe /tmp/logsuperd
(cat <> /tmp/logsuperd | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "supervisord;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
}

linkGrouperSecrets() {
for filepath in /run/secrets/*; do
Expand All @@ -46,6 +57,11 @@ linkGrouperSecrets() {
}

prepDaemon() {
setupLoggingPipe
setupGrouperLogPipe
}

prepDaemonConf() {
local dest=/opt/grouper/grouper.apiBinary
linkGrouperSecrets $dest/conf

Expand All @@ -58,6 +74,16 @@ prepDaemon() {
}

prepSCIM() {
setupLoggingPipe
setupGrouperLogPipe
setupHttpdLogPipe
setupTomcatLogPipe


cp /opt/tier-support/grouper-ws-scim.xml /opt/tomee/conf/Catalina/localhost/
}

prepSCIMConf() {
local dest=/opt/grouper/grouper.scim/WEB-INF
linkGrouperSecrets $dest/classes

Expand All @@ -66,12 +92,21 @@ prepSCIM() {
fi
if [ -d "/opt/grouper/lib" ]; then
cp -r /opt/grouper/lib/* $dest/lib/
fi

cp /opt/tier-support/grouper-ws-scim.xml /opt/tomee/conf/Catalina/localhost/
fi
}

prepUI() {
setupLoggingPipe
setupGrouperLogPipe
setupHttpdLogPipe
setupShibdLogPipe
setupTomcatLogPipe
setupSupervisordLogPipe

cp /opt/tier-support/grouper.xml /opt/tomcat/conf/Catalina/localhost/
}

prepUIConf() {
local dest=/opt/grouper/grouper.ui/WEB-INF
linkGrouperSecrets $dest/classes

Expand All @@ -81,11 +116,19 @@ prepUI() {
if [ -d "/opt/grouper/lib" ]; then
cp -r /opt/grouper/lib/* $dest/lib/
fi

cp /opt/tier-support/grouper.xml /opt/tomcat/conf/Catalina/localhost/
}

prepWS() {
setupLoggingPipe
setupGrouperLogPipe
setupHttpdLogPipe
setupTomcatLogPipe
setupSupervisordLogPipe

cp /opt/tier-support/grouper-ws.xml /opt/tomcat/conf/Catalina/localhost/
}

prepWSConf() {
local dest=/opt/grouper/grouper.ws/WEB-INF
linkGrouperSecrets $dest/classes

Expand All @@ -95,6 +138,12 @@ prepWS() {
if [ -d "/opt/grouper/lib" ]; then
cp -r /opt/grouper/lib/* $dest/lib/
fi

cp /opt/tier-support/grouper-ws.xml /opt/tomcat/conf/Catalina/localhost/
}


prepConf() {
prepDaemonConf
prepSCIMConf
prepUIConf
prepWSConf
}
2 changes: 2 additions & 0 deletions container_files/usr-local-bin/ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

. /usr/local/bin/library.sh

prepUI

export LD_LIBRARY_PATH=/opt/shibboleth/lib64:$LD_LIBRARY_PATH
Expand Down
2 changes: 2 additions & 0 deletions container_files/usr-local-bin/ui-ws
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

. /usr/local/bin/library.sh

prepUI
prepWS

Expand Down
2 changes: 2 additions & 0 deletions container_files/usr-local-bin/ws
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

. /usr/local/bin/library.sh

prepWS

exec /usr/bin/supervisord -c /opt/tier-support/supervisord-tomcat.conf
2 changes: 1 addition & 1 deletion test-compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Note that when accessing the Grouper UI, Grouper WS, or Shibboleth IdP, your bro
- In this example, we use a variety of ways to pass in passwords (Grouper database, LDAP, Grouper Client, and RabbitMQ). The point is to demonstrate possibilities and not demonstrating what is required. (See the image readme for more details.)
- Docker `configs` are not supported by Docker Compose (when run in a non-Swarm mode), so those are represented in the `docker-compose.yml` file as bind mount volumes.
- The Grouper config files in the `data` image's `conf` directory are used to build the sample grouper database and ldap store. They are not used when the container is instantiated as there is no Grouper runtime in this container.
- The containers will use Docker Secrets and bind mounts for non-sensitive files that are read from the `configs-ans-secrets` directory in the `test-compose` directory.
- The containers will use Docker Secrets and bind mounts for non-sensitive files that are read from the `configs-and-secrets` directory in the `test-compose` directory.
- With regard to RabbitMQ, the deployer must manually add a queue named `sampleQueue` to see Grouper messages in RabbitMQ. Messages will be dropped by RabbitMQ (and the Grouper Deamon will log errors) until this occurs.
- In this example, we don't care about the IdP secrets. They are baked into the overlay instead of using Docker Secrets. (This is not best practice for an IdP configuration, but that isn't the focus of this example.)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ grouperClient.webService.login = banderson

# password for shared secret authentication to web service
# or you can put a filename with an encrypted password
grouperClient.webService.password = ${java.lang.System.getenv().get('GROUPER_CLIENT_WEBSERVICE_PASSWORD_FILE') != null ? org.apache.commons.io.FileUtils.readFileToString(java.lang.System.getenv().get('GROUPER_CLIENT_WEBSERVICE_PASSWORD_FILE'), "utf-8") : java.lang.System.getenv().get('GROUPER_CLIENT_WEBSERVICE_PASSWORD') }
grouperClient.webService.password.elConfig = ${java.lang.System.getenv().get('GROUPER_CLIENT_WEBSERVICE_PASSWORD_FILE') != null ? org.apache.commons.io.FileUtils.readFileToString(java.lang.System.getenv().get('GROUPER_CLIENT_WEBSERVICE_PASSWORD_FILE'), "utf-8") : java.lang.System.getenv().get('GROUPER_CLIENT_WEBSERVICE_PASSWORD') }


################################
Expand Down Expand Up @@ -100,7 +100,7 @@ grouper.messaging.system.rabbitmq.defaultSystemName = rabbitmqSystem
grouper.messaging.system.rabbitmq.user = guest

#pass
grouper.messaging.system.rabbitmq.password = ${java.lang.System.getenv().get('RABBITMQ_PASSWORD_FILE') != null ? org.apache.commons.io.FileUtils.readFileToString(java.lang.System.getenv().get('RABBITMQ_PASSWORD_FILE'), "utf-8") : java.lang.System.getenv().get('RABBITMQ_PASSWORD') }
grouper.messaging.system.rabbitmq.password.elConfig = ${java.lang.System.getenv().get('RABBITMQ_PASSWORD_FILE') != null ? org.apache.commons.io.FileUtils.readFileToString(java.lang.System.getenv().get('RABBITMQ_PASSWORD_FILE'), "utf-8") : java.lang.System.getenv().get('RABBITMQ_PASSWORD') }
# set the following three properties if you want to use TLS connection to rabbitmq. All three need to be populated.
# TLS Version
#grouper.messaging.system.rabbitmqSystem.tlsVersion = TLSv1.1
Expand Down
3 changes: 2 additions & 1 deletion test-compose/data/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ COPY container_files/conf/ /opt/grouper/grouper.apiBinary/conf/
RUN yum install -y epel-release \
&& yum update -y \
&& yum install -y 389-ds-base 389-admin 389-adminutil mariadb-server mariadb \
&& yum clean all
&& yum clean all \
&& rm -rf /var/cache/yum

RUN mysql_install_db \
&& chown -R mysql:mysql /var/lib/mysql/ \
Expand Down
14 changes: 1 addition & 13 deletions test-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.3"
services:
daemon:
build: ./daemon/
command: bash -c "while ! curl -s data:3306 > /dev/null; do echo waiting for mysql to start; sleep 3; done; exec daemon"
command: bash -c "while ! curl -s data:3306 > /dev/null; do echo waiting for mysql to start; sleep 3; done; while ! curl -s ldap://data:389 > /dev/null; do echo waiting for ldap to start; sleep 3; done; exec daemon"
depends_on:
- data
environment:
Expand All @@ -13,9 +13,6 @@ services:
- RABBITMQ_PASSWORD_FILE=/run/secrets/rabbitmq_password.txt
- SUBJECT_SOURCE_LDAP_PASSWORD=password
- USERTOKEN=build-2
logging:
options:
tag: "grouper daemon"
networks:
- back
secrets:
Expand Down Expand Up @@ -46,9 +43,6 @@ services:
- GROUPER_DATABASE_PASSWORD_FILE=/run/secrets/database_password.txt
- SUBJECT_SOURCE_LDAP_PASSWORD=password
- USERTOKEN=build-2
logging:
options:
tag: "grouper ui"
networks:
- front
- back
Expand Down Expand Up @@ -100,9 +94,6 @@ services:
- GROUPER_DATABASE_PASSWORD_FILE=/run/secrets/database_password.txt
- SUBJECT_SOURCE_LDAP_PASSWORD=password
- USERTOKEN=build-2
logging:
options:
tag: "grouoer ws"
networks:
- front
- back
Expand Down Expand Up @@ -178,9 +169,6 @@ services:
- GROUPER_DATABASE_PASSWORD_FILE=/run/secrets/database_password.txt
- SUBJECT_SOURCE_LDAP_PASSWORD=password
- USERTOKEN=build-2
logging:
options:
tag: "grouper gsh"
networks:
- back
secrets:
Expand Down

0 comments on commit bbbda9d

Please sign in to comment.