Skip to content

Commit

Permalink
work on openshift and add more debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
mchyzer committed Jan 12, 2021
1 parent d8bc1e7 commit 50b6699
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 43 deletions.
129 changes: 101 additions & 28 deletions container_files/usr-local-bin/libraryPrep.sh
Original file line number Diff line number Diff line change
@@ -1,48 +1,118 @@
#!/bin/bash

prep_openshift() {
if [ -z "$GROUPER_CHOWN_DIRS" ]; then export GROUPER_CHOWN_DIRS=false; fi
if [ -z "$GROUPER_SHIB_LOG_USE_PIPE" ]; then export GROUPER_SHIB_LOG_USE_PIPE=false; fi
if [ -z "$GROUPER_GSH_CHECK_USER" ]; then export GROUPER_GSH_CHECK_USER=false; fi
if [ -z "$GROUPER_RUN_PROCESSES_AS_USERS" ]; then export GROUPER_RUN_PROCESSES_AS_USERS=false; fi
if [ "$GROUPER_OPENSHIFT" == 'true' ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_openshift) GROUPER_OPENSHIFT is true"
if [ -z "$GROUPER_CHOWN_DIRS" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_openshift) export GROUPER_CHOWN_DIRS=false"
export GROUPER_CHOWN_DIRS=false
fi
if [ -z "$GROUPER_SHIB_LOG_USE_PIPE" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_openshift) export GROUPER_SHIB_LOG_USE_PIPE=false"
export GROUPER_SHIB_LOG_USE_PIPE=false
fi
if [ -z "$GROUPER_USE_PIPES" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_openshift) export GROUPER_USE_PIPES=false"
export GROUPER_USE_PIPES=false
fi
if [ -z "$GROUPER_GSH_CHECK_USER" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_openshift) export GROUPER_GSH_CHECK_USER=false"
export GROUPER_GSH_CHECK_USER=false
fi
if [ -z "$GROUPER_RUN_PROCESSES_AS_USERS" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_openshift) export GROUPER_RUN_PROCESSES_AS_USERS=false"
export GROUPER_RUN_PROCESSES_AS_USERS=false
fi
fi
}

prep_quickstart() {

if [ "$GROUPER_RUN_TOMCAT_NOT_SUPERVISOR" != "true" ]; then
if [ -z "$GROUPER_RUN_HSQLDB" ]; then export GROUPER_RUN_HSQLDB=true; fi
if [ -z "$GROUPER_SELF_SIGNED_CERT" ]; then export GROUPER_SELF_SIGNED_CERT=true; fi
if [ -z "$GROUPER_START_DELAY_SECONDS" ]; then export GROUPER_START_DELAY_SECONDS='10'; fi
if [ -z "$GROUPER_DATABASE_URL_FILE" ] && [ -z "$GROUPER_DATABASE_URL" ]; then export GROUPER_DATABASE_URL=jdbc:hsqldb:hsql://localhost:9001/grouper; fi
if [ -z "$GROUPER_DATABASE_USERNAME_FILE" ] && [ -z "$GROUPER_DATABASE_USERNAME" ]; then export GROUPER_DATABASE_USERNAME=sa; fi
if [ -z "$GROUPER_RUN_HSQLDB" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_RUN_HSQLDB=true"
export GROUPER_RUN_HSQLDB=true
fi
if [ -z "$GROUPER_SELF_SIGNED_CERT" ] && [ "$GROUPER_OPENSHIFT" != "true" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_SELF_SIGNED_CERT=true"
export GROUPER_SELF_SIGNED_CERT=true
fi
if [ -z "$GROUPER_START_DELAY_SECONDS" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_START_DELAY_SECONDS='10'"
export GROUPER_START_DELAY_SECONDS='10'
fi
if [ -z "$GROUPER_DATABASE_URL_FILE" ] && [ -z "$GROUPER_DATABASE_URL" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_DATABASE_URL=jdbc:hsqldb:hsql://localhost:9001/grouper"
export GROUPER_DATABASE_URL=jdbc:hsqldb:hsql://localhost:9001/grouper
fi
if [ -z "$GROUPER_DATABASE_USERNAME_FILE" ] && [ -z "$GROUPER_DATABASE_USERNAME" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_DATABASE_USERNAME=sa"
export GROUPER_DATABASE_USERNAME=sa
fi
fi
if [ -z "$GROUPER_RUN_SHIB_SP" ] && [ "$GROUPER_OPENSHIFT" != "true" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_RUN_SHIB_SP=false"
export GROUPER_RUN_SHIB_SP=false
fi
if [ -z "$GROUPER_AUTO_DDL_UPTOVERSION" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_AUTO_DDL_UPTOVERSION='v2.5.*'"
export GROUPER_AUTO_DDL_UPTOVERSION='v2.5.*'
fi
if [ -z "$GROUPER_UI_CONFIGURATION_EDITOR_SOURCEIPADDRESSES" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_UI_CONFIGURATION_EDITOR_SOURCEIPADDRESSES='0.0.0.0/0'"
export GROUPER_UI_CONFIGURATION_EDITOR_SOURCEIPADDRESSES='0.0.0.0/0'
fi
if [ -z "$GROUPER_RUN_SHIB_SP" ]; then export GROUPER_RUN_SHIB_SP=false; fi
if [ -z "$GROUPER_AUTO_DDL_UPTOVERSION" ]; then export GROUPER_AUTO_DDL_UPTOVERSION='v2.5.*'; fi
if [ -z "$GROUPER_UI_CONFIGURATION_EDITOR_SOURCEIPADDRESSES" ]; then export GROUPER_UI_CONFIGURATION_EDITOR_SOURCEIPADDRESSES='0.0.0.0/0'; fi
# wait for database to start
if [ -z "$GROUPER_UI_GROUPER_AUTH" ]; then export GROUPER_UI_GROUPER_AUTH='true'; fi
if [ -z "$GROUPER_WS_GROUPER_AUTH" ]; then export GROUPER_WS_GROUPER_AUTH='true'; fi
if [ -z "$GROUPER_SCIM_GROUPER_AUTH" ] ; then export GROUPER_SCIM_GROUPER_AUTH=true; fi
if [ -z "$GROUPER_QUICKSTART" ]; then export GROUPER_QUICKSTART=true; fi
if [ -z "$GROUPER_UI_GROUPER_AUTH" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_UI_GROUPER_AUTH='true'"
export GROUPER_UI_GROUPER_AUTH='true'
fi
if [ -z "$GROUPER_WS_GROUPER_AUTH" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_WS_GROUPER_AUTH='true'"
export GROUPER_WS_GROUPER_AUTH='true'
fi
if [ -z "$GROUPER_SCIM_GROUPER_AUTH" ] ; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_SCIM_GROUPER_AUTH=true"
export GROUPER_SCIM_GROUPER_AUTH=true
fi
if [ -z "$GROUPER_QUICKSTART" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_quickstart) export GROUPER_QUICKSTART=true"
export GROUPER_QUICKSTART=true
fi

}

prep_daemon() {

if [ -z "$GROUPER_DAEMON" ]; then export GROUPER_DAEMON=true; fi
if [ -z "$GROUPER_RUN_TOMEE" ]; then export GROUPER_RUN_TOMEE=true; fi
if [ -z "$GROUPER_DAEMON" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_daemon) export GROUPER_DAEMON=true"
export GROUPER_DAEMON=true
fi
if [ -z "$GROUPER_RUN_TOMEE" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_daemon) export GROUPER_RUN_TOMEE=true"
export GROUPER_RUN_TOMEE=true
fi
}

prep_scim() {
if [ -z "$GROUPER_SCIM" ]; then export GROUPER_SCIM=true; fi
if [ -z "$GROUPER_RUN_APACHE" ] && [ "$GROUPER_RUN_TOMCAT_NOT_SUPERVISOR" != "true" ]; then export GROUPER_RUN_APACHE=true; fi
if [ -z "$GROUPER_RUN_TOMEE" ]; then export GROUPER_RUN_TOMEE=true; fi
if [ -z "$GROUPER_SCIM" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_scim) export GROUPER_SCIM=true"
export GROUPER_SCIM=true
fi
if [ -z "$GROUPER_RUN_APACHE" ] && [ "$GROUPER_RUN_TOMCAT_NOT_SUPERVISOR" != "true" ] && [ "$GROUPER_OPENSHIFT" != "true" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_scim) export GROUPER_RUN_APACHE=true"
export GROUPER_RUN_APACHE=true
fi
if [ -z "$GROUPER_RUN_TOMEE" ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_scim) export GROUPER_RUN_TOMEE=true"
export GROUPER_RUN_TOMEE=true
fi
}

prep_ui() {
if [ -z "$GROUPER_UI" ]; then export GROUPER_UI=true; fi
if [ -z "$GROUPER_RUN_APACHE" ] && [ "$GROUPER_RUN_TOMCAT_NOT_SUPERVISOR" != "true" ]; then export GROUPER_RUN_APACHE=true; fi
if [ -z "$GROUPER_RUN_SHIB_SP" ] && [ "$GROUPER_RUN_TOMCAT_NOT_SUPERVISOR" != "true" ]; then export GROUPER_RUN_SHIB_SP=true; fi
if [ -z "$GROUPER_RUN_APACHE" ] && [ "$GROUPER_RUN_TOMCAT_NOT_SUPERVISOR" != "true" ] && [ "$GROUPER_OPENSHIFT" != "true" ]; then export GROUPER_RUN_APACHE=true; fi
if [ -z "$GROUPER_RUN_SHIB_SP" ] && [ "$GROUPER_RUN_TOMCAT_NOT_SUPERVISOR" != "true" ] && [ "$GROUPER_OPENSHIFT" != "true" ]; then export GROUPER_RUN_SHIB_SP=true; fi
if [ -z "$GROUPER_RUN_TOMEE" ]; then export GROUPER_RUN_TOMEE=true; fi
}

Expand Down Expand Up @@ -85,15 +155,20 @@ prep_runScim() {


prep_ws() {

if [ -z "$GROUPER_WS" ]; then export GROUPER_WS=true; fi
if [ -z "$GROUPER_RUN_APACHE" ] && [ "$GROUPER_RUN_TOMCAT_NOT_SUPERVISOR" != "true" ]; then export GROUPER_RUN_APACHE=true; fi
if [ -z "$GROUPER_RUN_APACHE" ] && [ "$GROUPER_RUN_TOMCAT_NOT_SUPERVISOR" != "true" ] && [ "$GROUPER_OPENSHIFT" != "true" ] ; then export GROUPER_RUN_APACHE=true; fi
if [ -z "$GROUPER_RUN_TOMEE" ]; then export GROUPER_RUN_TOMEE=true; fi
}

prep_conf() {

echo "grouperContainer; INFO: (libraryPrep.sh-prep_conf) Start setting up initial pipes"
if [ -z "$GROUPER_USE_PIPES" ]; then
if [ "$GROUPER_OPENSHIFT" != 'true' ]; then
echo "grouperContainer; INFO: (libraryPrep.sh-prep_conf) GROUPER_USE_PIPES=true"
export GROUPER_USE_PIPES=true
fi
fi
setupPipe_logging
setupPipe_supervisordLog
setupPipe_grouperLog
Expand Down Expand Up @@ -146,9 +221,7 @@ prep_finishBegin() {
# default a lot of env variables
# morph defaults to null
# database password defaults to null
if [ "$GROUPER_OPENSHIFT" == 'true' ]; then
prep_openshift
fi
prep_openshift
if [ -z "$GROUPER_UI_GROUPER_AUTH" ] ; then export GROUPER_UI_GROUPER_AUTH=false; fi
if [ -z "$GROUPER_WS_GROUPER_AUTH" ] ; then export GROUPER_WS_GROUPER_AUTH=false; fi
if [ -z "$GROUPER_SCIM_GROUPER_AUTH" ] ; then export GROUPER_SCIM_GROUPER_AUTH=false; fi
Expand Down
47 changes: 32 additions & 15 deletions container_files/usr-local-bin/librarySetupPipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,34 @@ setupPipe() {
}

setupPipe_logging() {

if [ "$GROUPER_USE_PIPES" == "true" ]; then
# Make a "console" logging pipe that anyone can write too regardless of who owns the process.
setupPipe /tmp/logpipe
cat <> /tmp/logpipe &
fi
}

# Make loggers pipes for the supervisord connected apps' console, so that we can prepend the streams.
setupPipe_grouperLog() {
if [ "$GROUPER_USE_PIPES" == "true" ]; then
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) &
fi
}

setupPipe_httpdLog() {
if [ "$GROUPER_RUN_APACHE" = "true" ]
then
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) &
if [ "$GROUPER_USE_PIPES" == "true" ]; then
if [ "$GROUPER_RUN_APACHE" = "true" ]
then
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) &
fi
fi
}

setupPipe_shibdLog() {
if [ "$GROUPER_USE_PIPES" == "true" ]; then
if [ "$GROUPER_RUN_SHIB_SP" = "true" ]
then
if [ "$GROUPER_SHIB_LOG_USE_PIPE" = "true" ]
Expand All @@ -37,34 +45,43 @@ setupPipe_shibdLog() {
(cat <> /tmp/logshibd | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "shibd;console;%s;%s;%s", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
fi
fi
fi
}

setupPipe_tomcatLog() {
if [ "$GROUPER_RUN_TOMEE" = "true" ] && [ "$GROUPER_LOG_TO_HOST" != "true" ]
then
setupPipe /tmp/logtomcat
(cat <> /tmp/logtomcat | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "tomee;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
if [ "$GROUPER_USE_PIPES" == "true" ]; then
if [ "$GROUPER_RUN_TOMEE" = "true" ] && [ "$GROUPER_LOG_TO_HOST" != "true" ]
then
setupPipe /tmp/logtomcat
(cat <> /tmp/logtomcat | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "tomee;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
fi
fi
}

setupPipe_tomcatAccessLog() {
if [ "$GROUPER_TOMCAT_LOG_ACCESS" = "true" ]; then

setupPipe /tmp/tomcat_access_log
(cat <> /tmp/tomcat_access_log | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "tomcat-access;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' 1>/tmp/logpipe) &
if [ "$GROUPER_USE_PIPES" == "true" ]; then
if [ "$GROUPER_TOMCAT_LOG_ACCESS" = "true" ]; then

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

setupPipe_hsqldbLog() {
if [ "$GROUPER_RUN_HSQLDB" = "true" ]; then
setupPipe /tmp/loghsqldb
(cat <> /tmp/loghsqldb | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "hsqldb;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
if [ "$GROUPER_USE_PIPES" == "true" ]; then
if [ "$GROUPER_RUN_HSQLDB" = "true" ]; then
setupPipe /tmp/loghsqldb
(cat <> /tmp/loghsqldb | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "hsqldb;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' &>/tmp/logpipe) &
fi
fi
}

setupPipe_supervisordLog() {
if [ "$GROUPER_USE_PIPES" == "true" ]; then
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) &
fi
}

setupPipe_unsetAll() {
Expand Down

0 comments on commit 50b6699

Please sign in to comment.