+ units << "0"
+end
+
+units.sort.uniq.each do |unit|
+ if node[:lsb][:release].to_f >= 16.04
+ service "serial-getty@ttyS#{unit}" do
+ action [:enable, :start]
+ end
+ else
+ file "/etc/init/ttySttyS#{unit}.conf" do
+ action :delete
+ end
+
+ template "/etc/init/ttyS#{unit}.conf" do
+ source "tty.conf.erb"
+ owner "root"
+ group "root"
+ mode 0644
+ variables :unit => unit
+ end
+
+ service "ttyS#{unit}" do
+ provider Chef::Provider::Service::Upstart
+ action [:enable, :start]
+ supports :status => true, :restart => true, :reload => false
+ subscribes :restart, "template[/etc/init/ttyS#{unit}.conf]"
+ end
+ end
+end
+
+# if we need a different / special kernel version to make the hardware
+# work (e.g: https://github.com/openstreetmap/operations/issues/45) then
+# ensure that we have the package installed. the grub template will
+# make sure that this is the default on boot.
+if node[:hardware][:grub][:kernel]
+ kernel_version = node[:hardware][:grub][:kernel]
+
+ package "linux-image-#{kernel_version}-generic"
+ package "linux-image-extra-#{kernel_version}-generic"
+ package "linux-headers-#{kernel_version}-generic"
+
+ boot_device = IO.popen(["df", "/boot"]).readlines.last.split.first
+ boot_uuid = IO.popen(["blkid", "-o", "value", "-s", "UUID", boot_device]).readlines.first.chomp
+ grub_entry = "gnulinux-advanced-#{boot_uuid}>gnulinux-#{kernel_version}-advanced-#{boot_uuid}"
+else
+ grub_entry = "0"
+end
+
+if File.exist?("/etc/default/grub")
+ execute "update-grub" do
+ action :nothing
+ command "/usr/sbin/update-grub"
+ end
+
+ template "/etc/default/grub" do
+ source "grub.erb"
+ owner "root"
+ group "root"
+ mode 0644
+ variables :units => units, :entry => grub_entry
+ notifies :run, "execute[update-grub]"
+ end
+end
+
+execute "update-initramfs" do
+ action :nothing
+ command "update-initramfs -u -k all"
+ user "root"
+ group "root"
+end
+
+template "/etc/initramfs-tools/conf.d/mdadm" do
+ source "initramfs-mdadm.erb"
+ owner "root"
+ group "root"
+ mode 0644
+ notifies :run, "execute[update-initramfs]"
+end
+
+package "haveged"
+service "haveged" do
+ action [:enable, :start]
+end
+
+if node[:kernel][:modules].include?("ipmi_si")
+ package "ipmitool"