Skip to content

Instantly share code, notes, and snippets.

@teknikqa
Forked from kyletaylored/drupalvm-setup.sh
Created January 7, 2018 13:35
Show Gist options
  • Save teknikqa/1a55beb77bb73bee243a7a09d8400e27 to your computer and use it in GitHub Desktop.
Save teknikqa/1a55beb77bb73bee243a7a09d8400e27 to your computer and use it in GitHub Desktop.
A shell script to help set up a standard DrupalVM project
#!/bin/bash
# Get project directory and git url
echo "Project code (used for project directory name):"
read project_code
echo "Project repo git url (can be blank):"
read project_git_url
# Clone DrupalVM
git clone git@github.com:geerlingguy/drupal-vm.git $project_code
cd $project_code
# Copy default.config.yml to start altering values
cp default.config.yml config.yml
# Replace config file values.
sed -in "s/^vagrant_hostname.*/vagrant_hostname: ${project_code}.dev/1" config.yml
sed -in "s/^vagrant_machine_name.*/vagrant_machine_name: ${project_code}/1" config.yml
sed -in "s/^vagrant_ip.*/vagrant_ip: 0.0.0.0/1" config.yml
# Assumed most projects aren't Composer based.
sed -in "s/^drupal_build_composer_project.*/drupal_build_composer_project: false/1" config.yml
# Don't run a fresh Drupal build
sed -in "s/^drupal_install_site.*/drupal_install_site: false/1" config.yml
read -r -p "Is this an Acquia project? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]];
then
sed -in "s%^drupal_core_path.*%drupal_core_path: \"{{ drupal_composer_install_dir }}/web/docroot\"%1" config.yml
fi
read -r -p "Is this a Drupal 7 project? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]];
then
# Downgrade Solr version (at least for D7), incompatible with Search API.
# https://www.drupal.org/node/1999310
sed -in "s/^solr_version.*/solr_version: \"5.4.1\"/1" config.yml
# Downgrade PHP to 5.6
sed -in "s/^php_version.*/php_version: \"5.6\"/1" config.yml
fi
# Create the source directory and clone if available.
if [ -z "$project_git_url" ]
then
echo "No repo supplied, skipping..."
else
mkdir -p drupal
cd drupal
git clone $project_git_url web
cd ../
fi
# Install Vagrant plugins
vagrant plugin install vagrant-auto_network
# The following are no longer needed, now autoinstalled by DrupalVM.
#vagrant plugin install vagrant-hostsupdater
#vagrant plugin install vagrant-vbguest
# Set up vagrant server.
vagrant up --provision
vagrant ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment