]> git.openstreetmap.org Git - chef.git/commitdiff
Use systemd to manage serial getty on 16.04 machines
authorTom Hughes <tom@compton.nu>
Mon, 16 May 2016 13:55:31 +0000 (14:55 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 16 May 2016 13:55:31 +0000 (14:55 +0100)
cookbooks/hardware/recipes/default.rb

index 43c682ca0a51d7bb413bb003f00a638b55570ea3..aa0c889915af16eae7c9a006dcda70a221e34e47 100644 (file)
@@ -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