Instantly share code, notes, and snippets.

Embed
What would you like to do?
A function, when added to bash profile, clones the Vagrant Drupal-Dev-VM (https://github.com/geerlingguy/drupal-dev-vm), augments configuration (based on d7 or d8), renames the VM to something other than drupaltest.dev and starts vagrant up. Uses include <newd 7 my-drupal-site> and <newd 8 my-other-drupal-site>.
# new drupal vagrant install
# A function, when added to bash profile, clones the Vagrant Drupal-Dev-VM (https://github.com/geerlingguy/drupal-dev-vm),
# augments config (based on d7 or d8), renames the VM to something other than drupaltest.dev and starts vagrant up. Uses
# include <newd 7 my-drupal-site> and <newd 8 my-other-drupal-site>.
function newd {
if [ $2 == ]; then
echo 'USAGE: newd8 <version> <sitename>'
elif [[ -d ~/vagrant/$2 ]]; then
echo "Nope that folder $2 already exists. Choose another or delete it"
else
echo 'Cloing repo'
cd ~/vagrant
git clone https://github.com/geerlingguy/drupal-dev-vm.git $2
cd -
cd ~/vagrant/$2
echo 'Renaming example files'
mv example.drupal.make.yml drupal.make.yml
mv example.config.yml config.yml
echo 'Ansible about to nstall requirements'
sudo ansible-galaxy install -r requirements.txt
cd -
# Change to D7
if [[ $1 == 7 ]]; then
echo 'Changing config files for Drupal 7 install'
cd ~/vagrant/$2
sed -i 's/core\: 8.x/core\: 7.x/' drupal.make.yml
sed -i 's/version\: 8.0.x/version: 7.x/' drupal.make.yml
sed -i 's/drupal_major_version\: 8/drupal_major_version\: 7/' config.yml
cd -
fi
# Change drupal.dev to <project>.dev ($2)
cd ~/vagrant/$2
sed -i s/drupaltest.dev/$2.dev/ config.yml
sed -i s/drupaltest.dev/$2.dev/ README.md
sed -i s/\/Sites\/drupal/vagrant\/$2/www
cd -
# vagrant up
mkdir -p ~/Sites/drupal
cd ~/vagrant/$2
vagrant up
fi
}
@geerlingguy

This comment has been minimized.

Copy link

geerlingguy commented Aug 3, 2015

FYI, lines 45-46 (and this Gist's description) needs to be updated to use drupalvm.dev to work correctly now.

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