Skip to content

Commit

Permalink
Added support to find out the current version of virtualbox in the gu…
Browse files Browse the repository at this point in the history
…est by putting .vbox_version in the sudo user homedir
  • Loading branch information
jedi4ever committed Nov 13, 2010
1 parent c73f21a commit 1a2e91a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 21 deletions.
4 changes: 3 additions & 1 deletion Rakefile
Expand Up @@ -32,6 +32,7 @@ lib_dir= File.expand_path(File.join(veewee_dir, "lib"))
box_dir= File.expand_path(File.join(veewee_dir, "boxes"))
template_dir=File.expand_path(File.join(veewee_dir, "templates"))
vbox_dir=File.expand_path(File.join(veewee_dir, "tmp"))
tmp_dir=File.expand_path(File.join(veewee_dir, "tmp"))
iso_dir=File.expand_path(File.join(veewee_dir, "iso"))
ENV['VBOX_USER_HOME']=vbox_dir

Expand All @@ -40,7 +41,8 @@ Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f|
require f }

#Initialize
Veewee::Session.setenv({:veewee_dir => veewee_dir, :definition_dir => definition_dir, :template_dir => template_dir, :iso_dir => iso_dir, :box_dir => box_dir})
Veewee::Session.setenv({:veewee_dir => veewee_dir, :definition_dir => definition_dir,
:template_dir => template_dir, :iso_dir => iso_dir, :box_dir => box_dir, :tmp_dir => tmp_dir})

desc 'Default: list templates'
task :default => [:templates]
Expand Down
22 changes: 15 additions & 7 deletions lib/veewee/session.rb
Expand Up @@ -17,6 +17,7 @@ def self.setenv(env)
@template_dir=env[:template_dir]
@box_dir=env[:box_dir]
@iso_dir=env[:iso_dir]
@tmp_dir=env[:tmp_dir]
end

def self.declare(options)
Expand Down Expand Up @@ -188,19 +189,26 @@ def self.build(boxname)
end #initial Transaction

Veewee::Ssh.when_ssh_login_works("localhost",ssh_options) do

#Transfer version of Virtualbox to $HOME/.vbox_version
versionfile=File.join(@tmp_dir,".vbox_version")
File.open(versionfile, 'w') {|f| f.write("#{VirtualBox::Global.global.lib.virtualbox.version}") }
Veewee::Ssh.transfer_file("localhost",versionfile,ssh_options)

counter=0
@definition[:postinstall_files].each do |postinstall_file|

filename=File.join(@definition_dir,boxname,postinstall_file)
filename=File.join(@definition_dir,boxname,postinstall_file)
transaction(boxname,"#{counter}-#{filename}","postinstall") do
Veewee::Ssh.transfer_file("localhost",filename,ssh_options)
command=@definition[:sudo_cmd]
command.gsub!(/%p/,"#{@definition[:ssh_password]}")

Veewee::Ssh.transfer_file("localhost",filename,ssh_options)
command=@definition[:sudo_cmd]
command.gsub!(/%p/,"#{@definition[:ssh_password]}")
command.gsub!(/%u/,"#{@definition[:ssh_user]}")
command.gsub!(/%f/,"#{postinstall_file}")

Veewee::Ssh.execute("localhost","#{command}",ssh_options)
counter+=1
Veewee::Ssh.execute("localhost","#{command}",ssh_options)
counter+=1
end
end
end
Expand Down Expand Up @@ -380,7 +388,7 @@ def self.transaction(boxname,name,checksum_params, &block)
end
end

#VirtualBox::Global.global.lib.virtualbox.version


def self.list_ostypes
puts
Expand Down
23 changes: 19 additions & 4 deletions templates/CentOS-4.8-i386/postinstall.sh
Expand Up @@ -7,30 +7,45 @@ yum -y install gcc bzip2 make kernel-devel-`uname -r`
#yum -y upgrade

yum -y install gcc-c++ zlib-devel openssl-devel readline-devel sqlite3-devel

yum -y erase wireless-tools gtk2 libX11 hicolor-icon-theme avahi freetype bitstream-vera-fonts

#Installing ruby
wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
tar xzvf ruby-enterprise-1.8.7-2010.02.tar.gz
./ruby-enterprise-1.8.7-2010.02/installer -a /opt/ruby
echo 'PATH=$PATH:/opt/ruby/bin/'> /etc/profile.d/rubyenterprise.sh
rm -rf ./ruby-enterprise-1.8.7-2010.02/
rm ruby-enterprise-1.8.7-2010.02.tar.gz

#Installing chef
/opt/ruby/bin/gem install chef

#Enable sudo
echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Defaults requiretty

#Installing vagrant keys
mkdir /home/vagrant/.ssh
chmod 600 /home/vagrant/.ssh
cd /home/vagrant/.ssh
wget --no-check-certificate 'http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub' -O authorized_keys
chown -R vagrant /home/vagrant/.ssh

VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
#INstalling the virtualbox guest additions
cd /tmp
wget http://download.virtualbox.org/virtualbox/3.2.8/VBoxGuestAdditions_3.2.8.iso
mount -o loop VBoxGuestAdditions_3.2.8.iso /mnt
wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
sh /mnt/VBoxLinuxAdditions-x86.run
umount /mnt

poweroff -h
rm VBoxGuestAdditions_$VBOX_VERSION.iso

#poweroff -h

exit




exit
18 changes: 15 additions & 3 deletions templates/CentOS-5.5-i386/postinstall.sh
Expand Up @@ -7,34 +7,46 @@ yum -y install gcc bzip2 make kernel-devel-`uname -r`
#yum -y upgrade

yum -y install gcc-c++ zlib-devel openssl-devel readline-devel sqlite3-devel

yum -y erase wireless-tools gtk2 libX11 hicolor-icon-theme avahi freetype bitstream-vera-fonts

#Installing ruby
wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
tar xzvf ruby-enterprise-1.8.7-2010.02.tar.gz
./ruby-enterprise-1.8.7-2010.02/installer -a /opt/ruby
echo 'PATH=$PATH:/opt/ruby/bin/'> /etc/profile.d/rubyenterprise.sh
rm -rf ./ruby-enterprise-1.8.7-2010.02/
rm ruby-enterprise-1.8.7-2010.02.tar.gz

#Installing chef
/opt/ruby/bin/gem install chef

#Enable sudo
echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Defaults requiretty

#Installing vagrant keys
mkdir /home/vagrant/.ssh
chmod 600 /home/vagrant/.ssh
cd /home/vagrant/.ssh
wget --no-check-certificate 'http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub' -O authorized_keys
chown -R vagrant /home/vagrant/.ssh

VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
#INstalling the virtualbox guest additions
cd /tmp
wget http://download.virtualbox.org/virtualbox/3.2.8/VBoxGuestAdditions_3.2.8.iso
mount -o loop VBoxGuestAdditions_3.2.8.iso /mnt
wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
sh /mnt/VBoxLinuxAdditions-x86.run
umount /mnt

/sbin/shutdown -H now
rm VBoxGuestAdditions_$VBOX_VERSION.iso

#poweroff -h

exit





10 changes: 7 additions & 3 deletions templates/ubuntu-10.04.1-server-i386/postinstall.sh
Expand Up @@ -17,6 +17,8 @@ wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.t
tar xzvf ruby-enterprise-1.8.7-2010.02.tar.gz
./ruby-enterprise-1.8.7-2010.02/installer -a /opt/ruby
echo 'PATH=$PATH:/opt/ruby/bin/'> /etc/profile.d/rubyenterprise.sh
rm -rf ./ruby-enterprise-1.8.7-2010.02/
rm ruby-enterprise-1.8.7-2010.02.tar.gz

#Installing chef
/opt/ruby/bin/gem install chef
Expand All @@ -28,12 +30,14 @@ cd /home/vagrant/.ssh
wget --no-check-certificate 'http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub' -O authorized_keys
chown -R vagrant /home/vagrant/.ssh

#INstalling the virtualbox guest additions
VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
#INstalling the virtualbox guest additions
cd /tmp
wget http://download.virtualbox.org/virtualbox/3.2.8/VBoxGuestAdditions_3.2.8.iso
mount -o loop VBoxGuestAdditions_3.2.8.iso /mnt
wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
sh /mnt/VBoxLinuxAdditions-x86.run
umount /mnt

shutdown -h now
rm VBoxGuestAdditions_$VBOX_VERSION.iso
exit
10 changes: 7 additions & 3 deletions templates/ubuntu-10.10-server-i386/postinstall.sh
Expand Up @@ -17,6 +17,8 @@ wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.t
tar xzvf ruby-enterprise-1.8.7-2010.02.tar.gz
./ruby-enterprise-1.8.7-2010.02/installer -a /opt/ruby
echo 'PATH=$PATH:/opt/ruby/bin/'> /etc/profile.d/rubyenterprise.sh
rm -rf ./ruby-enterprise-1.8.7-2010.02/
rm ruby-enterprise-1.8.7-2010.02.tar.gz

#Installing chef
/opt/ruby/bin/gem install chef
Expand All @@ -28,12 +30,14 @@ cd /home/vagrant/.ssh
wget --no-check-certificate 'http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub' -O authorized_keys
chown -R vagrant /home/vagrant/.ssh

#INstalling the virtualbox guest additions
VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
#INstalling the virtualbox guest additions
cd /tmp
wget http://download.virtualbox.org/virtualbox/3.2.8/VBoxGuestAdditions_3.2.8.iso
mount -o loop VBoxGuestAdditions_3.2.8.iso /mnt
wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
sh /mnt/VBoxLinuxAdditions-x86.run
umount /mnt

shutdown -h now
rm VBoxGuestAdditions_$VBOX_VERSION.iso
exit

0 comments on commit 1a2e91a

Please sign in to comment.