From 30e1a89d9342f6207c7504b1f52e3f66850736bb Mon Sep 17 00:00:00 2001 From: villadalmine Date: Wed, 14 Sep 2016 17:36:04 -0300 Subject: [PATCH] ADded other script to use variables --- Dockerfile | 3 ++ container_files/bin/configure_php.sh | 37 +++++++++++++++++++++++ container_files/bin/configure_php_user.sh | 7 +++++ 3 files changed, 47 insertions(+) create mode 100755 container_files/bin/configure_php_user.sh diff --git a/Dockerfile b/Dockerfile index af7747f..b1527f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/container_files/bin/configure_php.sh b/container_files/bin/configure_php.sh index 6a5ab89..6a88987 100755 --- a/container_files/bin/configure_php.sh +++ b/container_files/bin/configure_php.sh @@ -23,3 +23,40 @@ else 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 diff --git a/container_files/bin/configure_php_user.sh b/container_files/bin/configure_php_user.sh new file mode 100755 index 0000000..2fb0f75 --- /dev/null +++ b/container_files/bin/configure_php_user.sh @@ -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 +