Skip to content

Instantly share code, notes, and snippets.

@kyletaylored
Last active October 18, 2018 14:32
Show Gist options
  • Save kyletaylored/9ad838940180b8efb0b3aecfa6f54827 to your computer and use it in GitHub Desktop.
Save kyletaylored/9ad838940180b8efb0b3aecfa6f54827 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 [email protected]: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}.dave/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
@kyletaylored
Copy link
Author

Had to change .dev to .dave because Chrome forces all .dev domains to use HTTPS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment