A Customfile for VVV to auto-create synced folders for specific VVV site and bash file to convert shared folder to symlinks.
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
config.vm.provider :virtualbox do |v| | |
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] | |
#v.memory = 2048 | |
end | |
# config.vm.synced_folder "/Users/afragen/Documents/github/github-updater", "/srv/www/test3/htdocs/wp-content/plugins/github-updater", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ] | |
vvvsites = [ | |
'multi-test', | |
'single-test', | |
] | |
git_plugins = [ | |
'add-custom-header-images', | |
'airplane-mode', | |
'category-colors-options', | |
'drmc-medical-staff-governance', | |
'embed-pdf-viewer', | |
'github-updater', | |
'github-updater-additions', | |
'local-development', | |
'losrobles-governance', | |
'pods', | |
'resend-welcome-email', | |
'the-events-calendar-category-colors', | |
'the-events-calendar-pro-alarm', | |
'the-events-calendar-user-css', | |
'wp-install-dependencies', | |
'wp-polls', | |
] | |
git_themes = [ | |
'losrobles-theme', | |
] | |
localgit = '/Users/afragen/Documents/github/' | |
localvagrant = '/Users/afragen/vagrant-local/www/' | |
vvvsites.each do |site| | |
git_repos = {} | |
plugins_path = '/srv/www/' + site + '/htdocs/wp-content/plugins/' | |
themes_path = '/srv/www/' + site + '/htdocs/wp-content/themes/' | |
git_plugins.each do |plugin| | |
git_repos.merge!( localgit + plugin => plugins_path + plugin ) | |
end | |
git_themes.each do |theme| | |
git_repos.merge!( localgit + theme => themes_path + theme ) | |
end | |
git_repos.each do |local, vvv| | |
config.vm.synced_folder local, vvv, :owner => 'www-data', :mount_options => [ 'dmode=775', 'fmode=774' ] | |
end | |
end | |
# Remove all synched folders at startup. | |
# This seems to run first. | |
# Unfortunately also runs with `vagrant ssh`, etc. | |
vvvsites.each do |site| | |
plugins_localpath = localvagrant + site + '/htdocs/wp-content/plugins/' | |
themes_localpath = localvagrant + site + '/htdocs/wp-content/themes/' | |
vagrant_shared_folders = [] | |
git_plugins.each do |plugin| | |
vagrant_shared_folders.push( plugins_localpath + plugin ) | |
end | |
git_themes.each do |theme| | |
vagrant_shared_folders.push( themes_localpath + theme ) | |
end | |
vagrant_shared_folders.each do |folder| | |
if File.symlink?( folder ) | |
%x[rm -r #{folder}] | |
end | |
end | |
end |
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 | |
# Use `./vagrant_symlink.sh link` to add symlinks, | |
# Calling script without a parameter will just delete all symlinks | |
if test -n "$1"; then | |
param="link" | |
else | |
param=false | |
fi | |
vvvsites=( | |
'multi-test' | |
'single-test' | |
) | |
git="/Users/afragen/Documents/github" | |
vagrant_path="/Users/afragen/vagrant-local/www" | |
vagrant_plugin_path="htdocs/wp-content/plugins" | |
vagrant_theme_path="htdocs/wp-content/themes" | |
git_plugins=( | |
'add-custom-header-images' | |
'airplane-mode' | |
'category-colors-options' | |
'drmc-medical-staff-governance' | |
'embed-pdf-viewer' | |
'github-updater' | |
'github-updater-additions' | |
'local-development' | |
'losrobles-governance' | |
'pods' | |
'resend-welcome-email' | |
'the-events-calendar-category-colors' | |
'the-events-calendar-pro-alarm' | |
'the-events-calendar-user-css' | |
'wp-install-dependencies' | |
'wp-polls' | |
) | |
git_themes=( | |
'losrobles-theme' | |
) | |
for j in ${vvvsites[@]}; do | |
for i in ${git_plugins[@]}; do | |
if [ -e $vagrant_path/${j}/${vagrant_plugin_path}/${i} ]; then | |
rm -r $vagrant_path/${j}/${vagrant_plugin_path}/${i} | |
fi | |
if [ "link" == $param ]; then | |
ln -s $git/${i} $vagrant_path/${j}/${vagrant_plugin_path} | |
fi | |
done | |
for i in ${git_themes[@]}; do | |
if [ -e $vagrant_path/${j}/${vagrant_theme_path}/${i} ]; then | |
rm -r $vagrant_path/${j}/${vagrant_theme_path}/${i} | |
fi | |
if [ "link" == $param ]; then | |
ln -s $git/${i} $vagrant_path/${j}/${vagrant_theme_path} | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment