Last active
October 18, 2018 14:32
-
-
Save kyletaylored/9ad838940180b8efb0b3aecfa6f54827 to your computer and use it in GitHub Desktop.
A shell script to help set up a standard DrupalVM project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
I've been having an issue with characters being added to the config.yml file using sed
. In order to edit the single file without a copy, we use the -i
or --in-place
flag to edit the stream. The problem is, the core sed
program on OSX expects a secondary parameter to add a suffix to the file (which causes n
or -n
to be added).
I updated this to work with the GNU version of sed, so if you're using this on a Mac, you need to install gnu-sed
using Homebrew and alias that to sed
.
brew install gnu-sed
echo 'alias sed=gsed' >> ~/.bash_profile
More info on Stackoverflow: sed command with -i option failing on Mac
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
Changed delimiter on Acquia line as to not trigger a regex (or whatever was breaking)