Split Docksal init command
This commit is contained in:
parent
d634b835f8
commit
8c7752cf43
|
@ -1,37 +1,37 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
## Initialise the project
|
## Initialize stack and site (full reset)
|
||||||
##
|
##
|
||||||
## Usage: fin init
|
## Usage: fin init
|
||||||
|
|
||||||
fin start
|
# Abort if anything fails
|
||||||
|
set -e
|
||||||
|
|
||||||
fin run composer install
|
#-------------------------- Helper functions --------------------------------
|
||||||
|
|
||||||
# Overwrite settings.php.
|
# Console colors
|
||||||
cp ../files/settings.php ../../web/sites/default
|
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.
|
#-------------------------- Execution --------------------------------
|
||||||
fin drush config:set -y system.site uuid de7ba5dc-5795-4cb5-9d38-1edcc27be491
|
|
||||||
|
|
||||||
# Delete the uuid for shortcut.set.default so that config will import.
|
# Stack initialization
|
||||||
fin drush config:delete -y shortcut.set.default uuid
|
echo -e "${green_bg} Step 1 ${NC}${green} Initializing stack...${NC}"
|
||||||
|
fin project reset -f
|
||||||
|
|
||||||
# Import config.
|
# Site initialization
|
||||||
fin drush config:import -y --source=../config/sync
|
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()'
|
echo -e "${green_bg} DONE! ${NC}${green} Completed all initialization steps.${NC}"
|
||||||
fin drush php:eval '\Drupal::service("Drupal\dtc_import\Service\Importer\CsvSessionImporter")->import()'
|
|
||||||
|
|
||||||
fin drush user:create api --password=api
|
#-------------------------- END: Execution --------------------------------
|
||||||
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
|
|
||||||
|
|
82
drupal/.docksal/commands/init-site
Executable file
82
drupal/.docksal/commands/init-site
Executable 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 --------------------------------
|
Loading…
Reference in a new issue