Skip to content

Instantly share code, notes, and snippets.

@Mte90
Last active December 10, 2021 14:55
Show Gist options
  • Save Mte90/9810f7c2775f1fd79ee049b3d259dff0 to your computer and use it in GitHub Desktop.
Save Mte90/9810f7c2775f1fd79ee049b3d259dff0 to your computer and use it in GitHub Desktop.
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