Based on Varying-Vagrant-Vagrants/VVV#2005 this enable 2 new commands inside Vagrant.
2 new commands for VVV
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
class VVVScripts < Vagrant.plugin(2, :command) | |
def self.synopsis | |
"Execute script from /config/homebin/" | |
end | |
def execute | |
with_target_vms(nil, single_target: true) do |vm| | |
@env.ui.output "#{$yellow}Executing #{$red}#{ARGV[1]}#{$creset}\n" | |
vm.action(:ssh_run, ssh_run_command: "/srv/config/homebin/#{ARGV[1]}" ) | |
end | |
end | |
end | |
class VVVCommand < Vagrant.plugin(2, :command) | |
def self.synopsis | |
"Execute custom command inside site folder" | |
end | |
def execute | |
vm_dir = "/srv/www/#{ARGV[1]}/public_html" | |
$vvv_config['sites'].each do |site, args| | |
if site == ARGV[1] | |
vm_dir = args['vm_dir'] | |
end | |
end | |
with_target_vms(nil, single_target: true) do |vm| | |
@env.ui.output "#{$yellow}Executing in #{$red}#{ARGV[1]}#{$yellow}: #{$red}#{ARGV[2]}#{$creset}\n" | |
vm.action(:ssh_run, ssh_run_command: "cd #{$vm_dir}; #{ARGV[2]}") | |
end | |
end | |
end | |
class VVVPlugin < Vagrant.plugin(2) | |
name "VVV commands" | |
command "script" do | |
VVVScripts | |
end | |
command "command" do | |
VVVCommand | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment