Sha256: 11cf89a4d5cc150ddcbed0edd056eb0897beeb7c0580521cc8e5225b24af7953

Contents?: true

Size: 1.3 KB

Versions: 31

Compression:

Stored size: 1.3 KB

Contents

module Vagrant
  module Provisioners
    class Shell < Base
      register :shell

      class Config < Vagrant::Config::Base
        attr_accessor :path
        attr_accessor :upload_path

        def initialize
          @upload_path = "/tmp/vagrant-shell"
        end

        def expanded_path
          Pathname.new(path).expand_path(env.root_path) if path
        end

        def validate(errors)
          super

          if !path
            errors.add(I18n.t("vagrant.provisioners.shell.path_not_set"))
          elsif !expanded_path.file?
            errors.add(I18n.t("vagrant.provisioners.shell.path_invalid", :path => expanded_path))
          end

          if !upload_path
            errors.add(I18n.t("vagrant.provisioners.shell.upload_path_not_set"))
          end
        end
      end

      def provision!
        commands = ["chmod +x #{config.upload_path}", config.upload_path]

        # Upload the script to the VM
        vm.ssh.upload!(config.expanded_path.to_s, config.upload_path)

        # Execute it with sudo
        vm.ssh.execute do |ssh|
          ssh.sudo!(commands) do |ch, type, data|
            if type == :exit_status
              ssh.check_exit_status(data, commands)
            else
              env.ui.info(data)
            end
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 5 rubygems

Version Path
vagrantup-0.7.8 lib/vagrant/provisioners/shell.rb
vagrantup-0.7.7 lib/vagrant/provisioners/shell.rb
vagrantup-0.7.6 lib/vagrant/provisioners/shell.rb
vagrantup-0.7.5 lib/vagrant/provisioners/shell.rb
vagrantup-0.7.4 lib/vagrant/provisioners/shell.rb
vagrantup-0.7.3 lib/vagrant/provisioners/shell.rb
vagrantup-0.7.2 lib/vagrant/provisioners/shell.rb
vagrantup-0.7.1 lib/vagrant/provisioners/shell.rb
vagrant-0.7.8 lib/vagrant/provisioners/shell.rb
vagrant-0.7.7 lib/vagrant/provisioners/shell.rb
vagrant-0.7.6 lib/vagrant/provisioners/shell.rb
vagrant-0.7.5 lib/vagrant/provisioners/shell.rb
vagrant-0.7.4 lib/vagrant/provisioners/shell.rb
fixed-vagrant-0.7.4.dev lib/vagrant/provisioners/shell.rb
vagrant-0.7.3 lib/vagrant/provisioners/shell.rb
mccloud-0.0.13 lib/mccloud/provisioner/vagrant/shell.rb
mccloud-0.0.12 lib/mccloud/provisioner/vagrant/shell.rb
mccloud-0.0.11 lib/mccloud/provisioner/vagrant/shell.rb
mccloud-0.0.10 lib/mccloud/provisioner/vagrant/shell.rb
mccloud-0.0.9 lib/mccloud/provisioner/vagrant/shell.rb