HeSYINUvSBZfxqA-veewee 0.2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +69 -0
- data/HeSYINUvSBZfxqA-veewee.gemspec +33 -0
- data/README.md +198 -0
- data/Rakefile +92 -0
- data/bin/veewee +79 -0
- data/lib/java/README.txt +5 -0
- data/lib/java/dir2floppy.jar +0 -0
- data/lib/java/dir2floppy.java +137 -0
- data/lib/vagrant_init.rb +6 -0
- data/lib/veewee/command.rb +82 -0
- data/lib/veewee/config.rb +5 -0
- data/lib/veewee/export.rb +81 -0
- data/lib/veewee/scancode.rb +151 -0
- data/lib/veewee/session.rb +783 -0
- data/lib/veewee/shell.rb +54 -0
- data/lib/veewee/ssh.rb +193 -0
- data/lib/veewee/transaction.rb +122 -0
- data/lib/veewee/utils.rb +26 -0
- data/lib/veewee/version.rb +3 -0
- data/lib/veewee/web.rb +48 -0
- data/lib/veewee.rb +2 -0
- data/templates/CentOS-4.8-i386/definition.rb +14 -0
- data/templates/CentOS-4.8-i386/ks.cfg +45 -0
- data/templates/CentOS-4.8-i386/postinstall.sh +55 -0
- data/templates/CentOS-5.6-i386/definition.rb +17 -0
- data/templates/CentOS-5.6-i386/ks.cfg +45 -0
- data/templates/CentOS-5.6-i386/postinstall.sh +50 -0
- data/templates/CentOS-5.6-i386-netboot/definition.rb +16 -0
- data/templates/CentOS-5.6-i386-netboot/ks.cfg +45 -0
- data/templates/CentOS-5.6-i386-netboot/postinstall.sh +52 -0
- data/templates/CentOS-5.6-x86_64-netboot/definition.rb +16 -0
- data/templates/CentOS-5.6-x86_64-netboot/ks.cfg +45 -0
- data/templates/CentOS-5.6-x86_64-netboot/postinstall.sh +60 -0
- data/templates/CentOS-6.0-i386/definition.rb +17 -0
- data/templates/CentOS-6.0-i386/ks.cfg +47 -0
- data/templates/CentOS-6.0-i386/postinstall.sh +48 -0
- data/templates/CentOS-6.0-i386-netboot/definition.rb +16 -0
- data/templates/CentOS-6.0-i386-netboot/ks.cfg +52 -0
- data/templates/CentOS-6.0-i386-netboot/postinstall.sh +30 -0
- data/templates/CentOS-6.0-x86_64/definition.rb +17 -0
- data/templates/CentOS-6.0-x86_64/ks.cfg +47 -0
- data/templates/CentOS-6.0-x86_64/postinstall.sh +48 -0
- data/templates/CentOS-6.0-x86_64-netboot/definition.rb +16 -0
- data/templates/CentOS-6.0-x86_64-netboot/ks.cfg +52 -0
- data/templates/CentOS-6.0-x86_64-netboot/postinstall.sh +30 -0
- data/templates/Debian-5.0.8-amd64-netboot/definition.rb +39 -0
- data/templates/Debian-5.0.8-amd64-netboot/postinstall.sh +60 -0
- data/templates/Debian-5.0.8-amd64-netboot/preseed.cfg +312 -0
- data/templates/Debian-5.0.8-i386-netboot/definition.rb +39 -0
- data/templates/Debian-5.0.8-i386-netboot/postinstall.sh +60 -0
- data/templates/Debian-5.0.8-i386-netboot/preseed.cfg +312 -0
- data/templates/Debian-6.0.2-amd64-netboot/definition.rb +39 -0
- data/templates/Debian-6.0.2-amd64-netboot/postinstall.sh +71 -0
- data/templates/Debian-6.0.2-amd64-netboot/preseed.cfg +312 -0
- data/templates/Debian-6.0.2-i386-netboot/definition.rb +41 -0
- data/templates/Debian-6.0.2-i386-netboot/postinstall.sh +83 -0
- data/templates/Debian-6.0.2-i386-netboot/preseed.cfg +312 -0
- data/templates/Fedora-14-amd64/definition.rb +16 -0
- data/templates/Fedora-14-amd64/ks.cfg +41 -0
- data/templates/Fedora-14-amd64/postinstall.sh +54 -0
- data/templates/Fedora-14-amd64-netboot/definition.rb +16 -0
- data/templates/Fedora-14-amd64-netboot/ks.cfg +40 -0
- data/templates/Fedora-14-amd64-netboot/postinstall.sh +54 -0
- data/templates/Fedora-14-i386/definition.rb +16 -0
- data/templates/Fedora-14-i386/ks.cfg +41 -0
- data/templates/Fedora-14-i386/postinstall.sh +54 -0
- data/templates/Fedora-14-i386-netboot/definition.rb +16 -0
- data/templates/Fedora-14-i386-netboot/ks.cfg +40 -0
- data/templates/Fedora-14-i386-netboot/postinstall.sh +54 -0
- data/templates/Fedora-15-i386/definition.rb +17 -0
- data/templates/Fedora-15-i386/ks.cfg +64 -0
- data/templates/Fedora-15-i386/postinstall.sh +33 -0
- data/templates/Fedora-15-i386-netboot/definition.rb +17 -0
- data/templates/Fedora-15-i386-netboot/ks.cfg +82 -0
- data/templates/Fedora-15-i386-netboot/postinstall.sh +18 -0
- data/templates/Sysrescuecd-2.0.0-experimental/autorun0 +3 -0
- data/templates/Sysrescuecd-2.0.0-experimental/definition.rb +20 -0
- data/templates/archlinux-i386/aif.cfg +33 -0
- data/templates/archlinux-i386/definition.rb +29 -0
- data/templates/archlinux-i386/postinstall.sh +95 -0
- data/templates/archlinux-x86_64/aif.cfg +33 -0
- data/templates/archlinux-x86_64/definition.rb +29 -0
- data/templates/archlinux-x86_64/postinstall.sh +95 -0
- data/templates/freebsd-8.2-experimental/definition.rb +19 -0
- data/templates/freebsd-8.2-experimental/postinstall.sh +191 -0
- data/templates/freebsd-8.2-pcbsd-i386/definition.rb +31 -0
- data/templates/freebsd-8.2-pcbsd-i386/pcinstall.fbg.cfg +57 -0
- data/templates/freebsd-8.2-pcbsd-i386/postinstall.sh +93 -0
- data/templates/freebsd-8.2-pcbsd-i386-netboot/definition.rb +34 -0
- data/templates/freebsd-8.2-pcbsd-i386-netboot/pcinstall.fbg.cfg +58 -0
- data/templates/freebsd-8.2-pcbsd-i386-netboot/postinstall.sh +93 -0
- data/templates/gentoo-latest-i386-experimental/definition.rb +29 -0
- data/templates/gentoo-latest-i386-experimental/postinstall.sh +184 -0
- data/templates/openindiana-148-ai-x86/auto_install/ai.dtd +58 -0
- data/templates/openindiana-148-ai-x86/auto_install/ai_manifest.xml +241 -0
- data/templates/openindiana-148-ai-x86/auto_install/configuration.dtd +44 -0
- data/templates/openindiana-148-ai-x86/auto_install/default.xml +121 -0
- data/templates/openindiana-148-ai-x86/auto_install/default.xml.orig +124 -0
- data/templates/openindiana-148-ai-x86/auto_install/sc_profiles/static_network.xml +105 -0
- data/templates/openindiana-148-ai-x86/auto_install/software.dtd +105 -0
- data/templates/openindiana-148-ai-x86/auto_install/target.dtd +196 -0
- data/templates/openindiana-148-ai-x86/default.xml +121 -0
- data/templates/openindiana-148-ai-x86/definition.rb +59 -0
- data/templates/openindiana-148-ai-x86/postinstall.sh +103 -0
- data/templates/opensuse-11.4-i386-experimental/README +11 -0
- data/templates/opensuse-11.4-i386-experimental/autoinst.xml +1269 -0
- data/templates/opensuse-11.4-i386-experimental/autoinst.xml.generated +1269 -0
- data/templates/opensuse-11.4-i386-experimental/autoinst.xml.tweaked +1269 -0
- data/templates/opensuse-11.4-i386-experimental/definition.rb +31 -0
- data/templates/opensuse-11.4-i386-experimental/postinstall.sh +90 -0
- data/templates/solaris-11-express-i386/auto_install/ai.dtd +58 -0
- data/templates/solaris-11-express-i386/auto_install/ai_manifest.xml +241 -0
- data/templates/solaris-11-express-i386/auto_install/configuration.dtd +44 -0
- data/templates/solaris-11-express-i386/auto_install/default.xml +124 -0
- data/templates/solaris-11-express-i386/auto_install/default.xml.orig +124 -0
- data/templates/solaris-11-express-i386/auto_install/sc_profiles/static_network.xml +105 -0
- data/templates/solaris-11-express-i386/auto_install/software.dtd +105 -0
- data/templates/solaris-11-express-i386/auto_install/target.dtd +196 -0
- data/templates/solaris-11-express-i386/default.xml +121 -0
- data/templates/solaris-11-express-i386/definition.rb +65 -0
- data/templates/solaris-11-express-i386/postinstall.sh +98 -0
- data/templates/ubuntu-10.04.2-amd64-netboot/definition.rb +23 -0
- data/templates/ubuntu-10.04.2-amd64-netboot/postinstall.sh +90 -0
- data/templates/ubuntu-10.04.2-amd64-netboot/preseed.cfg +89 -0
- data/templates/ubuntu-10.04.2-server-amd64/definition.rb +57 -0
- data/templates/ubuntu-10.04.2-server-amd64/postinstall.sh +90 -0
- data/templates/ubuntu-10.04.2-server-amd64/preseed.cfg +87 -0
- data/templates/ubuntu-10.04.2-server-amd64-alt/definition.rb +57 -0
- data/templates/ubuntu-10.04.2-server-amd64-alt/postinstall.sh +249 -0
- data/templates/ubuntu-10.04.2-server-amd64-alt/preseed.cfg +124 -0
- data/templates/ubuntu-10.04.2-server-i386/definition.rb +24 -0
- data/templates/ubuntu-10.04.2-server-i386/postinstall.sh +91 -0
- data/templates/ubuntu-10.04.2-server-i386/preseed.cfg +87 -0
- data/templates/ubuntu-10.04.2-server-i386-netboot/definition.rb +23 -0
- data/templates/ubuntu-10.04.2-server-i386-netboot/postinstall.sh +90 -0
- data/templates/ubuntu-10.04.2-server-i386-netboot/preseed.cfg +89 -0
- data/templates/ubuntu-10.10-server-amd64/definition.rb +24 -0
- data/templates/ubuntu-10.10-server-amd64/postinstall.sh +90 -0
- data/templates/ubuntu-10.10-server-amd64/preseed.cfg +87 -0
- data/templates/ubuntu-10.10-server-amd64-netboot/definition.rb +24 -0
- data/templates/ubuntu-10.10-server-amd64-netboot/postinstall.sh +90 -0
- data/templates/ubuntu-10.10-server-amd64-netboot/preseed.cfg +89 -0
- data/templates/ubuntu-10.10-server-i386/definition.rb +24 -0
- data/templates/ubuntu-10.10-server-i386/postinstall.sh +90 -0
- data/templates/ubuntu-10.10-server-i386/preseed.cfg +87 -0
- data/templates/ubuntu-10.10-server-i386-netboot/definition.rb +24 -0
- data/templates/ubuntu-10.10-server-i386-netboot/postinstall.sh +90 -0
- data/templates/ubuntu-10.10-server-i386-netboot/preseed.cfg +89 -0
- data/templates/ubuntu-11.04-server-amd64/definition.rb +24 -0
- data/templates/ubuntu-11.04-server-amd64/postinstall.sh +90 -0
- data/templates/ubuntu-11.04-server-amd64/preseed.cfg +87 -0
- data/templates/ubuntu-11.04-server-i386/definition.rb +24 -0
- data/templates/ubuntu-11.04-server-i386/postinstall.sh +90 -0
- data/templates/ubuntu-11.04-server-i386/preseed.cfg +87 -0
- data/templates/ubuntu-8.04.4-server-amd64/definition.rb +25 -0
- data/templates/ubuntu-8.04.4-server-amd64/postinstall.sh +68 -0
- data/templates/ubuntu-8.04.4-server-amd64/preseed.cfg +88 -0
- data/templates/ubuntu-8.04.4-server-i386/definition.rb +25 -0
- data/templates/ubuntu-8.04.4-server-i386/postinstall.sh +47 -0
- data/templates/ubuntu-8.04.4-server-i386/preseed.cfg +87 -0
- data/templates/windows-2008R2-amd64/Autounattend.xml +132 -0
- data/templates/windows-2008R2-amd64/README.md +68 -0
- data/templates/windows-2008R2-amd64/cygwin-setup.exe +0 -0
- data/templates/windows-2008R2-amd64/definition.rb +16 -0
- data/templates/windows-2008R2-amd64/install-cygwin-sshd.bat +38 -0
- data/templates/windows-2008R2-amd64/install-winrm.bat +6 -0
- data/templates/windows-2008R2-amd64/oracle-cert.cer +0 -0
- data/templates/windows-2008R2-amd64/postinstall.sh +122 -0
- data/templates/windows-2008R2-amd64/winrm.rb +8 -0
- data/trials/docu-vbox.txt +83 -0
- data/trials/f.rb +29 -0
- data/trials/t.rb +15 -0
- data/validation/features/steps/ssh_steps.rb +170 -0
- data/validation/support/env.rb +1 -0
- data/validation/vagrant-private.key +27 -0
- data/validation/vagrant.feature +52 -0
- data/validation/vagrant.pub +1 -0
- data/veewee.gemspec +33 -0
- data/vendor/cache/Platform-0.4.0.gem +0 -0
- data/vendor/cache/archive-tar-minitar-0.5.2.gem +0 -0
- data/vendor/cache/builder-3.0.0.gem +0 -0
- data/vendor/cache/cucumber-1.0.2.gem +0 -0
- data/vendor/cache/diff-lcs-1.1.2.gem +0 -0
- data/vendor/cache/erubis-2.7.0.gem +0 -0
- data/vendor/cache/ffi-1.0.9.gem +0 -0
- data/vendor/cache/gherkin-2.4.6.gem +0 -0
- data/vendor/cache/highline-1.6.2.gem +0 -0
- data/vendor/cache/i18n-0.5.0.gem +0 -0
- data/vendor/cache/json-1.5.3.gem +0 -0
- data/vendor/cache/net-scp-1.0.4.gem +0 -0
- data/vendor/cache/net-ssh-2.1.4.gem +0 -0
- data/vendor/cache/open4-1.1.0.gem +0 -0
- data/vendor/cache/popen4-0.1.2.gem +0 -0
- data/vendor/cache/progressbar-0.9.1.gem +0 -0
- data/vendor/cache/rspec-2.5.0.gem +0 -0
- data/vendor/cache/rspec-core-2.5.2.gem +0 -0
- data/vendor/cache/rspec-expectations-2.5.0.gem +0 -0
- data/vendor/cache/rspec-mocks-2.5.0.gem +0 -0
- data/vendor/cache/term-ansicolor-1.0.6.gem +0 -0
- data/vendor/cache/thor-0.14.6.gem +0 -0
- data/vendor/cache/vagrant-0.8.2.gem +0 -0
- data/vendor/cache/virtualbox-0.9.1.gem +0 -0
- metadata +417 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'veewee/session'
|
2
|
+
|
3
|
+
#Load Veewee::Session libraries
|
4
|
+
lib_dir= File.expand_path(File.join(File.dirname(__FILE__),"..","..", "lib"))
|
5
|
+
Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f| require f }
|
6
|
+
|
7
|
+
#Setup some base variables to use
|
8
|
+
template_dir=File.expand_path(File.join(lib_dir,"..", "templates"))
|
9
|
+
|
10
|
+
veewee_dir="."
|
11
|
+
definition_dir= File.expand_path(File.join(veewee_dir, "definitions"))
|
12
|
+
tmp_dir=File.expand_path(File.join(veewee_dir, "tmp"))
|
13
|
+
iso_dir=File.expand_path(File.join(veewee_dir, "iso"))
|
14
|
+
box_dir=File.expand_path(File.join(veewee_dir, "boxes"))
|
15
|
+
validation_dir=File.expand_path(File.join(lib_dir, "..","validation"))
|
16
|
+
|
17
|
+
#Initialize
|
18
|
+
Veewee::Session.setenv({:veewee_dir => veewee_dir, :definition_dir => definition_dir,
|
19
|
+
:template_dir => template_dir, :iso_dir => iso_dir, :box_dir => box_dir, :tmp_dir => tmp_dir, :validation_dir => validation_dir})
|
20
|
+
|
21
|
+
module Veewee
|
22
|
+
class Command < Vagrant::Command::GroupBase
|
23
|
+
register "basebox","Commands to manage baseboxes"
|
24
|
+
|
25
|
+
desc "templates", "List the currently available basebox templates"
|
26
|
+
def templates
|
27
|
+
Veewee::Session.list_templates
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "define BOXNAME TEMPLATE", "Define a new basebox starting from a template"
|
31
|
+
method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
|
32
|
+
def define(boxname, template)
|
33
|
+
Veewee::Session.define(boxname,template,options)
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "undefine BOXNAME", "Removes the definition of a basebox "
|
37
|
+
def undefine(boxname)
|
38
|
+
Veewee::Session.undefine(boxname)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "build BOXNAME", "Build the box BOXNAME"
|
42
|
+
method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the basebox"
|
43
|
+
method_option :nogui,:type => :boolean , :default => false, :aliases => "-n", :desc => "no gui"
|
44
|
+
|
45
|
+
def build(boxname)
|
46
|
+
Veewee::Session.build(boxname,options)
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "ostypes", "List the available Operating System types"
|
50
|
+
def ostypes
|
51
|
+
Veewee::Session.list_ostypes
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "destroy BOXNAME", "Destroys the virtualmachine that was build for a basebox"
|
55
|
+
def destroy(boxname)
|
56
|
+
Veewee::Session.destroy_vm(boxname)
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "list", "Lists all defined baseboxes"
|
60
|
+
def list
|
61
|
+
Veewee::Session.list_definitions
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "export [NAME]", "Exports the basebox to the vagrant box format"
|
65
|
+
method_options :force => :boolean
|
66
|
+
def export(boxname)
|
67
|
+
if (!boxname.nil?)
|
68
|
+
Veewee::Session.export_box(boxname)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "validate [NAME]", "Validates a box against vagrant compliancy rules"
|
73
|
+
method_option :user,:default => "vagrant", :aliases => "-u", :desc => "user to login with"
|
74
|
+
def validate(boxname)
|
75
|
+
if (!boxname.nil?)
|
76
|
+
Veewee::Session.validate_box(boxname,options)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
module Veewee
|
3
|
+
class Export
|
4
|
+
|
5
|
+
# Shellutil.execute("vagrant package --base #{vmname} --include /tmp/Vagrantfile --output /tmp/#{vmname}.box", {:progress => "on"})
|
6
|
+
|
7
|
+
def self.vagrant(boxname,boxdir,definition)
|
8
|
+
|
9
|
+
#Check if box already exists
|
10
|
+
vm=VirtualBox::VM.find(boxname)
|
11
|
+
if vm.nil?
|
12
|
+
puts "#{boxname} is not found, maybe you need to build first?"
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
#We need to shutdown first
|
16
|
+
if vm.running?
|
17
|
+
puts "Vagrant requires the box to be shutdown, before it can export"
|
18
|
+
puts "Sudo also needs to work for user #{definition[:ssh_user]}"
|
19
|
+
puts "Performing a clean shutdown now."
|
20
|
+
ssh_options={ :user => definition[:ssh_user], :port => definition[:ssh_host_port], :password => definition[:ssh_password],
|
21
|
+
:timeout => definition[:ssh_timeout]}
|
22
|
+
|
23
|
+
Veewee::Ssh.execute("localhost","sudo #{definition[:shutdown_cmd]}",ssh_options)
|
24
|
+
|
25
|
+
#Wait for state poweroff
|
26
|
+
while (vm.running?) do
|
27
|
+
print '.'
|
28
|
+
sleep 1
|
29
|
+
end
|
30
|
+
puts
|
31
|
+
puts "Machine #{boxname} is powered off cleanly"
|
32
|
+
end
|
33
|
+
|
34
|
+
#Vagrant requires a relative path for output of boxes
|
35
|
+
|
36
|
+
#4.0.x. not using boxes as a subdir
|
37
|
+
boxdir=Pathname.new(Dir.pwd)
|
38
|
+
|
39
|
+
full_path=File.join(boxdir,boxname+".box")
|
40
|
+
path1=Pathname.new(full_path)
|
41
|
+
path2=Pathname.new(Dir.pwd)
|
42
|
+
box_path=path1.relative_path_from(path2).to_s
|
43
|
+
|
44
|
+
if File.exists?("#{box_path}")
|
45
|
+
puts "box #{boxname}.box already exists"
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "Excuting vagrant voodoo:"
|
50
|
+
export_command="vagrant package --base '#{boxname}' --output '#{box_path}'"
|
51
|
+
puts "#{export_command}"
|
52
|
+
Veewee::Shell.execute("#{export_command}") #hmm, needs to get the gem_home set?
|
53
|
+
puts
|
54
|
+
|
55
|
+
#add_ssh_nat_mapping back!!!!
|
56
|
+
|
57
|
+
puts "To import it into vagrant type:"
|
58
|
+
puts "vagrant box add '#{boxname}' '#{box_path}'"
|
59
|
+
puts ""
|
60
|
+
puts "To use it:"
|
61
|
+
puts "vagrant init '#{boxname}'"
|
62
|
+
puts "vagrant up"
|
63
|
+
puts "vagrant ssh"
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
# #currently vagrant has a problem with the machine up, it calculates the wrong port to ssh to poweroff the system
|
71
|
+
# thebox.execute("shutdown -h now")
|
72
|
+
# thebox.wait_for_state("poweroff")
|
73
|
+
|
74
|
+
# Shellutil.execute("echo 'Vagrant::Config.run do |config|' > /tmp/Vagrantfile")
|
75
|
+
# Shellutil.execute("echo ' config.ssh.forwarded_port_key = \"ssh\"' >> /tmp/Vagrantfile")
|
76
|
+
# Shellutil.execute("echo ' config.vm.forward_port(\"ssh\",22,#{host_port})' >> /tmp/Vagrantfile")
|
77
|
+
# Shellutil.execute("echo 'end' >> /tmp/Vagrantfile")
|
78
|
+
|
79
|
+
|
80
|
+
#vagrant export disables the machine
|
81
|
+
# thebox.ssh_enable_vmachine({:hostport => host_port , :guestport => 22} )
|
@@ -0,0 +1,151 @@
|
|
1
|
+
module Veewee
|
2
|
+
class Scancode
|
3
|
+
|
4
|
+
def self.send_sequence(vboxcmd,vname,sequence,webport)
|
5
|
+
puts
|
6
|
+
counter=0
|
7
|
+
sequence.each { |s|
|
8
|
+
counter=counter+1
|
9
|
+
|
10
|
+
s.gsub!(/%IP%/,Veewee::Session.local_ip);
|
11
|
+
s.gsub!(/%PORT%/,webport);
|
12
|
+
s.gsub!(/%NAME%/, vname);
|
13
|
+
puts "Typing:[#{counter}]: "+s
|
14
|
+
|
15
|
+
keycodes=string_to_keycode(s)
|
16
|
+
|
17
|
+
# VBox seems to have issues with sending the scancodes as one big
|
18
|
+
# .join()-ed string. It seems to get them out or order or ignore some.
|
19
|
+
# A workaround is to send the scancodes one-by-one.
|
20
|
+
codes=""
|
21
|
+
for keycode in keycodes.split(' ') do
|
22
|
+
|
23
|
+
unless keycode=="wait"
|
24
|
+
send_keycode(vboxcmd,vname,keycode)
|
25
|
+
sleep 0.01
|
26
|
+
else
|
27
|
+
sleep 1
|
28
|
+
end
|
29
|
+
end
|
30
|
+
#sleep after each sequence (needs to be param)
|
31
|
+
sleep 1
|
32
|
+
}
|
33
|
+
|
34
|
+
puts "Done typing."
|
35
|
+
puts
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.send_keycode(vboxcmd,vname,keycode)
|
40
|
+
command= "#{vboxcmd} controlvm '#{vname}' keyboardputscancode #{keycode}"
|
41
|
+
#puts "#{command}"
|
42
|
+
IO.popen("#{command}") { |f| print '' }
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.string_to_keycode(thestring)
|
46
|
+
|
47
|
+
#http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
|
48
|
+
|
49
|
+
k=Hash.new
|
50
|
+
k['1'] = '02 82' ; k['2'] = '03 83' ; k['3'] = '04 84'; k['4']= '05 85' ;
|
51
|
+
k['5']='06 86'; k['6'] = '07 87' ; k['7'] = '08 88'; k['8'] = '09 89'; k['9']= '0a 8a';
|
52
|
+
k['0']='0b 8b'; k['-'] = '0c 8c'; k['='] = '0d 8d' ;
|
53
|
+
k['Tab'] = '0f 8f';
|
54
|
+
k['q'] = '10 90' ; k['w'] = '11 91' ; k['e'] = '12 92';
|
55
|
+
k['r'] = '13 93' ; k['t'] = '14 94' ; k['y'] = '15 95';
|
56
|
+
k['u']= '16 96' ; k['i']='17 97'; k['o'] = '18 98' ; k['p'] = '19 99' ;
|
57
|
+
|
58
|
+
k['Q'] = '2a 10 aa' ; k['W'] = '2a 11 aa' ; k['E'] = '2a 12 aa'; k['R'] = '2a 13 aa' ; k['T'] = '2a 14 aa' ; k['Y'] = '2a 15 aa'; k['U']= '2a 16 aa' ; k['I']='2a 17 aa'; k['O'] = '2a 18 aa' ; k['P'] = '2a 19 aa' ;
|
59
|
+
|
60
|
+
k['a'] = '1e 9e'; k['s'] = '1f 9f' ; k['d'] = '20 a0' ; k['f'] = '21 a1'; k['g'] = '22 a2' ; k['h'] = '23 a3' ; k['j'] = '24 a4';
|
61
|
+
k['k']= '25 a5' ; k['l']='26 a6';
|
62
|
+
k['A'] = '2a 1e aa 9e'; k['S'] = '2a 1f aa 9f' ; k['D'] = '2a 20 aa a0' ; k['F'] = '2a 21 aa a1';
|
63
|
+
k['G'] = '2a 22 aa a2' ; k['H'] = '2a 23 aa a3' ; k['J'] = '2a 24 aa a4'; k['K']= '2a 25 aa a5' ; k['L']='2a 26 aa a6';
|
64
|
+
|
65
|
+
k[';'] = '27 a7' ;k['"']='2a 28 aa a8';k['\'']='28 a8';
|
66
|
+
|
67
|
+
k['\\'] = '2b ab'; k['|'] = '2a 2b aa 8b';
|
68
|
+
|
69
|
+
k['[']='1a 9a'; k[']']='1b 9b';
|
70
|
+
k['<']='2a 33 aa b3'; k['>']='2a 34 aa b4';
|
71
|
+
k['$']='2a 05 aa 85';
|
72
|
+
k['+']='2a 0d aa 8d';
|
73
|
+
|
74
|
+
k['z'] = '2c ac'; k['x'] = '2d ad' ; k['c'] = '2e ae' ; k['v'] = '2f af'; k['b'] = '30 b0' ; k['n'] = '31 b1' ;
|
75
|
+
k['m'] = '32 b2';
|
76
|
+
k['Z'] = '2a 2c aa ac'; k['X'] = '2a 2d aa ad' ; k['C'] = '2a 2e aa ae' ; k['V'] = '2a 2f aa af';
|
77
|
+
k['B'] = '2a 30 aa b0' ; k['N'] = '2a 31 aa b1' ; k['M'] = '2a 32 aa b2';
|
78
|
+
|
79
|
+
k[',']= '33 b3' ; k['.']='34 b4'; k['/'] = '35 b5' ;k[':'] = '2a 27 aa a7';
|
80
|
+
k['%'] = '2a 06 aa 86'; k['_'] = '2a 0c aa 8c';
|
81
|
+
k['&'] = '2a 08 aa 88';
|
82
|
+
k['('] = '2a 0a aa 8a';
|
83
|
+
k[')'] = '2a 0b aa 8b';
|
84
|
+
|
85
|
+
|
86
|
+
special=Hash.new;
|
87
|
+
special['<Enter>'] = '1c 9c';
|
88
|
+
special['<Backspace>'] = '0e 8e';
|
89
|
+
special['<Spacebar>'] = '39 b9';
|
90
|
+
special['<Return>'] = '1c 9c'
|
91
|
+
special['<Esc>'] = '01 81';
|
92
|
+
special['<Tab>'] = '0f 8f';
|
93
|
+
special['<KillX>'] = '1d 38 0e';
|
94
|
+
special['<Wait>'] = 'wait';
|
95
|
+
|
96
|
+
special['<Up>'] = '48 c8';
|
97
|
+
special['<Down>'] = '50 d0';
|
98
|
+
special['<PageUp>'] = '49 c9';
|
99
|
+
special['<PageDown>'] = '51 d1';
|
100
|
+
special['<End>'] = '4f cf';
|
101
|
+
special['<Insert>'] = '52 d2';
|
102
|
+
special['<Delete>'] = '53 d3';
|
103
|
+
special['<Left>'] = '4b cb';
|
104
|
+
special['<Right>'] = '4d cd';
|
105
|
+
special['<Home>'] = '47 c7';
|
106
|
+
|
107
|
+
special['<F1>'] = '3b';
|
108
|
+
special['<F2>'] = '3c';
|
109
|
+
special['<F3>'] = '3d';
|
110
|
+
special['<F4>'] = '3e';
|
111
|
+
special['<F5>'] = '3f';
|
112
|
+
special['<F6>'] = '40';
|
113
|
+
special['<F7>'] = '41';
|
114
|
+
special['<F8>'] = '42';
|
115
|
+
special['<F9>'] = '43';
|
116
|
+
special['<F10>'] = '44';
|
117
|
+
|
118
|
+
keycodes=''
|
119
|
+
thestring.gsub!(/ /,"<Spacebar>")
|
120
|
+
|
121
|
+
until thestring.length == 0
|
122
|
+
nospecial=true;
|
123
|
+
special.keys.each { |key|
|
124
|
+
if thestring.start_with?(key)
|
125
|
+
#take thestring
|
126
|
+
#check if it starts with a special key + pop special string
|
127
|
+
keycodes=keycodes+special[key]+' ';
|
128
|
+
thestring=thestring.slice(key.length,thestring.length-key.length)
|
129
|
+
nospecial=false;
|
130
|
+
break;
|
131
|
+
end
|
132
|
+
}
|
133
|
+
if nospecial
|
134
|
+
code=k[thestring.slice(0,1)]
|
135
|
+
if !code.nil?
|
136
|
+
keycodes=keycodes+code+' '
|
137
|
+
else
|
138
|
+
puts "no scan code for #{thestring.slice(0,1)}"
|
139
|
+
end
|
140
|
+
#pop one
|
141
|
+
thestring=thestring.slice(1,thestring.length-1)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
return keycodes
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
|