Split Docksal init command

This commit is contained in:
Oliver Davies 2019-06-05 21:29:17 +01:00
parent d634b835f8
commit 8c7752cf43
2 changed files with 106 additions and 24 deletions

View file

@ -1,37 +1,37 @@
#!/usr/bin/env bash
## Initialise the project
## Initialize stack and site (full reset)
##
## Usage: fin init
fin start
# Abort if anything fails
set -e
fin run composer install
#-------------------------- Helper functions --------------------------------
# Overwrite settings.php.
cp ../files/settings.php ../../web/sites/default
# Console colors
red='\033[0;31m'
green='\033[0;32m'
green_bg='\033[1;97;42m'
yellow='\033[1;33m'
NC='\033[0m'
fin drush site:install -y
echo-red () { echo -e "${red}$1${NC}"; }
echo-green () { echo -e "${green}$1${NC}"; }
echo-green-bg () { echo -e "${green_bg}$1${NC}"; }
echo-yellow () { echo -e "${yellow}$1${NC}"; }
# Reset the site uuid.
fin drush config:set -y system.site uuid de7ba5dc-5795-4cb5-9d38-1edcc27be491
#-------------------------- Execution --------------------------------
# Delete the uuid for shortcut.set.default so that config will import.
fin drush config:delete -y shortcut.set.default uuid
# Stack initialization
echo -e "${green_bg} Step 1 ${NC}${green} Initializing stack...${NC}"
fin project reset -f
# Import config.
fin drush config:import -y --source=../config/sync
# Site initialization
echo -e "${green_bg} Step 2 ${NC}${green} Initializing site...${NC}"
# This runs inside cli using http://docs.docksal.io/en/v1.4.0/fin/custom-commands/#executing-commands-inside-cli
fin init-site
fin drush php:eval '\Drupal::service("Drupal\dtc_import\Service\Importer\CsvSpeakerImporter")->import()'
fin drush php:eval '\Drupal::service("Drupal\dtc_import\Service\Importer\CsvSessionImporter")->import()'
echo -e "${green_bg} DONE! ${NC}${green} Completed all initialization steps.${NC}"
fin drush user:create api --password=api
fin drush user:role:add api_user api
# Set uuid for admin user.
fin drush sql:query "UPDATE users SET uuid = '11dad4c2-baa8-4fb2-97c6-12e1ce925806' WHERE uid = 1"
# Set uuid for API user.
fin drush sql:query "UPDATE users SET uuid = '63936126-87cd-4166-9cb4-63b61a210632' WHERE uid = 7"
fin uli
#-------------------------- END: Execution --------------------------------

View file

@ -0,0 +1,82 @@
#!/usr/bin/env bash
#: exec_target = cli
## Initialize/reinstall site
##
## Usage: fin init-site
# Abort if anything fails
set -e
#-------------------------- Helper functions --------------------------------
copy_settings_file() {
local source="$1"
local dest="$2"
echo "Copying ${dest}..."
cp $source $dest
}
composer_install() {
echo "Installing Composer dependencies..."
composer install
}
#-------------------------- END: Helper functions --------------------------------
#-------------------------- END: Functions --------------------------------
init_settings() {
copy_settings_file ../files/settings.php ../../web/sites/default
}
site_install() {
composer_install
echo "Installing Drupal..."
drush site:install -y
}
import_config() {
drush config:set -y system.site uuid de7ba5dc-5795-4cb5-9d38-1edcc27be491
drush config:delete -y shortcut.set.default uuid
echo "Importing configuration..."
drush config:import -y --source=../config/sync
}
import_content() {
echo "Importing speakers from CSV..."
drush php:eval '\Drupal::service("Drupal\dtc_import\Service\Importer\CsvSpeakerImporter")->import()'
echo "Importing sessions from CSV..."
drush php:eval '\Drupal::service("Drupal\dtc_import\Service\Importer\CsvSessionImporter")->import()'
}
setup_users() {
echo "Creating the API user..."
drush user:create api --password=api
drush user:role:add api_user api
echo "Resetting uuid for the admin user..."
drush sql:query "UPDATE users SET uuid = '11dad4c2-baa8-4fb2-97c6-12e1ce925806' WHERE uid = 1"
echo "Resetting uuid for the API user..."
drush sql:query "UPDATE users SET uuid = '63936126-87cd-4166-9cb4-63b61a210632' WHERE uid = 7"
}
#-------------------------- END: Functions --------------------------------
#-------------------------- Execution --------------------------------
site_install
import_config
import_content
setup_users
echo -e "Open ${yellow}http://${VIRTUAL_HOST}${NC} in your browser to verify the setup."
#-------------------------- END: Execution --------------------------------