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

Commit

Permalink
Merge pull request #9 from docker/comanagephp
Browse files Browse the repository at this point in the history
Comanagephp
  • Loading branch information
Jim Van Fleet committed Sep 15, 2016
2 parents 8003b99 + 0cd0652 commit 69cf933
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 3 deletions.
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
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


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

2 changes: 1 addition & 1 deletion 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

0 comments on commit 69cf933

Please sign in to comment.