Class: VagrantPlugins::Shell::Provisioner
- Inherits:
-
Object
- Object
- VagrantPlugins::Shell::Provisioner
- Includes:
- VagrantWindows::Helper
- Defined in:
- lib/vagrant-windows/monkey_patches/plugins/provisioners/shell/provisioner.rb
Instance Method Summary collapse
Methods included from VagrantWindows::Helper
#wait_if_rebooting, #win_friendly_path, #win_friendly_share_id
Instance Method Details
#provision_on_windows ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/vagrant-windows/monkey_patches/plugins/provisioners/shell/provisioner.rb', line 18 def provision_on_windows args = "" args = " #{config.args}" if config.args windows_machine = VagrantWindows::WindowsMachine.new(@machine) wait_if_rebooting(windows_machine) with_windows_script_file do |path| # Upload the script to the machine @machine.communicate.tap do |comm| # Ensure the uploaded script has a file extension, by default # config.upload_path from vagrant core does not fixed_upload_path = if File.extname(config.upload_path) == "" "#{config.upload_path}#{File.extname(path.to_s)}" else config.upload_path end comm.upload(path.to_s, fixed_upload_path) command = <<-EOH $old = Get-ExecutionPolicy; Set-ExecutionPolicy Unrestricted -force; #{win_friendly_path(fixed_upload_path)}#{args}; Set-ExecutionPolicy $old -force EOH # Execute it with sudo comm.sudo(command) do |type, data| if [:stderr, :stdout].include?(type) # Output the data with the proper color based on the stream. color = type == :stdout ? :green : :red @machine.ui.info( data, :color => color, :new_line => false, :prefix => false) end end end end end |