#!/bin/bash #set -euo pipefail function set_config() { FB_ENCRYPTION_KEY=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32` cat <${FILEBIN_DIR}/application/config/config-local.php ${FILEBIN_DIR}/application/config/database.php 'mysql:host=${FB_DB_HOSTNAME};dbname=${FB_DB_DATABASE}', 'hostname' => '', 'port' => 3306, 'username' => '${FB_DB_USERNAME}', 'password' => '${FB_DB_PASSWORD}', 'database' => '', 'dbdriver' => 'pdo', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => TRUE, 'char_set' => 'utf8mb4', // if you use postgres, set this to utf8 'dbcollat' => 'utf8mb4_bin', // if you use postgres, set this to utf8_bin 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => TRUE, 'failover' => array(), 'save_queries' => TRUE ); EOF } # wait for DB to be ready while ! nc "$FB_DB_HOSTNAME" 3306 /dev/null; do echo "Waiting for database" sleep 0.5 done if [[ ! -e $FILEBIN_DIR/application/config/config-local.php ]]; then echo "no config found, new config will be generated" set_config set_database_config CONTACT_INFO_FILE=${FILEBIN_DIR}/data/local/contact-info.php cp $FILEBIN_DIR/data/local/examples/contact-info.php ${CONTACT_INFO_FILE} sed -i "s/John Doe/${FB_CONTACT_NAME}/" ${CONTACT_INFO_FILE} sed -i "s/john.doe@example.com/${FB_CONTACT_MAIL}/" ${CONTACT_INFO_FILE} ${FILEBIN_DIR}/scripts/install-git-hooks.sh ${FILEBIN_DIR}/git-hooks/post-merge ${FILEBIN_HOME_DIR}/add_user.sh fi cd $FILEBIN_DIR/public_html php -S 0.0.0.0:8080