Skip to content
This repository has been archived by the owner. It is now read-only.

Comanagephp #9

Merged
16 commits merged into from
Sep 15, 2016
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ ENV MYSQL_HOST "i2mariadb"
ENV MYSQL_DATABASE "registry"
ENV MYSQL_USER "registry_user"
ENV MYSQL_PASSWORD "WJzesbe3poNZ91qIbmR7"
ENV ADMIN_FAMILY "admin"
ENV ADMIN_USERNAME "admin"
ENV ADMIN_NAME "admin"
ENV TERM "testterm"
# How long will we wait for MariaDB to start up?
ENV WAIT_TIME 60
Expand All @@ -100,6 +103,13 @@ RUN ln -s /opt/etc/httpd/conf.d/ports.conf /etc/httpd/conf.d/ports.conf
RUN ln -s /opt/etc/httpd/conf.d/handlers.conf /etc/httpd/conf.d/handlers.conf
RUN ln -s /opt/etc/httpd/conf.d/virtual_host_80.conf /etc/httpd/conf.d/00-comanage-80.conf

#Add php Configuration
RUN ln -s /opt/etc/php/EmailSheel.php /opt/comanage/comanage-registry-$version/app/Console/Command/EmailSheel.php
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each RUN command creates a new layer. Can you chain these together with && ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

RUN ln -s /opt/etc/php/database.php /opt/comanage/comanage-registry-$version/local/Config/database.php
RUN rm -f /opt/comanage/comanage-registry-$version/app/Config/database.php && ln -s /opt/etc/php/database.php /opt/comanage/comanage-registry-$version/app/Config/database.php
RUN ln -s /opt/etc/php/email.php /opt/comanage/comanage-registry-$version/local/Config/email.php
RUN rm -f /opt/comanage/comanage-registry-$version/app/Config/email.php && ln -s /opt/etc/php/email.php /opt/comanage/comanage-registry-$version/app/Config/email.php

# Port
EXPOSE 80 443

Expand Down
10 changes: 10 additions & 0 deletions container_files/bin/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
#!/bin/bash

log=/tmp/cleanup.log

date >> $log

echo "Cleaning firsttimerunning" >> $log

rm /tmp/firsttimerunning


3 changes: 2 additions & 1 deletion container_files/bin/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

/opt/bin/configure_httpd.sh

/opt/bin/configure_shibd.sh

/opt/bin/configure_php.sh

/opt/bin/configure_shibd.sh


7 changes: 6 additions & 1 deletion container_files/bin/configure_httpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
log="/tmp/httpd.log"
date >> $log
echo "Configuring httpd: " >> $log

echo "Parsing COMANAGE_SERVER_FQDN to $COMANAGE_SERVER_FQDN in virtualhost 80 and 443" >> $log
sed -i "s|COMANAGE_SERVER_FQDN|$COMANAGE_SERVER_FQDN|g" /opt/etc/httpd/conf.d/virtual_host_80.conf >> $log
sed -i "s|COMANAGE_SERVER_FQDN|$COMANAGE_SERVER_FQDN|g" /opt/etc/httpd/conf.d/virtual_host_443.conf >> $log
echo "virtualhost parsed" >> $log
if [[ $CHANGE_TO_SSL_HTTPD_KEY && ${CHANGE_TO_SSL_HTTPD_KEY-x} ]]; then
echo "Parsing CHANGE_TO_SSL_HTTPD_KEY to $CHANGE_TO_SSL_HTTPD_KEY in virtual host 443" >> $log
sed -i "s|CHANGE_TO_SSL_HTTPD_KEY|$CHANGE_TO_SSL_HTTPD_KEY|g" /opt/etc/httpd/conf.d/virtual_host_443.conf >> $log
echo "key parsed in virtualhost 443" >> $log
else
echo "CHANGE_TO_SSL_HTTPD_KEY variable is not used" >> $log
fi
if [[ $CHANGE_TO_SSL_HTTPD_CERT && ${CHANGE_TO_SSL_HTTPD_CERT-x} ]]; then
echo "Parsing CHANGE_TO_SSL_HTTPD_CERT to $CHANGE_TO_SSL_HTTPD_CERT in virtualhost 443" >> $log
sed -i "s|CHANGE_TO_SSL_HTTPD_CERT|$CHANGE_TO_SSL_HTTPD_CERT|g" /opt/etc/httpd/conf.d/virtual_host_443.conf >> $log
echo "httpd cert parsed in virtualhost 443" >> $log
else
echo "CHANGE_TO_SSL_HTTPD_CERT variable is not used" >> $log
fi
Expand Down
57 changes: 56 additions & 1 deletion container_files/bin/configure_php.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,62 @@
#!/bin/bash

log="/tmp/php.log"
date >> $log
echo "Configuring php: " >> $log

echo "Configuring php: " > $log
echo " " >> $log
echo "Checking variables before configuring config files " >> $log

if [[ $MYSQL_HOST && ${MYSQL_HOST-x} ]] && [[ $MYSQL_USER && ${MYSQL_USER-x} ]] && [[ $MYSQL_PASSWORD && ${MYSQL_PASSWORD-x} ]] && [[ $MYSQL_DATABASE && ${MYSQL_DATABASE-x} ]] && [[ $COMANAGE_MAIL_FROM && ${COMANAGE_MAIL_FROM-x} ]] && [[ $COMANAGE_MAIL_HOST && ${COMANAGE_MAIL_HOST-x} ]] && [[ $COMANAGE_MAIL_PORT && ${COMANAGE_MAIL_PORT-x} ]] && [[ $COMANAGE_MAIL_USER && ${COMANAGE_MAIL_USER-x} ]] && [[ $COMANAGE_MAIL_PASS && ${COMANAGE_MAIL_PASS-x} ]]; then
sed -i "s|CHANGE_TO_ENV_MYSQL_HOST|$MYSQL_HOST|g" /opt/etc/php/database.php
sed -i "s|CHANGE_TO_ENV_MYSQL_USERNAME|$MYSQL_USER|g" /opt/etc/php/database.php
sed -i "s|CHANGE_TO_ENV_MYSQL_PASSWORD|$MYSQL_PASSWORD|g" /opt/etc/php/database.php
sed -i "s|CHANGE_TO_ENV_MYSQL_TABLE|$MYSQL_DATABASE|g" /opt/etc/php/database.php
sed -i "s|CHANGE_TO_COMANAGE_MAIL_FROM|$COMANAGE_MAIL_FROM|g" /opt/etc/php/email.php
sed -i "s|CHANGE_TO_COMANAGE_MAIL_HOST|$COMANAGE_MAIL_HOST|g" /opt/etc/php/email.php
sed -i "s|CHANGE_TO_COMANAGE_MAIL_PORT|$COMANAGE_MAIL_PORT|g" /opt/etc/php/email.php
sed -i "s|CHANGE_TO_COMANAGE_MAIL_USER|$COMANAGE_MAIL_USER|g" /opt/etc/php/email.php
sed -i "s|CHANGE_TO_COMANAGE_MAIL_PASS|$COMANAGE_MAIL_PASS|g" /opt/etc/php/email.php
echo "Variables process was completed without any error" >> $log
else
echo "Variables are not totally filled so no configuration was performed" >> $log

fi
date >> $log
if [ -z ${COMPOSE+x} ];then
echo "Comanage is not composed no database configuration will be perform" >> $log
else
echo "Comanage is composed. Checking variables to Configure first database data" >> $log
if [[ $ADMIN_NAME && ${ADMIN_NAME-x} ]] && [[ $ADMIN_FAMILY && ${ADMIN_FAMILY-x} ]] && [[ $ADMIN_USERNAME && ${ADMIN_USERNAME-x} ]] && [[ $VERSION && ${VERSION-x} ]]; then
echo "Variables are ok" >> $log
echo "Doing first configuration in database data" >> $log
cd /opt/comanage/comanage-registry-$VERSION/app
./Console/cake database >> $log
laststatus=$?
echo "Composed status: $laststatus" >> $log
if [ "$laststatus" != "0" ]; then
echo "Not composed non-zero exit status: $laststatus" >> $log
echo "Console cake database script failed" >> $log
exit 1
fi
date >> $log
echo "First database input was completed whithout any error" >> $log
echo "Doing variable parsing" >> $log
sed -i "s|ADMIN_NAME|$ADMIN_NAME|g" /opt/bin/configure_php_user.sh
sed -i "s|ADMIN_FAMILY|$ADMIN_FAMILY|g" /opt/bin/configure_php_user.sh
sed -i "s|ADMIN_USERNAME|$ADMIN_USERNAME|g" /opt/bin/configure_php_user.sh
/opt/bin/configure_php_user.sh
laststatus=$?
if [ "$laststatus" != "0" ]; then
echo "Not composed non-zero exit status: $laststatus" >> $log
echo "Console cake database setup script failed" >> $log
exit 1
fi
date >> $log
echo "Configuration of database was completed" >> $log
else
echo "Variables were not provided . Configuration of database is not possible" >> $log
date >> $log
fi

fi
7 changes: 7 additions & 0 deletions container_files/bin/configure_php_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
log=/tmp/php-user.sh

date >> $log
cd /opt/comanage/comanage-registry-$VERSION/app
echo "Performing database user setup" >> $log
./Console/cake setup --admin-given-name ADMIN_NAME --admin-family-name ADMIN_FAMILY --admin-username ADMIN_USERNAME --enable-pooling=No --force >> $log

13 changes: 10 additions & 3 deletions container_files/bin/configure_shibd.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/bin/bash

log="/tmp/shibd.log"

date >> $log
echo "Configuring shibd: " > $log


if [[ $COMANAGE_SERVER_FQDN && ${COMANAGE_SERVER_FQDN-x} ]]; then
echo "Parsing COMANAGE_SERVER_FQDN to $COMANAGE_SERVER_FQDN in /etc/opt/shibboleth/shibboleth2.xml" >> $log
sed -i "s|COMANAGE_SERVER_FQDN|$COMANAGE_SERVER_FQDN|g" /opt/etc/shibboleth/shibboleth2.xml
echo "shibboleth2.xml parsed" >> $log
else
echo "Variable COMANAGE_SERVER_FQDN not found" >> $log
fi
echo "Shibboleth xml parsing finish" >> $log
date >> $log
20 changes: 16 additions & 4 deletions container_files/bin/start.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

log="/tmp/start-starting.log"
date >> $log

if [ -z ${COMPOSE+x} ]
then
echo "Not composed so not waiting for MariaDB: " > $log
Expand Down Expand Up @@ -43,7 +43,19 @@ else
echo "Database Connection with $MYSQL_USER to database $MYSQL_DATABASE was completed without any error" >> $log
echo "Database Connection with $MYSQL_USER to database $MYSQL_DATABASE was completed without any error"
date >> $log
echo "Starting apache and shibd" >>$log
echo "Starting apache shibd"
/usr/local/bin/httpd-shib-foreground
/opt/bin/main.sh
laststatus="$?"
echo "main.sh last status: $laststatus"
if [ "$laststatus" != "0" ]; then
echo "composed non-zero exit status: $laststatus" >> $log
echo "composed non-zero exit status: $laststatus"
exit 1
else
date >> $log
echo "COmanage was configured" >>$log
echo "COmanage was configured"
echo "Starting apache and shibd" >>$log
echo "Starting apache shibd"
/usr/local/bin/httpd-shib-foreground
fi
fi
4 changes: 2 additions & 2 deletions container_files/etc/shibboleth/shibboleth2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
clockSkew="180">

<ApplicationDefaults entityID="https://CHANGE_TO_COMANAGE_SERVER_FQDN/shibboleth"
<ApplicationDefaults entityID="https://COMANAGE_SERVER_FQDN/shibboleth"
REMOTE_USER="eppn persistent-id targeted-id">

<Sessions lifetime="28800" timeout="3600" relayState="ss:mem"
checkAddress="false" handlerSSL="true" cookieProps="https">

<SSO discoveryProtocol="SAMLDS" discoveryURL="https://CHANGE_TO_COMANAGE_SERVER_FQDN/registry/pages/eds/index">
<SSO discoveryProtocol="SAMLDS" discoveryURL="https://COMANAGE_SERVER_FQDN/registry/pages/eds/index">
SAML2
</SSO>

Expand Down