Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version update and version configurable #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class plexmediaserver::config inherits plexmediaserver::params {
if $plexmediaserver::params::plex_config {
file { 'plexconfig':
ensure => file,
path => $plexmediaserver::params::plex_config,
owner => 'root',
group => 'root',
mode => '0775',
content => template("${module_name}/PlexMediaServer.erb"),
}
}
}
60 changes: 5 additions & 55 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
class plexmediaserver (
$plex_url =
$plexmediaserver::params::plex_url,
$plex_pkg =
$plexmediaserver::params::plex_pkg,
$plex_provider =
$plexmediaserver::params::plex_provider,
$plex_version,
$plex_user =
$plexmediaserver::params::plex_user,
$plex_media_server_home =
Expand All @@ -22,53 +17,8 @@
$plex_media_server_tmpdir =
$plexmediaserver::params::plex_media_server_tmpdir
) inherits plexmediaserver::params {
case $::operatingsystem {
'Darwin': {
staging::deploy { $plex_pkg:
source => $plex_url,
target => '/tmp',
before => Package['plexmediaserver'],
}
}
default: {
staging::file { $plex_pkg:
source => $plex_url,
target => "/tmp/${plex_pkg}",
before => Package['plexmediaserver'],
}
}
}
Package {
ensure => installed,
}
if $::operatingsystem == 'ubuntu' {
package { 'libavahi-common-data': } -> package { 'libavahi-common3': } -> package { 'avahi-utils': } ->
package { $plexmediaserver::params::plex_ubuntu_deps:
before => Package['plexmediaserver'],
}
}
package { 'plexmediaserver':
provider => $plex_provider,
source => "/tmp/${plex_pkg}",
}
if $plexmediaserver::params::plex_config {
file { 'plexconfig':
ensure => file,
path => $plexmediaserver::params::plex_config,
owner => 'root',
group => 'root',
mode => '0775',
content => template("${module_name}/PlexMediaServer.erb"),
require => Package['plexmediaserver'],
}
}
$subscription_file = $plexmediaserver::params::plex_config ? {
undef => undef,
default => File['plexconfig'],
}
service { 'plexmediaserver':
ensure => running,
enable => true,
subscribe => $subscription_file,
}
class { 'plexmediaserver::install': } ~>
class { 'plexmediaserver::config': } ~>
class { 'plexmediaserver::service': } ->
Class['plexmediaserver']
}
77 changes: 77 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
class plexmediaserver::install inherits plexmediaserver {
# Get download URL
case $::operatingsystem {
'Darwin': {
$plex_url = "https://downloads.plex.tv/plex-media-server/${plex_version}/PlexMediaServer-${plex_version}-OSX.zip"
$plex_pkg = "PlexMediaServer-${plex_version}-OSX.zip"
$plex_provider = 'pkgdmg'
}
'Ubuntu': {
case $::architecture {
'i386': {
$plex_url = "https://downloads.plex.tv/plex-media-server/${plex_version}/plexmediaserver_${plex_version}_i386.deb"
$plex_pkg = "plexmediaserver_${plex_version}_i386.deb"
}
default : {
$plex_url = "https://downloads.plex.tv/plex-media-server/${plex_version}/plexmediaserver_${plex_version}_amd64.deb"
$plex_pkg = "plexmediaserver_${plex_version}_amd64.deb"
}
}
$plex_provider = 'dpkg'
$plex_ubuntu_deps = [ 'libavahi-core7', 'libdaemon0', 'avahi-daemon' ]
}
'Fedora': {
case $::architecture {
'i386': {
$plex_url = "https://downloads.plex.tv/plex-media-server/${plex_version}/plexmediaserver-${plex_version}.i386.rpm"
$plex_pkg = "plexmediaserver-${plex_version}.i386.rpm"
}
default : {
$plex_url = "https://downloads.plex.tv/plex-media-server/${plex_version}/plexmediaserver-${plex_version}.x86_64.rpm"
$plex_pkg = "plexmediaserver-${plex_version}.x86_64.rpm"
}
}
$plex_provider = 'rpm'
}
'CentOS': {
case $::architecture {
'i386': {
$plex_url = "https://downloads.plex.tv/plex-media-server/${plex_version}/plexmediaserver-${plex_version}.i386.rpm"
$plex_pkg = "plexmediaserver-${plex_version}.i386.rpm"
}
default : {
$plex_url = "https://downloads.plex.tv/plex-media-server/${plex_version}/plexmediaserver-${plex_version}.x86_64.rpm"
$plex_pkg = "plexmediaserver-${plex_version}.x86_64.rpm"
}
}
$plex_provider = 'rpm'
}
default: { fail("${::operatingsystem} is not supported by this module.") }
}
# install packages
case $::operatingsystem {
'Darwin': {
staging::deploy { $plex_pkg:
source => $plex_url,
target => '/tmp',
before => Package['plexmediaserver'],
}
}
default: {
staging::file { $plex_pkg:
source => $plex_url,
target => "/tmp/${plex_pkg}",
before => Package['plexmediaserver'],
}
}
}
if $::operatingsystem == 'ubuntu' {
$packages = ['libavahi-common-data','libavahi-common3','avahi-utils',$plex_ubuntu_deps]
ensure_packages($packages)
}
package { 'plexmediaserver':
provider => $plex_provider,
source => "/tmp/${plex_pkg}",
ensure => 'latest',
}
}
74 changes: 15 additions & 59 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,70 +1,26 @@
class plexmediaserver::params {
# Get download URL
# Whether or not to manage the staging module
$plex_staging = false

# General stuff
$plex_user = 'plex'
$plex_media_server_home = '/usr/lib/plexmediaserver'
$plex_media_server_application_support_dir = '${HOME}/Library/Application Support'
$plex_media_server_max_plugin_procs = '6'
$plex_media_server_max_stack_size = '3000'
$plex_media_server_max_lock_mem = '3000'
$plex_media_server_max_open_files = '4096'
$plex_media_server_tmpdir = '/tmp'

case $::operatingsystem {
'Darwin': {
$plex_url = 'http://downloads.plexapp.com/plex-media-server/0.9.9.12.504-3e7f93c/PlexMediaServer-0.9.9.12.504-3e7f93c-OSX.zip'
$plex_pkg = 'PlexMediaServer-0.9.9.12.504-3e7f93c-OSX.zip'
$plex_provider = 'pkgdmg'
}
'Ubuntu': {
case $::architecture {
'i386': {
$plex_url = 'http://downloads.plexapp.com/plex-media-server/0.9.9.12.504-3e7f93c/plexmediaserver_0.9.9.12.504-3e7f93c_i386.deb'
$plex_pkg = 'plexmediaserver_0.9.9.12.504-3e7f93c_i386.deb'
}
default : {
$plex_url = 'http://downloads.plexapp.com/plex-media-server/0.9.9.12.504-3e7f93c/plexmediaserver_0.9.9.12.504-3e7f93c_amd64.deb'
$plex_pkg = 'plexmediaserver_0.9.9.12.504-3e7f93c_amd64.deb'
}
}
$plex_provider = 'dpkg'
$plex_ubuntu_deps = [ 'libavahi-core7', 'libdaemon0', 'avahi-daemon' ]
$plex_config = '/etc/default/plexmediaserver'
}
'Fedora': {
case $::architecture {
'i386': {
$plex_url = 'http://downloads.plexapp.com/plex-media-server/0.9.9.12.504-3e7f93c/plexmediaserver-0.9.9.12.504-3e7f93c.i386.rpm'
$plex_pkg = 'plexmediaserver-0.9.9.12.504-3e7f93c.i386.rpm'
}
default : {
$plex_url = 'http://downloads.plexapp.com/plex-media-server/0.9.9.12.504-3e7f93c/plexmediaserver-0.9.9.12.504-3e7f93c.x86_64.rpm'
$plex_pkg = 'plexmediaserver-0.9.9.12.504-3e7f93c.x86_64.rpm'
}
}
$plex_provider = 'rpm'
$plex_config = '/etc/sysconfig/PlexMediaServer'
$plex_config = '/etc/sysconfig/PlexMediaServer'
}
'CentOS': {
case $::architecture {
'i386': {
$plex_url = 'http://downloads.plexapp.com/plex-media-server/0.9.9.12.504-3e7f93c/plexmediaserver-0.9.9.12.504-3e7f93c.i386.rpm'
$plex_pkg = 'plexmediaserver-0.9.9.12.504-3e7f93c.i386.rpm'
}
default : {
$plex_url = 'http://downloads.plexapp.com/plex-media-server/0.9.9.12.504-3e7f93c/plexmediaserver-0.9.9.12.504-3e7f93c.x86_64.rpm'
$plex_pkg = 'plexmediaserver-0.9.9.12.504-3e7f93c.x86_64.rpm'
}
}
$plex_provider = 'rpm'
$plex_config = '/etc/sysconfig/PlexMediaServer'
$plex_config = '/etc/sysconfig/PlexMediaServer'
}
default: { fail("${::operatingsystem} is not supported by this module.") }
}
# Whether or not to manage the staging module
$plex_staging = false
# General stuff
$plex_user = 'plex'
$plex_media_server_home = '/usr/lib/plexmediaserver'
$plex_media_server_application_support_dir_array = [
'`getent passwd $PLEX_USER|awk -F : \'{print $6}\'`',
'/Library/Application Support'
]
$plex_media_server_application_support_dir =
join($plex_media_server_application_support_dir_array, ' ')
$plex_media_server_max_plugin_procs = '6'
$plex_media_server_max_stack_size = '10000'
$plex_media_server_max_lock_mem = '3000'
$plex_media_server_max_open_files = '4096'
$plex_media_server_tmpdir = '/tmp'
}
6 changes: 6 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class plexmediaserver::service {
service { 'plexmediaserver':
ensure => running,
enable => true,
}
}
43 changes: 8 additions & 35 deletions templates/PlexMediaServer.erb
Original file line number Diff line number Diff line change
@@ -1,46 +1,19 @@
# Plex Media Server Config file.

# Set Plex User
PLEX_USER=<%= @plex_user %>
# Set home of Plex Media Server
PLEX_MEDIA_SERVER_HOME=<%= @plex_media_server_home %>

# Set home for Plex metadata
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="<%= @plex_media_server_application_support_dir %>"
# default script for Plex Media Server

# the number of plugins that can run at the same time
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=<%= @plex_media_server_max_plugin_procs %>

# ulimit -s $PLEX_MEDIA_SERVER_MAX_STACK_SIZE
PLEX_MEDIA_SERVER_MAX_STACK_SIZE=<%= @plex_media_server_max_stack_size %>

# ulimit -l $PLEX_MEDIA_SERVER_MAX_LOCK_MEM
PLEX_MEDIA_SERVER_MAX_LOCK_MEM=<%= @plex_media_server_max_lock_mem %>

# ulimit -n $PLEX_MEDIA_SERVER_MAX_OPEN_FILES
PLEX_MEDIA_SERVER_MAX_OPEN_FILES=<%= @plex_media_server_max_open_files %>

# where the mediaserver should store the transcodes
PLEX_MEDIA_SERVER_TMPDIR=<%= @plex_media_server_tmpdir %>

# Enable syslog for Plex logging.
# uncomment to enable
# export PLEX_MEDIA_SERVER_USE_SYSLOG=true

# uncomment to set it to alternative support dir, eg. /opt/plex
# NOTE: Plex user must be able to write to this dir
#
# PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/opt/plex/Library/Application Support"
# uncomment to set it to something else
# PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="<%= @plex_media_server_application_support_dir %>"

export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}"
export TMPDIR="${PLEX_MEDIA_SERVER_TMPDIR}"
export PLEX_MEDIA_SERVER_HOME=$PLEX_MEDIA_SERVER_HOME
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR
export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=$PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS
export PLEX_MEDIA_SERVER_TMPDIR=$PLEX_MEDIA_SERVER_TMPDIR
export LD_LIBRARY_PATH=$PLEX_MEDIA_SERVER_HOME
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
ulimit -l $PLEX_MEDIA_SERVER_MAX_LOCK_MEM
ulimit -s $PLEX_MEDIA_SERVER_MAX_STACK_SIZE
ulimit -n $PLEX_MEDIA_SERVER_MAX_OPEN_FILES
# the user that PMS should run as, defaults to 'plex'
# note that if you change this you might need to move
# the Application Support directory to not lose your
# media library
PLEX_MEDIA_SERVER_USER=<%= @plex_user %>