<commit_before>#!/bin/sh

#
# Fully initialise/configure Flow/Neos app
#
set -e
set -u

source ./include-functions-common.sh
source ./include-functions.sh
source ./include-variables.sh

# Internal variables - there is no need to change them
CWD=$(pwd) # Points to /build-typo3-app/ directory, where this script is located
WEB_SERVER_ROOT="/data/www"
SURF_ROOT="${WEB_SERVER_ROOT}/${T3APP_NAME}/surf"
APP_ROOT="${WEB_SERVER_ROOT}/${T3APP_NAME}"
if [ "${T3APP_USE_SURF_DEPLOYMENT^^}" = TRUE ]; then
  APP_ROOT="${SURF_ROOT}/releases/current"
fi
SETTINGS_SOURCE_FILE="${CWD}/Settings.yaml"
VHOST_SOURCE_FILE="${CWD}/vhost.conf"
VHOST_FILE="/data/conf/nginx/hosts.d/${T3APP_NAME}.conf"
VHOST_SURF_SOURCE_FILE="${CWD}/vhost-surf.conf"
VHOST_SURF_FILE="/data/conf/nginx/hosts.d/${T3APP_NAME}-surf.conf"
MYSQL_CMD_PARAMS="-u$T3APP_DB_USER -p$T3APP_DB_PASS -h $T3APP_DB_HOST -P $T3APP_DB_PORT"
CONTAINER_IP=$(ip -4 addr show eth0 | grep inet | cut -d/ -f1 | awk '{print $2}')
BASH_RC_FILE="$WEB_SERVER_ROOT/.bash_profile"
BASH_RC_SOURCE_FILE="$CWD/.bash_profile"


# Configure some environment aspects (PATH, /etc/hosts, 'www' user profile etc)
configure_env
configure_ssh_key_for_www_user

#
# Flow/Neos app installation
#
install_typo3_app
cd $APP_ROOT

# Use provided by user T3APP_INSTALLATION_TYPE or detect it
INSTALLATION_TYPE=${T3APP_INSTALLATION_TYPE:-$(detect_installation_type)}
log "Detected installation type: ${INSTALLATION_TYPE^^}."

wait_for_db

hook_user_build_script --post-install

#
# Regular Flow/Neos app initialisation
#
if [ "${T3APP_DO_INIT^^}" = TRUE ]; then
  log "Configuring ${INSTALLATION_TYPE^^} app..." && log

  create_app_db $T3APP_DB_NAME
  create_settings_yaml "Configuration/Settings.yaml"
  update_settings_yaml "Configuration/Settings.yaml" $T3APP_DB_NAME
  # Production/Settings.yaml is essential when using Surf deployment
  if [ "${T3APP_USE_SURF_DEPLOYMENT^^}" = TRUE ]; then
    create_settings_yaml "Configuration/Production/Settings.yaml"
  fi
  # Only update if they exist...
  update_settings_yaml "Configuration/Production/Settings.yaml" $T3APP_DB_NAME
  update_settings_yaml "Configuration/Development/Settings.yaml" $T3APP_DB_NAME

  # DB migration: where are we? Also export it so site build script can access to that info.
  log "DB status: checking migration status..."
  executed_migrations=$(get_db_executed_migrations)
  export RUNTIME_EXECUTED_MIGRATIONS=$executed_migrations
  log "DB status: $executed_migrations migrations executed."

  hook_user_build_script --post-settings

  if [[ $(./flow help | grep "database:setcharset") ]]; then # Only run if this command is available (not in Flow < 3.0)
    ./flow database:setcharset
  fi
  # Only proceed with doctrine:migration if it is a fresh installation...
  if [[ $executed_migrations == 0 ]]; then
    log "Fresh ${INSTALLATION_TYPE^^} installation detected: making DB migration:"
    doctrine_update
  else
    log "${INSTALLATION_TYPE^^} app database already provisioned, skipping..."
  fi

  hook_user_build_script --post-db-migration

  # Neos CMS steps only:
  if [[ $INSTALLATION_TYPE == "neos" ]]; then<commit_msg>Fix: hook `--post-settings` should be after all settings has been done<commit_after>#!/bin/sh

#
# Fully initialise/configure Flow/Neos app
#
set -e
set -u

source ./include-functions-common.sh
source ./include-functions.sh
source ./include-variables.sh

# Internal variables - there is no need to change them
CWD=$(pwd) # Points to /build-typo3-app/ directory, where this script is located
WEB_SERVER_ROOT="/data/www"
SURF_ROOT="${WEB_SERVER_ROOT}/${T3APP_NAME}/surf"
APP_ROOT="${WEB_SERVER_ROOT}/${T3APP_NAME}"
if [ "${T3APP_USE_SURF_DEPLOYMENT^^}" = TRUE ]; then
  APP_ROOT="${SURF_ROOT}/releases/current"
fi
SETTINGS_SOURCE_FILE="${CWD}/Settings.yaml"
VHOST_SOURCE_FILE="${CWD}/vhost.conf"
VHOST_FILE="/data/conf/nginx/hosts.d/${T3APP_NAME}.conf"
VHOST_SURF_SOURCE_FILE="${CWD}/vhost-surf.conf"
VHOST_SURF_FILE="/data/conf/nginx/hosts.d/${T3APP_NAME}-surf.conf"
MYSQL_CMD_PARAMS="-u$T3APP_DB_USER -p$T3APP_DB_PASS -h $T3APP_DB_HOST -P $T3APP_DB_PORT"
CONTAINER_IP=$(ip -4 addr show eth0 | grep inet | cut -d/ -f1 | awk '{print $2}')
BASH_RC_FILE="$WEB_SERVER_ROOT/.bash_profile"
BASH_RC_SOURCE_FILE="$CWD/.bash_profile"


# Configure some environment aspects (PATH, /etc/hosts, 'www' user profile etc)
configure_env
configure_ssh_key_for_www_user

#
# Flow/Neos app installation
#
install_typo3_app
cd $APP_ROOT

# Use provided by user T3APP_INSTALLATION_TYPE or detect it
INSTALLATION_TYPE=${T3APP_INSTALLATION_TYPE:-$(detect_installation_type)}
log "Detected installation type: ${INSTALLATION_TYPE^^}."

wait_for_db

hook_user_build_script --post-install

#
# Regular Flow/Neos app initialisation
#
if [ "${T3APP_DO_INIT^^}" = TRUE ]; then
  log "Configuring ${INSTALLATION_TYPE^^} app..." && log

  create_app_db $T3APP_DB_NAME
  create_settings_yaml "Configuration/Settings.yaml"
  update_settings_yaml "Configuration/Settings.yaml" $T3APP_DB_NAME
  # Production/Settings.yaml is essential when using Surf deployment
  if [ "${T3APP_USE_SURF_DEPLOYMENT^^}" = TRUE ]; then
    create_settings_yaml "Configuration/Production/Settings.yaml"
  fi
  # Only update if they exist...
  update_settings_yaml "Configuration/Production/Settings.yaml" $T3APP_DB_NAME
  update_settings_yaml "Configuration/Development/Settings.yaml" $T3APP_DB_NAME

  hook_user_build_script --post-settings

  # DB migration: where are we? Also export it so site build script can access to that info.
  log "DB status: checking migration status..."
  executed_migrations=$(get_db_executed_migrations)
  export RUNTIME_EXECUTED_MIGRATIONS=$executed_migrations
  log "DB status: $executed_migrations migrations executed."

  if [[ $(./flow help | grep "database:setcharset") ]]; then # Only run if this command is available (not in Flow < 3.0)
    ./flow database:setcharset
  fi
  # Only proceed with doctrine:migration if it is a fresh installation...
  if [[ $executed_migrations == 0 ]]; then
    log "Fresh ${INSTALLATION_TYPE^^} installation detected: making DB migration:"
    doctrine_update
  else
    log "${INSTALLATION_TYPE^^} app database already provisioned, skipping..."
  fi

  hook_user_build_script --post-db-migration

  # Neos CMS steps only:
  if [[ $INSTALLATION_TYPE == "neos" ]]; then
{'fraction_non_alphanumeric': 0.12074156235144985, 'fraction_numerical': 0.008239581682776106, 'mean_word_length': 5.312, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3310511', 'n_tokens_mistral': 2227, 'n_tokens_neox': 2160, 'n_words': 499}