Add support for systemd init scripts
This is needed to support ubuntu xenial. Change-Id: If30bff94ee0136fbadee7ce994b25842a1cc4270 Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
82a00dacba
commit
a45ee742a0
@ -5,4 +5,8 @@ class meetbot::params {
|
||||
'xenial' => '/usr/lib/python2.7/dist-packages',
|
||||
default => '/usr/share/pyshared',
|
||||
}
|
||||
$initd = $::lsbdistcodename ? {
|
||||
'trusty' => 'upstart',
|
||||
default => 'systemd',
|
||||
}
|
||||
}
|
||||
|
@ -106,11 +106,24 @@ define meetbot::site(
|
||||
environment => 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
}
|
||||
|
||||
# we set this file as root ownership because meetbot overwrites it on shutdown
|
||||
# this means when puppet changes it and restarts meetbot the file is reset
|
||||
file { "/etc/init/${name}-meetbot.conf":
|
||||
if ($::meetbot::params::initd == 'systemd') {
|
||||
$initd_path = "/etc/systemd/system/${name}-meetbot.service"
|
||||
# This is a hack to make sure that systemd is aware of the new service
|
||||
# before we attempt to start it.
|
||||
exec { "${name}-meetbot-systemd-daemon-reload":
|
||||
command => '/bin/systemctl daemon-reload',
|
||||
before => Service["${name}-meetbot"],
|
||||
subscribe => File["${name}-initd"],
|
||||
refreshonly => true,
|
||||
}
|
||||
} else {
|
||||
$initd_path = "/etc/init/${name}-meetbot.conf"
|
||||
}
|
||||
|
||||
file { "${name}-initd":
|
||||
ensure => present,
|
||||
content => template('meetbot/upstart.erb'),
|
||||
path => $initd_path,
|
||||
content => template("meetbot/${::meetbot::params::initd}.erb"),
|
||||
notify => Service["${name}-meetbot"],
|
||||
owner => 'root',
|
||||
replace => true,
|
||||
@ -118,10 +131,10 @@ define meetbot::site(
|
||||
}
|
||||
|
||||
service { "${name}-meetbot":
|
||||
provider => upstart,
|
||||
provider => $::meetbot::params::initd,
|
||||
require => [
|
||||
Vcsrepo['/opt/meetbot'],
|
||||
File["/etc/init/${name}-meetbot.conf"]
|
||||
File["${name}-initd"]
|
||||
],
|
||||
subscribe => [
|
||||
File["${::meetbot::params::plugins_dir}/supybot/plugins/MeetBot"],
|
||||
|
14
templates/systemd.erb
Normal file
14
templates/systemd.erb
Normal file
@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=<%= @name %> Meetbot Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment=PYTHONPATH=/var/lib/meetbot/<%= @name %>
|
||||
Group=meetbot
|
||||
User=meetbot
|
||||
WorkingDirectory=/var/lib/meetbot/<%= @name %>
|
||||
ExecStart=/usr/bin/python /usr/bin/supybot /var/lib/meetbot/<%= @name %>.conf
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
x
Reference in New Issue
Block a user