From 4a6b44b14090f10635726f05b07bb95c50dda83b Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 16 May 2016 14:55:31 +0100 Subject: [PATCH] Use systemd to manage serial getty on 16.04 machines --- cookbooks/hardware/recipes/default.rb | 36 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index 43c682ca0..aa0c88991 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -77,23 +77,29 @@ when "IBM" end units.sort.uniq.each do |unit| - file "/etc/init/ttySttyS#{unit}.conf" do - action :delete - end + 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 + 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]" + 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 -- 2.43.2