Skip to content

Instantly share code, notes, and snippets.

@nateswart
Created June 5, 2015 14:37
Show Gist options
  • Save nateswart/f59e765a5dce45ab7fde to your computer and use it in GitHub Desktop.
Save nateswart/f59e765a5dce45ab7fde to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Get passed in arguments
projectName = ARGV[0]
drupalVersion = ARGV[1]
vmRepo = 'https://github.com/geerlingguy/drupal-vm.git'
baseDirectory = '/#{Dir.home}/Sites/'
vmDirectory = baseDirectory + projectName + '_vm/'
projectDirectory = baseDirectory + projectName + '/'
# Clone DrupalVM to ~/Sites/mysite_vm
gitClone = 'git clone ' + vmRepo + ' ' + vmDirectory
system gitClone
# Create ~/Sites/mysite
makeDir = 'mkdir ' + projectDirectory
system makeDir
# Copy default config files to real config files
config = 'cp ' + vmDirectory + 'example.config.yml ' + vmDirectory + 'config.yml'
system config
drupalConfig = 'cp ' + vmDirectory + 'example.drupal.make.yml ' + vmDirectory + 'drupal.make.yml'
system drupalConfig
# Customize config.yml
require 'yaml'
config = YAML.load_file(vmDirectory + 'config.yml')
config['vagrant_hostname'] = projectName + '.dev'
config['vagrant_synced_folders'][0]['local_path'] = projectDirectory
config['drupal_domain'] = projectName + '.dev'
config['drupal_site_name'] = projectName
config['apache_vhosts'][1]['servername'] = 'xhprof.' + projectName + '.dev'
config['apache_vhosts'][2]['servername'] = 'pimpmylog.' + projectName + '.dev'
File.open(vmDirectory + 'config.yml','w') do |h|
h.write config.to_yaml
end
# Customize drupal.make.yml
case drupalVersion
when 'd7'
core = '7.x'
branch = '7.x'
when 'd8'
core = '8.x'
branch = '8.0.x'
else
core = '7.x'
branch = '7.x'
end
drupal = YAML.load_file(vmDirectory + 'drupal.make.yml')
drupal['core'] = core
drupal['projects']['drupal']['download']['branch'] = branch
File.open(vmDirectory + 'drupal.make.yml','w') do |h|
h.write drupal.to_yaml
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment