feat: manage jellyfin data migration_flag
This commit is contained in:
parent
2199e4e3c0
commit
f3046f8fbb
9
modules/libs/lib/facter/jellyfin_migration_done.rb
Normal file
9
modules/libs/lib/facter/jellyfin_migration_done.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'facter'
|
||||
|
||||
Facter.add(:jellyfin_migration_done) do
|
||||
setcode do
|
||||
File.exist?('/etc/sysconfig/jellyfin_migration_done')
|
||||
end
|
||||
end
|
||||
@ -1,6 +1,15 @@
|
||||
# profiles::media::jellyfin
|
||||
class profiles::media::jellyfin (
|
||||
Stdlib::Absolutepath $media_root = '/shared/media',
|
||||
Stdlib::Absolutepath $media_root = '/shared/media',
|
||||
Stdlib::Absolutepath $data_dir = '/data/jellyfin',
|
||||
Stdlib::Absolutepath $lib_dir = '/data/jellyfin/var/lib',
|
||||
Stdlib::Absolutepath $cache_dir = '/data/jellyfin/var/cache',
|
||||
Stdlib::Absolutepath $config_dir = '/data/jellyfin/etc',
|
||||
Stdlib::Absolutepath $log_dir = '/data/jellyfin/var/log',
|
||||
Stdlib::Absolutepath $sysconfig_file = '/etc/sysconfig/jellyfin',
|
||||
Stdlib::Absolutepath $migration_flag = '/etc/sysconfig/jellyfin_migration_done',
|
||||
String $service_name = 'jellyfin',
|
||||
Boolean $migrate_data = true,
|
||||
) {
|
||||
|
||||
include profiles::ceph::client
|
||||
@ -28,4 +37,80 @@ class profiles::media::jellyfin (
|
||||
'fall 2',
|
||||
]
|
||||
}
|
||||
|
||||
mkdir::p {[$data_dir, $lib_dir, $cache_dir, $config_dir, $log_dir]:}
|
||||
-> file { [$data_dir, $lib_dir, $cache_dir, $config_dir, $log_dir]:
|
||||
ensure => directory,
|
||||
owner => 'jellyfin',
|
||||
group => 'jellyfin',
|
||||
mode => '0755',
|
||||
}
|
||||
|
||||
if $migrate_data and ! $facts['jellyfin_migration_done'] {
|
||||
|
||||
exec { "stop-${service_name}":
|
||||
command => "/usr/bin/systemctl stop ${service_name}",
|
||||
require => File[$sysconfig_file],
|
||||
}
|
||||
|
||||
exec { 'move-jellyfin-lib':
|
||||
command => "/usr/bin/rsync -av /var/lib/jellyfin/ ${lib_dir}/ && rm -rf /var/lib/jellyfin",
|
||||
creates => "${lib_dir}/config",
|
||||
require => [File[$lib_dir], Exec["stop-${service_name}"]],
|
||||
}
|
||||
|
||||
exec { 'move-jellyfin-cache':
|
||||
command => "/usr/bin/rsync -av /var/cache/jellyfin/ ${cache_dir}/ && rm -rf /var/cache/jellyfin",
|
||||
creates => "${cache_dir}/config",
|
||||
require => [File[$cache_dir], Exec["stop-${service_name}"]],
|
||||
}
|
||||
|
||||
exec { 'move-jellyfin-config':
|
||||
command => "/usr/bin/rsync -av /etc/jellyfin/ ${config_dir}/ && rm -rf /etc/jellyfin",
|
||||
creates => "${config_dir}/config",
|
||||
require => [File[$config_dir], Exec["stop-${service_name}"]],
|
||||
}
|
||||
|
||||
exec { 'move-jellyfin-log':
|
||||
command => "/usr/bin/rsync -av /var/log/jellyfin/ ${log_dir}/ && rm -rf /var/log/jellyfin",
|
||||
creates => "${log_dir}/config",
|
||||
require => [File[$log_dir], Exec["stop-${service_name}"]],
|
||||
}
|
||||
|
||||
exec { 'create-migration-flag':
|
||||
command => "/usr/bin/touch ${migration_flag}",
|
||||
creates => $migration_flag,
|
||||
require => [
|
||||
Exec['move-jellyfin-lib'],
|
||||
Exec['move-jellyfin-cache'],
|
||||
Exec['move-jellyfin-config'],
|
||||
Exec['move-jellyfin-log']
|
||||
],
|
||||
}
|
||||
|
||||
exec { "start-${service_name}":
|
||||
command => "/usr/bin/systemctl start ${service_name}",
|
||||
require => Exec['create-migration-flag'],
|
||||
}
|
||||
}
|
||||
|
||||
file { $sysconfig_file:
|
||||
ensure => file,
|
||||
content => template('profiles/jellyfin/sysconfig.erb'),
|
||||
notify => [
|
||||
Systemd::Daemon_reload["${service_name}_service"],
|
||||
Service[$service_name]
|
||||
],
|
||||
}
|
||||
|
||||
file { '/etc/systemd/system/jellyfin.service.d/override.conf':
|
||||
ensure => file,
|
||||
content => template('profiles/jellyfin/override.conf.erb'),
|
||||
notify => [
|
||||
Systemd::Daemon_reload["${service_name}_service"],
|
||||
Service[$service_name]
|
||||
],
|
||||
}
|
||||
|
||||
systemd::daemon_reload {"${service_name}_service":}
|
||||
}
|
||||
|
||||
8
site/profiles/templates/jellyfin/override.conf.erb
Normal file
8
site/profiles/templates/jellyfin/override.conf.erb
Normal file
@ -0,0 +1,8 @@
|
||||
# Jellyfin systemd configuration options
|
||||
|
||||
# Use this file to override the user or environment file location.
|
||||
|
||||
[Service]
|
||||
#User = jellyfin
|
||||
EnvironmentFile = <%= @environment_file %>
|
||||
WorkingDirectory = <%= @lib_dir %>
|
||||
38
site/profiles/templates/jellyfin/sysconfig.erb
Normal file
38
site/profiles/templates/jellyfin/sysconfig.erb
Normal file
@ -0,0 +1,38 @@
|
||||
# Jellyfin default configuration options
|
||||
|
||||
# Use this file to override the default configurations; add additional
|
||||
# options with JELLYFIN_ADD_OPTS.
|
||||
|
||||
# To override the user or this config file's location, use
|
||||
# /etc/systemd/system/jellyfin.service.d/override.conf
|
||||
|
||||
#
|
||||
# This is a POSIX shell fragment
|
||||
#
|
||||
|
||||
#
|
||||
# General options
|
||||
#
|
||||
|
||||
# Program directories
|
||||
JELLYFIN_DATA_DIR="<%= @lib_dir %>"
|
||||
JELLYFIN_CONFIG_DIR="<%= @config_dir %>"
|
||||
JELLYFIN_LOG_DIR="<%= @log_dir %>"
|
||||
JELLYFIN_CACHE_DIR="<%= @cache_dir %>"
|
||||
|
||||
# web client path, installed by the jellyfin-web package
|
||||
JELLYFIN_WEB_OPT="--webdir=/usr/share/jellyfin-web"
|
||||
|
||||
# [OPTIONAL] ffmpeg binary paths, overriding the UI-configured values
|
||||
#JELLYFIN_FFMPEG_OPT="--ffmpeg=/usr/bin/ffmpeg"
|
||||
|
||||
# [OPTIONAL] run Jellyfin as a headless service
|
||||
#JELLYFIN_SERVICE_OPT="--service"
|
||||
|
||||
# [OPTIONAL] run Jellyfin without the web app
|
||||
#JELLYFIN_NOWEBAPP_OPT="--noautorunwebapp"
|
||||
|
||||
# [OPTIONAL] run Jellyfin with ASP.NET Server Garbage Collection (uses more RAM and less CPU than Workstation GC)
|
||||
# 0 = Workstation
|
||||
# 1 = Server
|
||||
#COMPlus_gcServer=1
|
||||
@ -6,6 +6,7 @@ class roles::apps::media::jellyfin {
|
||||
}else{
|
||||
include profiles::defaults
|
||||
include profiles::base
|
||||
include profiles::base::datavol
|
||||
include profiles::media::jellyfin
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user