Skip to content

Instantly share code, notes, and snippets.

@sebastianwestberg
Forked from rgoodie/new-drupal-dev-vm.sh
Last active January 23, 2017 23:43
Show Gist options
  • Save sebastianwestberg/876ec49e9ac840641ade to your computer and use it in GitHub Desktop.
Save sebastianwestberg/876ec49e9ac840641ade to your computer and use it in GitHub Desktop.
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 drupalvm.dev and starts vagrant up. uses
# include <newd 7 my-drupal-site> and <newd 8 my-other-drupal-site>.
function newd {
if [ -z "$2" ]; then
echo 'usage: newd <version> <sitename>'
elif [[ -d ~/vagrant/$2 ]]; then
echo "nope that folder $2 already exists. choose another or delete it"
else
echo 'cloning 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 install requirements'
sudo ansible-galaxy install -r provisioning/requirements.yml
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)
echo 'replace drupalvm.dev with new host'
cd ~/vagrant/$2
sed -i '' s/drupalvm.dev/$2.dev/g config.yml
sed -i '' s/drupalvm.dev/$2.dev/g readme.md
sed -i '' s/\/sites\/drupal/vagrant\/$2/www
cd -
# vagrant up
mkdir -p ~/sites/drupal
cd ~/vagrant/$2
vagrant up
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment