feat: add sonarr module #58
21
modules/sonarr/manifests/init.pp
Normal file
21
modules/sonarr/manifests/init.pp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# manage sonarr
|
||||||
|
class sonarr (
|
||||||
|
$packages = $sonarr::params::packages,
|
||||||
|
$user = $sonarr::params::user,
|
||||||
|
$group = $sonarr::params::user,
|
||||||
|
$base_path = $sonarr::params::base_path,
|
||||||
|
$install_path = $sonarr::params::install_path,
|
||||||
|
$config_folder = $sonarr::params::config_folder,
|
||||||
|
$app_folder = $sonarr::params::app_folder,
|
||||||
|
$archive_name = $sonarr::params::archive_name,
|
||||||
|
$archive_url = $sonarr::params::archive_url,
|
||||||
|
$executable = $sonarr::params::executable,
|
||||||
|
$service_enable = $sonarr::params::service_enable,
|
||||||
|
$service_name = $sonarr::params::service_name,
|
||||||
|
) inherits sonarr::params {
|
||||||
|
|
||||||
|
include sonarr::install
|
||||||
|
include sonarr::service
|
||||||
|
|
||||||
|
Class['sonarr::install'] -> Class['sonarr::service']
|
||||||
|
}
|
||||||
60
modules/sonarr/manifests/install.pp
Normal file
60
modules/sonarr/manifests/install.pp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# instsall sonarr
|
||||||
|
class sonarr::install (
|
||||||
|
$packages = $sonarr::packages,
|
||||||
|
$user = $sonarr::user,
|
||||||
|
$group = $sonarr::user,
|
||||||
|
$base_path = $sonarr::base_path,
|
||||||
|
$install_path = $sonarr::install_path,
|
||||||
|
$config_folder = $sonarr::config_folder,
|
||||||
|
$app_folder = $sonarr::app_folder,
|
||||||
|
$archive_name = $sonarr::archive_name,
|
||||||
|
$archive_url = $sonarr::archive_url,
|
||||||
|
$executable = $sonarr::executable,
|
||||||
|
) {
|
||||||
|
|
||||||
|
$_packages = $packages ? {
|
||||||
|
Array => true,
|
||||||
|
default => false,
|
||||||
|
}
|
||||||
|
|
||||||
|
if $_packages {
|
||||||
|
package { $packages:
|
||||||
|
ensure => installed,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group { $group:
|
||||||
|
ensure => present,
|
||||||
|
}
|
||||||
|
|
||||||
|
user { $user:
|
||||||
|
ensure => present,
|
||||||
|
shell => '/sbin/nologin',
|
||||||
|
groups => $group,
|
||||||
|
managehome => true,
|
||||||
|
}
|
||||||
|
|
||||||
|
file { [ $base_path, $install_path, $config_folder, $app_folder ]:
|
||||||
|
ensure => directory,
|
||||||
|
owner => $user,
|
||||||
|
group => $group,
|
||||||
|
}
|
||||||
|
|
||||||
|
archive { $archive_name:
|
||||||
|
path => "/tmp/${archive_name}",
|
||||||
|
source => "${archive_url}${archive_name}",
|
||||||
|
extract => true,
|
||||||
|
extract_path => $install_path,
|
||||||
|
creates => "${install_path}/${executable}",
|
||||||
|
cleanup => true,
|
||||||
|
require => File[$install_path],
|
||||||
|
user => $user,
|
||||||
|
group => $group,
|
||||||
|
notify => Exec['move_sonarr_files'],
|
||||||
|
}
|
||||||
|
|
||||||
|
exec { 'move_sonarr_files':
|
||||||
|
command => "/usr/bin/mv ${install_path}/NzbDrone/* ${install_path}",
|
||||||
|
creates => "${install_path}/${executable}",
|
||||||
|
}
|
||||||
|
}
|
||||||
19
modules/sonarr/manifests/params.pp
Normal file
19
modules/sonarr/manifests/params.pp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# sonarr params
|
||||||
|
class sonarr::params (
|
||||||
|
$packages = [ 'mediainfo', 'libzen', 'libmediainfo',
|
||||||
|
'gettext', 'sqlite.x86_64', 'par2cmdline',
|
||||||
|
'python-feedparser', 'python-configobj',
|
||||||
|
'python-cheetah', 'python-dbus', 'python-devel',
|
||||||
|
'libxslt-devel'],
|
||||||
|
$user = 'sonarr',
|
||||||
|
$base_path = '/opt/sonarr',
|
||||||
|
$install_path = '/opt/sonarr/bin',
|
||||||
|
$config_folder = "/home/${user}/.config",
|
||||||
|
$app_folder = "/home/${user}/.config/Sonarr",
|
||||||
|
$archive_version = '4.0.5',
|
||||||
|
$archive_name = 'Sonarr.main.linux-x64.tar.gz',
|
||||||
|
$archive_url = "https://git.query.consul/api/packages/unkinben/generic/sonarr/${archive_version}",
|
||||||
|
$executable = 'Sonarr',
|
||||||
|
$service_enable = true,
|
||||||
|
$service_name = 'sonarr',
|
||||||
|
){}
|
||||||
20
modules/sonarr/manifests/service.pp
Normal file
20
modules/sonarr/manifests/service.pp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# manage sonarr service
|
||||||
|
class sonarr::service (
|
||||||
|
$service_enable = $sonarr::service_enable,
|
||||||
|
$service_name = $sonarr::service_name,
|
||||||
|
$user = $sonarr::user,
|
||||||
|
$group = $sonarr::user,
|
||||||
|
$install_path = $sonarr::install_path,
|
||||||
|
$executable = $sonarr::executable,
|
||||||
|
$base_path = $sonarr::base_path,
|
||||||
|
) {
|
||||||
|
if $service_enable {
|
||||||
|
include ::systemd
|
||||||
|
|
||||||
|
systemd::unit_file { "${service_name}.service":
|
||||||
|
content => template('sonarr/sonarr.service.erb'),
|
||||||
|
enable => true,
|
||||||
|
active => true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
modules/sonarr/templates/sonarr.service.erb
Normal file
14
modules/sonarr/templates/sonarr.service.erb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=<%= @service_name %> Daemon
|
||||||
|
After=syslog.target network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=<%= @user %>
|
||||||
|
Group=<%= @group %>
|
||||||
|
Type=simple
|
||||||
|
ExecStart=<%= @install_path %>/<%= @executable %> -nobrowser -data=<%= @base_path %>
|
||||||
|
KillMode=process
|
||||||
|
Restart=on-failure
|
||||||
|
TimeoutStopSec=20
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Loading…
Reference in New Issue
Block a user