Skip to content

Instantly share code, notes, and snippets.

@Mte90 Mte90/Customfile
Last active Jan 15, 2020

Embed
What would you like to do?
2 new commands for VVV
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
You can’t perform that action at this time.