From f070a1f2919e40e53785d4aeb9477c96486523d9 Mon Sep 17 00:00:00 2001 From: Anachron Date: Sat, 13 Apr 2019 16:54:32 +0200 Subject: [PATCH] plex-media-server: Add service, add _plex system user, ship better start_pms script, add default config --- srcpkgs/plex-media-server/files/default | 15 ++++++++++ .../files/plex-media-server/run | 5 ++++ srcpkgs/plex-media-server/files/start_pms | 28 +++++++++++++++++++ srcpkgs/plex-media-server/template | 10 +++++-- 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 srcpkgs/plex-media-server/files/default create mode 100755 srcpkgs/plex-media-server/files/plex-media-server/run create mode 100755 srcpkgs/plex-media-server/files/start_pms diff --git a/srcpkgs/plex-media-server/files/default b/srcpkgs/plex-media-server/files/default new file mode 100644 index 00000000000..7d3c9a7b7b5 --- /dev/null +++ b/srcpkgs/plex-media-server/files/default @@ -0,0 +1,15 @@ +# config for Plex Media Server + +# ulimit -s $PLEX_MEDIA_SERVER_MAX_STACK_SIZE +export PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000 +#export PLEX_MEDIA_SERVER_MAX_VIRTUAL_MEMORY=524288000 + +# 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 (match what is in /etc/passwd) +#export PLEX_MEDIA_SERVER_USER="_plex" + +# Uncomment this to use syslog for logging instead of +# sending logs to Plex Media Server.log +#export PLEX_MEDIA_SERVER_USE_SYSLOG=true diff --git a/srcpkgs/plex-media-server/files/plex-media-server/run b/srcpkgs/plex-media-server/files/plex-media-server/run new file mode 100755 index 00000000000..b887ad12d73 --- /dev/null +++ b/srcpkgs/plex-media-server/files/plex-media-server/run @@ -0,0 +1,5 @@ +#!/bin/sh + +[ -r ./conf ] && ./conf + +chpst -u _plex:_plex start_pms diff --git a/srcpkgs/plex-media-server/files/start_pms b/srcpkgs/plex-media-server/files/start_pms new file mode 100755 index 00000000000..9b3c606e0f4 --- /dev/null +++ b/srcpkgs/plex-media-server/files/start_pms @@ -0,0 +1,28 @@ +#!/bin/sh + +# Set identification variables +. /etc/os-release +export PLEX_MEDIA_SERVER_INFO_VENDOR="${NAME}" +export PLEX_MEDIA_SERVER_INFO_DEVICE="PC" +export PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)" +export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION=$(date +%Y.%m.%d) + +# change these parameters in /etc/default/plexmediaserver +export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6 +export PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" +export PLEX_MEDIA_SERVER_TMPDIR="/tmp" +export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/var/plexmediaserver" + +test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || mkdir "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" + +test -e /etc/default/plexmediaserver && . /etc/default/plexmediaserver + +export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}/lib:${PLEX_MEDIA_SERVER_HOME}" +export TMPDIR="${PLEX_MEDIA_SERVER_TMPDIR}" + +( + printf 'Starting "Plex Media Server" on %s (%s, %s)\n' "${PLEX_MEDIA_SERVER_INFO_VENDOR}" "${PLEX_MEDIA_SERVER_INFO_MODEL}" "${PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION}" + test -n "${PLEX_MEDIA_SERVER_MAX_STACK_SIZE}" && ulimit -s "${PLEX_MEDIA_SERVER_MAX_STACK_SIZE}" + test -n "${PLEX_MEDIA_SERVER_MAX_VIRTUAL_MEMORY}" && ulimit -v "${PLEX_MEDIA_SERVER_MAX_VIRTUAL_MEMORY}" + cd "${PLEX_MEDIA_SERVER_HOME}" && ./Plex\ Media\ Server +) diff --git a/srcpkgs/plex-media-server/template b/srcpkgs/plex-media-server/template index 3115afeed9a..c7f04c7ad39 100644 --- a/srcpkgs/plex-media-server/template +++ b/srcpkgs/plex-media-server/template @@ -1,7 +1,7 @@ # Template file for 'plex-media-server' pkgname=plex-media-server version=1.15.3.876 -revision=1 +revision=2 _suffix=ad6e39743 archs="i686 x86_64 armv7 aarch64" create_wrksrc=yes @@ -11,6 +11,7 @@ license="Proprietary" homepage="https://www.plex.tv/media-server-downloads" restricted=yes repository=nonfree +system_accounts="_plex" # See https://support.plex.tv/articles/categories/plex-media-server/ case "$XBPS_TARGET_MACHINE" in @@ -35,18 +36,21 @@ esac nopie="yes" nopie_files="/usr/lib/plexmediaserver/Plex DLNA Server" +make_dirs="/var/plexmediaserver 0755 _plex _plex" + do_extract() { fn="${distfiles##*/}" ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${fn}" tar xf data.tar.xz mv usr/{s,}bin - sed -i 's/export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR.*/'\ -'export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${HOME}\/.pms"/g' usr/bin/start_pms + cp "${FILESDIR}/default" etc/default/plexmediaserver + cp "${FILESDIR}/start_pms" usr/bin/start_pms rm -r etc/{apt,init} } do_install() { vcopy etc / vcopy usr / + vsv plex-media-server vlicense "${FILESDIR}/LICENSE" }