diff --git a/Dockerfile b/Dockerfile index cca47c28..aea12836 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,9 +18,11 @@ ENV WAIT_TIME=60 LABEL Build docker build --rm --tag $maintainer/$imagename . -COPY MariaDB.repo /etc/yum.repos.d/MariaDB.repo +ADD container_files /opt RUN mkdir -p /opt/grouper/$VERSION \ + && mv /opt/etc/grouper.installer.properties /opt/grouper/$VERSION/. \ + && mv /opt/etc/MariaDB.repo /etc/yum.repos.d/MariaDB.repo \ && curl -o /opt/grouper/$VERSION/grouperInstaller.jar http://software.internet2.edu/grouper/release/$VERSION/grouperInstaller.jar \ && yum -y update \ && yum -y install --setopt=tsflags=nodocs \ @@ -30,10 +32,6 @@ RUN mkdir -p /opt/grouper/$VERSION \ MariaDB-client \ mlocate \ && yum clean all - -# Add starters and installers -ADD ./container_files /opt -COPY grouper.installer.properties /opt/grouper/$version # The installer creates a HSQL DB which we ignore later WORKDIR /opt/grouper/$version diff --git a/container_files/bin/check.sh b/container_files/bin/check.sh index 9b997d2e..cda8f095 100755 --- a/container_files/bin/check.sh +++ b/container_files/bin/check.sh @@ -1,5 +1,5 @@ #!/bin/bash -log="/tmp/shib.log" +log="/tmp/grouper.log" -cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check \ No newline at end of file +cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check >> $log \ No newline at end of file diff --git a/container_files/bin/cleanup.sh b/container_files/bin/cleanup.sh new file mode 100755 index 00000000..a829a2ed --- /dev/null +++ b/container_files/bin/cleanup.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +log="/tmp/grouper.log" + +rm -f /tmp/firsttimerunning >> $log \ No newline at end of file diff --git a/container_files/bin/configure.sh b/container_files/bin/configure.sh index 176b8d87..65fe687e 100755 --- a/container_files/bin/configure.sh +++ b/container_files/bin/configure.sh @@ -1,3 +1,27 @@ -#!/bin/bash -x +#!/bin/bash -# Configure your access (e.g. rewriting grouper.installer.properties) here \ No newline at end of file +log="/tmp/grouper.log" + +sed -i "s|#GROUPER_SYSTEM_PASSWORD#|$GROUPER_SYSTEM_PASSWORD|g" /opt/etc/grouper.installer.properties >> $log + +# Long-lived configuration values, these are symlinked into place + +sed -i "s|#MYSQL_HOST#|$MYSQL_HOST|g" /opt/etc/grouper.hibernate.properties >> $log + +sed -i "s|#MYSQL_USER#|$MYSQL_USER|g" /opt/etc/grouper.hibernate.properties >> $log + +sed -i "s|#MYSQL_PASSWORD#|$MYSQL_PASSWORD|g" /opt/etc/grouper.hibernate.properties >> $log + +sed -i "s|#MYSQL_DATABASE#|$MYSQL_DATABASE|g" /opt/etc/grouper.hibernate.properties >> $log + +# Transient DB whitelist capability for when schema changes are needed + +sed -i "s|#MYSQL_HOST#|$MYSQL_HOST|g" /opt/etc/grouper.properties >> $log + +sed -i "s|#MYSQL_USER#|$MYSQL_USER|g" /opt/etc/grouper.properties >> $log + +sed -i "s|#MYSQL_DATABASE#|$MYSQL_DATABASE|g" /opt/etc/grouper.properties >> $log + +cat /opt/etc/grouper.hibernate.properties >> $log + +cat /opt/etc/grouper.properties >> $log \ No newline at end of file diff --git a/container_files/bin/main.sh b/container_files/bin/main.sh index 36a34cb0..9a780614 100755 --- a/container_files/bin/main.sh +++ b/container_files/bin/main.sh @@ -10,11 +10,12 @@ if [ -e "/tmp/firsttimerunning" ]; then set -e - /opt/bin/configure.sh + /opt/bin/configure.sh >> $log - /opt/bin/check.sh + /opt/bin/check.sh >> $log - rm -f /tmp/firsttimerunning + /opt/bin/cleanup.sh >> $log + else echo "Grouper container has run." >> $log echo "If there are problems, docker rm this container and try again." >> $log diff --git a/MariaDB.repo b/container_files/etc/MariaDB.repo similarity index 100% rename from MariaDB.repo rename to container_files/etc/MariaDB.repo diff --git a/container_files/etc/grouper.hibernate.properties b/container_files/etc/grouper.hibernate.properties new file mode 100644 index 00000000..a198ae7b --- /dev/null +++ b/container_files/etc/grouper.hibernate.properties @@ -0,0 +1,49 @@ +# +# Copyright 2014 Internet2 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Grouper Hibernate Configuration +# $Id: grouper.hibernate.example.properties,v 1.9 2009-08-11 20:18:09 mchyzer Exp $ +# + +# The grouper hibernate config uses Grouper Configuration Overlays (documented on wiki) +# By default the configuration is read from grouper.hibernate.base.properties +# (which should not be edited), and the grouper.hibernate.properties overlays +# the base settings. See the grouper.hibernate.base.properties for the possible +# settings that can be applied to the grouper.hibernate.properties + +######################################## +## DB settings +######################################## + +# e.g. mysql: jdbc:mysql://localhost:3306/grouper +# e.g. p6spy (log sql): [use the URL that your DB requires] +# e.g. oracle: jdbc:oracle:thin:@server.school.edu:1521:sid +# e.g. hsqldb (a): jdbc:hsqldb:dist/run/grouper;create=true +# e.g. hsqldb (b): jdbc:hsqldb:hsql://localhost:9001/grouper +# e.g. postgres: jdbc:postgresql://localhost:5432/database +# e.g. mssql: jdbc:sqlserver://localhost:3280;databaseName=grouper +hibernate.connection.url = jdbc:mysql://#MYSQL_HOST#:3306/#MYSQL_DATABASE# + +hibernate.connection.username = #MYSQL_USER# +# If you are using an empty password, depending upon your version of +# Java and Ant you may need to specify a password of "". +# Note: you can keep passwords external and encrypted: https://bugs.internet2.edu/jira/browse/GRP-122 +hibernate.connection.password = #MYSQL_PASSWORD# + + +hibernate.dialect = org.hibernate.dialect.MySQL5Dialect +hibernate.connection.driver_class = com.mysql.jdbc.Driver \ No newline at end of file diff --git a/grouper.installer.properties b/container_files/etc/grouper.installer.properties similarity index 100% rename from grouper.installer.properties rename to container_files/etc/grouper.installer.properties diff --git a/container_files/etc/grouper.properties b/container_files/etc/grouper.properties new file mode 100644 index 00000000..83133353 --- /dev/null +++ b/container_files/etc/grouper.properties @@ -0,0 +1,2 @@ +db.change.allow.user.0=#MYSQL_USER# +db.change.allow.url.0=jdbc:mysql://#MYSQL_HOST#:3306/#MYSQL_DATABASE# \ No newline at end of file diff --git a/tests/image.bats b/tests/image.bats index 4be7160a..50c2dfdf 100644 --- a/tests/image.bats +++ b/tests/image.bats @@ -2,8 +2,24 @@ load ../common +@test "MariaDB repo provisioned" { + docker run -i $maintainer/$imagename find /etc/yum.repos.d/MariaDB.repo +} + @test "Grouper directory created" { - docker run -i $maintainer/$imagename find /opt/grouper/$version + docker run -i $maintainer/$imagename find /opt/grouper/$version/grouper.installer.properties +} + +@test "Grouper installer properties in correct position" { + docker run -i $maintainer/$imagename find /etc/yum.repos.d/MariaDB.repo +} + +@test "Grouper hibernate properties template available" { + docker run -i $maintainer/$imagename find /opt/etc/grouper.hibernate.properties +} + +@test "Grouper whitelist properties template available" { + docker run -i $maintainer/$imagename find /opt/etc/grouper.properties } @test "API binary directory created" { @@ -20,4 +36,5 @@ load ../common @test "WS directory created" { docker run -i $maintainer/$imagename find /opt/grouper/$version/grouper.ws-$version -} \ No newline at end of file +} +