ievms-ruby
Ruby interface for boxes made by ievms.sh. Use this Library to provision your IE boxes from https://modern.ie.
Next to ievms.sh, ievms-ruby
also works great in combination with iectrl.
WinBoxes supported
Features
- Upload files to guest machine
- Download file from guest machine
- Execute cmd.exe and powershell commands on guest machine
- Execute cmd.exe and powershell commands on guest machine as admin
- Cat file guest machine from cli
Requirements
- VirtualBox >= 5.0.6
- VirtualBox Extension Pack and Guest Additions >= 5.0.6
- Host Machine: OSX or Linux (only tested on OSX 10.9 & 10.10)
- Virtual Machines created by .ievms (only tested with vanilla Win7 machines)
Usage
As library
Use Ievms-ruby in provisioning scripts for windows E.g. for CI. Here’s an example provisioning script using the Gem. It installs Chocolatey, Ruby, and git-for-windows without user interaction needed.
Add this line to your application’s Gemfile:
ruby
gem 'ievms-ruby'
run bundle install
```ruby #!/usr/bin/env ruby require ‘rubygems’ require ‘bundler/setup’ require ‘ievms/windows_guest’
class ProvisionIE
# Create interface for the ‘IE9 - Win7’ virtual box def init @machine = Ievms::WindowsGuest.new ‘IE9 - Win7’ end
# Install the choco package manager (APT for Windows) def install_chocolatey print “Installing Chocolatey\n” choco_install_cmd = ‘@powershell -NoProfile -ExecutionPolicy unrestricted -Command “iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))” && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin ‘ @machine.run_command_as_admin(choco_install_cmd) end
# Install ruby and git stuff, the reason why we wrote ievms-ruby def install_ruby_and_git %w( ruby msysgit ).each do |pkg| @machine.run_command_as_admin “c:\ProgramData\chocolatey\bin\choco install -y #pkg” end end end
provision = ProvisionIE.new provision.init provision.install_chocolatey provision.install_ruby_and_git ```
From CLI
Install the Gem on your system:
$ gem install ievms-ruby
After installation you can use the ievmsrb
cli program.
ievmsrb commands
```bash $ ievmsrb help
Commands: ievmsrb cat [vbox name] [file path] # cat file from path in Win vbox ievmsrb cmd [vbox name] [command to execute] # Run command with cmd.exe in Win vbox ievmsrb copy_from [vbox name] [path in vbox] [local file] # Copy file from Win vbox to local path ievmsrb copy_to [vbox name] [local file] [path in vbox] # Copy local file to Win vbox ievmsrb help [COMMAND] # Describe available commands or one specific command ievmsrb ps [vbox name] # Show running tasks in Win vbox ievmsrb reboot [vbox name] # Reboot Win box ievmsrb shutdown [vbox name] # Shutdown Win vbox ```
ievmsrb examples
Display the contents of a guest file.
bash
$ ievmsrb cat "IE9 - Win7" 'C:\Windows\System32\Drivers\Etc\hosts'
Execute a cmd on the guestmachine and show the output
bash
$ ievmsrb cmd "IE9 - Win7" 'tasklist'
Copy a file from the Windows Guest to a local path
bash
$ ievmsrb copy_from "IE9 - Win7" 'C:\Windows\System32\Drivers\Etc\hosts' ~/Desktop/hosts.win9
Turn of the Filewall executing a command as Administator
bash
$ ievmsrb cmd_adm "IE9 - Win7" 'NetSh Advfirewall set allprofiles state off'
Contributing
Please submit a new ticket if you want to report an issue.
Merge requests are welcome. See issues with Help Wanted
label.
Testing
To run the tests you need top fullfil the testing requirements first:
- VirtualBox >= 5.0.4
- “IE9 - Win7” installed by ievms.sh
- Create an new virtual machine called
standbymachine
. Keep the disk size as small as possible. It should be turned off.
git clone https://github.com/mipmip/ievms-ruby.git
cd ievms-ruby
bundle install
bundle exec rake
Merge Requests
- Fork it ( https://github.com/mipmip/ievms-ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Troubleshooting
- If tests fail check if virtualbox guest additions 5.0.6 or higher are installed
Acknowledgements
- ievms - Provider of a platform and methology
- modern.IE - Provider of IE VM images.
- virtualbox - Software for running Virtual Machines
- shields.io - Creates the beautiful Windows Badges