From 436a8e7534aa9190e73902c79859a1a0de4dbdf2 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 26 Feb 2017 10:55:02 +0000 Subject: [PATCH] Convert supybot service to a systemd unit --- cookbooks/supybot/metadata.rb | 1 + cookbooks/supybot/recipes/default.rb | 19 +++++++++------ .../templates/default/supybot.init.erb | 24 ------------------- 3 files changed, 13 insertions(+), 31 deletions(-) delete mode 100644 cookbooks/supybot/templates/default/supybot.init.erb diff --git a/cookbooks/supybot/metadata.rb b/cookbooks/supybot/metadata.rb index ee6d1c463..6c22755c5 100644 --- a/cookbooks/supybot/metadata.rb +++ b/cookbooks/supybot/metadata.rb @@ -5,3 +5,4 @@ license "Apache 2.0" description "Installs and configures supybot" long_description IO.read(File.join(File.dirname(__FILE__), "README.md")) version "1.0.0" +depends "systemd" diff --git a/cookbooks/supybot/recipes/default.rb b/cookbooks/supybot/recipes/default.rb index 7f9953526..551f71331 100644 --- a/cookbooks/supybot/recipes/default.rb +++ b/cookbooks/supybot/recipes/default.rb @@ -123,16 +123,21 @@ git "/usr/local/lib/supybot/plugins/Git" do group "root" end -template "/etc/init.d/supybot" do - source "supybot.init.erb" - owner "root" - group "root" - mode 0o755 +systemd_service "supybot" do + description "OpenStreetMap IRC Robot" + after "network.target" + user "supybot" + exec_start "/usr/bin/supybot /etc/supybot/supybot.conf" + private_tmp true + private_devices true + protect_system true + protect_home true + no_new_privileges true + restart "on-failure" end service "supybot" do action [:enable, :start] - supports :restart => true subscribes :restart, "template[/etc/supybot/supybot.conf]" subscribes :restart, "template[/etc/supybot/channels.conf]" subscribes :restart, "template[/etc/supybot/git.conf]" @@ -140,5 +145,5 @@ service "supybot" do subscribes :restart, "template[/etc/supybot/userdata.conf]" subscribes :restart, "template[/etc/supybot/users.conf]" subscribes :restart, "git[/usr/local/lib/supybot/plugins/Git]" - subscribes :restart, "template[/etc/init.d/supybot]" + subscribes :restart, "systemd_service[supybot]" end diff --git a/cookbooks/supybot/templates/default/supybot.init.erb b/cookbooks/supybot/templates/default/supybot.init.erb deleted file mode 100644 index 8fb6d6bdc..000000000 --- a/cookbooks/supybot/templates/default/supybot.init.erb +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# DO NOT EDIT - This file is being maintained by Chef - -start() { - start-stop-daemon --start --chuid supybot --background --make-pidfile --pidfile /var/run/supybot.pid --exec /usr/bin/supybot -- /etc/supybot/supybot.conf -} - -stop() { - start-stop-daemon --stop --retry TERM/15/KILL/30 --pidfile /var/run/supybot.pid -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop || exit $? - start - ;; -esac -- 2.43.2