X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/3c54ec033cbaa0e1cb58c7157c5741d857e36613..d1be18e9426db54d3cf367855ee95fd8ed117e3b:/cookbooks/hardware/templates/default/grub.erb diff --git a/cookbooks/hardware/templates/default/grub.erb b/cookbooks/hardware/templates/default/grub.erb index 1c19cf684..d69a870b9 100644 --- a/cookbooks/hardware/templates/default/grub.erb +++ b/cookbooks/hardware/templates/default/grub.erb @@ -1,7 +1,23 @@ # DO NOT EDIT - This file is being maintained by Chef -# Boot the first entry by default +# Boot the first entry by default, unless we have configured +# it to boot a specific version. +<% if node[:hardware][:grub][:kernel] == :latest %> GRUB_DEFAULT="0" +<% else + df = Mixlib::ShellOut.new("df /boot/grub/grub.cfg | tail -n 1 | awk '{print $1;}'") + df.run_command + df.error! + root=df.stdout + + blkid = Mixlib::ShellOut.new("blkid -o value -s UUID #{root}") + blkid.run_command + blkid.error! + uuid=blkid.stdout + + version="#{node[:hardware][:grub][:kernel]}-generic" %> +GRUB_DEFAULT="gnulinux-advanced-<%= uuid %>>gnulinux-<%= version %>-advanced-<%= uuid %>" +<% end %> # Wait two seconds before booting the default entry GRUB_TIMEOUT="2"