Browse code

packaging-ubuntu; issue #516: Add xorg kernel to Vagrantfile for stable ubuntu LTS docker distro

Daniel Mizyrycki authored on 2013/05/09 11:36:06
Showing 1 changed files
... ...
@@ -3,28 +3,47 @@
3 3
 
4 4
 BOX_NAME = ENV['BOX_NAME'] || "ubuntu"
5 5
 BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box"
6
-PPA_KEY = "E61D797F63561DC6"
7 6
 
8 7
 Vagrant::Config.run do |config|
9 8
   # Setup virtual machine box. This VM configuration code is always executed.
10 9
   config.vm.box = BOX_NAME
11 10
   config.vm.box_url = BOX_URI
12
-  # Add docker PPA key to the local repository and install docker
13
-  pkg_cmd = "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys #{PPA_KEY}; "
14
-  pkg_cmd << "echo 'deb http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main' >/etc/apt/sources.list.d/lxc-docker.list; "
15
-  pkg_cmd << "apt-get update -qq; apt-get install -q -y lxc-docker"
16
-  if ARGV.include?("--provider=aws".downcase)
17
-    # Add AUFS dependency to amazon's VM
18
-    pkg_cmd << "; apt-get install linux-image-extra-3.2.0-40-virtual"
11
+
12
+  # Provision docker and new kernel if deployment was not done
13
+  if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty?
14
+    # Add lxc-docker package
15
+    pkg_cmd = "apt-get update -qq; apt-get install -q -y python-software-properties; " \
16
+      "add-apt-repository -y ppa:dotcloud/lxc-docker; apt-get update -qq; " \
17
+      "apt-get install -q -y lxc-docker; "
18
+    # Add X.org Ubuntu backported 3.8 kernel
19
+    pkg_cmd << "add-apt-repository -y ppa:ubuntu-x-swat/r-lts-backport; " \
20
+      "apt-get update -qq; apt-get install -q -y linux-image-3.8.0-19-generic; "
21
+    # Add guest additions if local vbox VM
22
+    is_vbox = true
23
+    ARGV.each do |arg| is_vbox &&= !arg.downcase.start_with?("--provider") end
24
+    if is_vbox
25
+      pkg_cmd << "apt-get install -q -y linux-headers-3.8.0-19-generic dkms; " \
26
+        "echo 'Downloading VBox Guest Additions...'; " \
27
+        "wget -q http://dlc.sun.com.edgesuite.net/virtualbox/4.2.12/VBoxGuestAdditions_4.2.12.iso; "
28
+      # Prepare the VM to add guest additions after reboot
29
+      pkg_cmd << "echo -e 'mount -o loop,ro /home/vagrant/VBoxGuestAdditions_4.2.12.iso /mnt\n" \
30
+        "echo yes | /mnt/VBoxLinuxAdditions.run\numount /mnt\n" \
31
+          "rm /root/guest_additions.sh; ' > /root/guest_additions.sh; " \
32
+        "chmod 700 /root/guest_additions.sh; " \
33
+        "sed -i -E 's#^exit 0#[ -x /root/guest_additions.sh ] \\&\\& /root/guest_additions.sh#' /etc/rc.local; " \
34
+        "echo 'Installation of VBox Guest Additions is proceeding in the background.'; " \
35
+        "echo '\"vagrant reload\" can be used in about 2 minutes to activate the new guest additions.'; "
36
+    end
37
+    # Activate new kernel
38
+    pkg_cmd << "shutdown -r +1; "
39
+    config.vm.provision :shell, :inline => pkg_cmd
19 40
   end
20
-  config.vm.provision :shell, :inline => pkg_cmd
21 41
 end
22 42
 
43
+
23 44
 # Providers were added on Vagrant >= 1.1.0
24 45
 Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
25 46
   config.vm.provider :aws do |aws, override|
26
-    config.vm.box = "dummy"
27
-    config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
28 47
     aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
29 48
     aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
30 49
     aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
... ...
@@ -36,8 +55,6 @@ Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
36 36
   end
37 37
 
38 38
   config.vm.provider :rackspace do |rs|
39
-    config.vm.box = "dummy"
40
-    config.vm.box_url = "https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box"
41 39
     config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"]
42 40
     rs.username = ENV["RS_USERNAME"]
43 41
     rs.api_key  = ENV["RS_API_KEY"]