#!/usr/bin/env bash
# Install the Drupal site.
#: exec_target = cli

# Database for the drush command.
DB_URL="mysql://${DATABASE_USER:-user}:${DATABASE_PASSWORD:-user}@${DATABASE_HOST:-db}/${DATABASE_NAME:-default}"

# Install Drupal site
if [ -e "${CONFIG_PATH}/default/system.site.yml" ]; then
  # If config exists, install using it.
  printf "$INFO_SLUG Installing Drupal from existing config...\n"
  drush si --db-url=$DB_URL --account-pass="admin" ${PROFILE} --existing-config -y
else
  # Otherwise install clean from profile.
  printf "$INFO_SLUG Installing Drupal profile: ${PROFILE}...\n"
  drush si --db-url=$DB_URL --account-pass="admin" ${PROFILE} -y
fi
