From bac8b14e6cd7dc11383970a7e058a49f6890b0a6 Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Wed, 11 Jan 2017 19:16:55 +0000 Subject: [PATCH 1/9] use plex env variables, usermod home folder of abc to /app --- Dockerfile | 11 ++++++++--- README.md | 2 ++ root/etc/cont-init.d/40-chown-files | 20 ++++++++++++-------- root/etc/services.d/plex/run | 3 ++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 73a4632..c5b7d96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,11 @@ MAINTAINER Stian Larsen, sparklyballs ENV PLEX_INSTALL="https://plex.tv/downloads/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu" # global environment settings -ENV DEBIAN_FRONTEND="noninteractive" -ENV HOME="/config" -ENV PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server" +ENV DEBIAN_FRONTEND="noninteractive" \ +PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server" \ +PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" \ +PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \ +PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" # install packages RUN \ @@ -23,6 +25,9 @@ RUN \ "${PLEX_INSTALL}" && \ dpkg -i /tmp/plexmediaserver.deb && \ +# change abc home folder to fix plex hanging at runtime with usermod + usermod -d /app abc && \ + # cleanup apt-get clean && \ rm -rf \ diff --git a/README.md b/README.md index 54a2311..4508e85 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,8 @@ Valid settings for VERSION are:- ## Versions ++ **11.01.17:** Use Plex environemt variables from pms docker, +change abc home folder to /app to alleviate usermod chowning library folder by default (thanks gbooker, plexinc). + **03.01.17:** Use case insensitive version variable matching rather than export and make lowercase. + **17.10.16:** Allow use of uppercase version variable + **01.10.16:** Add TZ info to README. diff --git a/root/etc/cont-init.d/40-chown-files b/root/etc/cont-init.d/40-chown-files index fa3c826..062a022 100644 --- a/root/etc/cont-init.d/40-chown-files +++ b/root/etc/cont-init.d/40-chown-files @@ -1,12 +1,16 @@ #!/usr/bin/with-contenv bash # check for Library existence and permissions -if [ ! -d "/config/Library" ]; then - mkdir -p /config/Library - chown abc:abc /config/Library -elif [ ! "$(stat -c %u /config/Library)" = "$PUID" ]; then - echo "Change in ownership detected, please be patient while we chown existing files" - echo "This could take some time" - chown abc:abc -R \ - /config/Library +if [ ! -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" ]; then + mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" + chown abc:abc "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" +elif [ ! "$(stat -c %u ${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR})" = "$PUID" ]; then + echo "Change in ownership detected, please be patient while we chown existing files" + echo "This could take some time" + chown abc:abc -R \ + "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" fi + +chown abc:abc \ + /config \ + /config/* diff --git a/root/etc/services.d/plex/run b/root/etc/services.d/plex/run index 0a979f9..b3556ec 100644 --- a/root/etc/services.d/plex/run +++ b/root/etc/services.d/plex/run @@ -1,5 +1,6 @@ #!/usr/bin/with-contenv bash echo "Starting Plex Media Server." -exec s6-setuidgid abc /usr/sbin/start_pms +exec s6-setuidgid abc /bin/sh -c 'LD_LIBRARY_PATH=/usr/lib/plexmediaserver /usr/lib/plexmediaserver/Plex\ Media\ Server' + From 894d4b74fa9942fcf27f3715df832b2e048ba0d9 Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Wed, 11 Jan 2017 19:51:37 +0000 Subject: [PATCH 2/9] use PLEX_MEDIA_SERVER_INFO_DEVICE=docker to identify to pms using a docker image, fix quotes on variable, shellcheck --- Dockerfile | 4 ++-- root/etc/cont-init.d/40-chown-files | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5b7d96..ae57867 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ FROM lsiobase/xenial MAINTAINER Stian Larsen, sparklyballs -# package version -ENV PLEX_INSTALL="https://plex.tv/downloads/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu" # global environment settings ENV DEBIAN_FRONTEND="noninteractive" \ PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server" \ +PLEX_INSTALL="https://plex.tv/downloads/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu" \ PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" \ PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \ +PLEX_MEDIA_SERVER_INFO_DEVICE=docker \ PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" # install packages diff --git a/root/etc/cont-init.d/40-chown-files b/root/etc/cont-init.d/40-chown-files index 062a022..61fcf71 100644 --- a/root/etc/cont-init.d/40-chown-files +++ b/root/etc/cont-init.d/40-chown-files @@ -4,7 +4,7 @@ if [ ! -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" ]; then mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" chown abc:abc "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" -elif [ ! "$(stat -c %u ${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR})" = "$PUID" ]; then +elif [ ! "$(stat -c %u "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}")" = "$PUID" ]; then echo "Change in ownership detected, please be patient while we chown existing files" echo "This could take some time" chown abc:abc -R \ From 85caabf7a7c8229c3a8a4f06e75f9da703ad04d9 Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Wed, 11 Jan 2017 20:29:18 +0000 Subject: [PATCH 3/9] different approach to init --- root/etc/cont-init.d/40-chown-files | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/root/etc/cont-init.d/40-chown-files b/root/etc/cont-init.d/40-chown-files index 61fcf71..ffb4503 100644 --- a/root/etc/cont-init.d/40-chown-files +++ b/root/etc/cont-init.d/40-chown-files @@ -1,16 +1,17 @@ #!/usr/bin/with-contenv bash -# check for Library existence and permissions -if [ ! -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" ]; then - mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" - chown abc:abc "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" -elif [ ! "$(stat -c %u "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}")" = "$PUID" ]; then +# create folders +if [[ ! -d ${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR} ]]; then \ +mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" +chown -R abc:abc "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" +fi + +# check Library permissions +PUID=${PUID:-911} +if [ ! "$(stat -c %u /config/Library)" = "$PUID" ]; then echo "Change in ownership detected, please be patient while we chown existing files" echo "This could take some time" chown abc:abc -R \ - "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" + /config/Library fi -chown abc:abc \ - /config \ - /config/* From 86ff461b4220996d9d1927290ea1da77ab2a3532 Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Wed, 11 Jan 2017 20:37:30 +0000 Subject: [PATCH 4/9] tweak chown init once again --- root/etc/cont-init.d/40-chown-files | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/root/etc/cont-init.d/40-chown-files b/root/etc/cont-init.d/40-chown-files index ffb4503..6726d97 100644 --- a/root/etc/cont-init.d/40-chown-files +++ b/root/etc/cont-init.d/40-chown-files @@ -1,9 +1,9 @@ #!/usr/bin/with-contenv bash # create folders -if [[ ! -d ${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR} ]]; then \ +if [ ! -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" ]; then \ mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" -chown -R abc:abc "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" +chown -R abc:abc /config fi # check Library permissions From 28aed5a0716f844040aa63f1bcd6063623109e7d Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Wed, 11 Jan 2017 20:54:44 +0000 Subject: [PATCH 5/9] put LIBPATH in dockerfile, try using /bin/bash in place of /bin/sh to see if jenkins crash happens --- Dockerfile | 3 ++- root/etc/services.d/plex/run | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ae57867..d74ef3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,8 @@ PLEX_INSTALL="https://plex.tv/downloads/latest/1?channel=8&build=linux-ubuntu-x8 PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" \ PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \ PLEX_MEDIA_SERVER_INFO_DEVICE=docker \ -PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" +PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" \ +LD_LIBRARY_PATH="/usr/lib/plexmediaserver:$LD_LIBRARY_PATH" # install packages RUN \ diff --git a/root/etc/services.d/plex/run b/root/etc/services.d/plex/run index b3556ec..cd91d22 100644 --- a/root/etc/services.d/plex/run +++ b/root/etc/services.d/plex/run @@ -1,6 +1,8 @@ #!/usr/bin/with-contenv bash echo "Starting Plex Media Server." -exec s6-setuidgid abc /bin/sh -c 'LD_LIBRARY_PATH=/usr/lib/plexmediaserver /usr/lib/plexmediaserver/Plex\ Media\ Server' +exec \ + s6-setuidgid abc /bin/bash -c \ + '/usr/lib/plexmediaserver/Plex\ Media\ Server' From 08c34488dfc255d7fbdcf68a661927277b4cf0df Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Wed, 11 Jan 2017 20:58:07 +0000 Subject: [PATCH 6/9] test theory if it /bin/sh causing jenkins crashlog --- root/etc/services.d/plex/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/services.d/plex/run b/root/etc/services.d/plex/run index cd91d22..1b9b75a 100644 --- a/root/etc/services.d/plex/run +++ b/root/etc/services.d/plex/run @@ -2,7 +2,7 @@ echo "Starting Plex Media Server." exec \ - s6-setuidgid abc /bin/bash -c \ + s6-setuidgid abc /bin/sh -c \ '/usr/lib/plexmediaserver/Plex\ Media\ Server' From 3740cdb35bb34f348e3275ec9e06fc1cfa286b07 Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Wed, 11 Jan 2017 21:02:40 +0000 Subject: [PATCH 7/9] retry again with /bin/bash --- root/etc/services.d/plex/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/services.d/plex/run b/root/etc/services.d/plex/run index 1b9b75a..cd91d22 100644 --- a/root/etc/services.d/plex/run +++ b/root/etc/services.d/plex/run @@ -2,7 +2,7 @@ echo "Starting Plex Media Server." exec \ - s6-setuidgid abc /bin/sh -c \ + s6-setuidgid abc /bin/bash -c \ '/usr/lib/plexmediaserver/Plex\ Media\ Server' From 55e1964bf0a7242c45563dd1e14a13c368e6d818 Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Wed, 11 Jan 2017 21:26:14 +0000 Subject: [PATCH 8/9] save up --- Dockerfile | 1 + root/etc/cont-init.d/40-chown-files | 1 - root/etc/cont-init.d/50-plex-update | 7 ------- root/etc/services.d/avahi/run | 1 - root/etc/services.d/dbus/run | 1 - root/etc/services.d/plex/run | 2 -- 6 files changed, 1 insertion(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index d74ef3b..bf0cb02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \ PLEX_MEDIA_SERVER_INFO_DEVICE=docker \ PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" \ +PLEX_MEDIA_SERVER_USER=abc \ LD_LIBRARY_PATH="/usr/lib/plexmediaserver:$LD_LIBRARY_PATH" # install packages diff --git a/root/etc/cont-init.d/40-chown-files b/root/etc/cont-init.d/40-chown-files index 6726d97..509665a 100644 --- a/root/etc/cont-init.d/40-chown-files +++ b/root/etc/cont-init.d/40-chown-files @@ -14,4 +14,3 @@ if [ ! "$(stat -c %u /config/Library)" = "$PUID" ]; then chown abc:abc -R \ /config/Library fi - diff --git a/root/etc/cont-init.d/50-plex-update b/root/etc/cont-init.d/50-plex-update index 2c181db..75174af 100644 --- a/root/etc/cont-init.d/50-plex-update +++ b/root/etc/cont-init.d/50-plex-update @@ -1,9 +1,5 @@ #!/usr/bin/with-contenv bash -# copy config on first run, regardless of update status -[[ ! -e /etc/default/plexmediaserver ]] && \ - cp /defaults/plexmediaserver /etc/default/plexmediaserver - # test if plex is installed and try re-pulling latest if not if (dpkg --get-selections plexmediaserver | grep -wq "install"); then : @@ -117,6 +113,3 @@ else dpkg -i --force-confold /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64.deb rm -f /tmp/plexmediaserver_*.deb fi - -# recopy config file -cp /defaults/plexmediaserver /etc/default/plexmediaserver diff --git a/root/etc/services.d/avahi/run b/root/etc/services.d/avahi/run index 41851f1..e438886 100644 --- a/root/etc/services.d/avahi/run +++ b/root/etc/services.d/avahi/run @@ -6,4 +6,3 @@ done echo "Starting Avahi daemon" exec avahi-daemon --no-chroot - diff --git a/root/etc/services.d/dbus/run b/root/etc/services.d/dbus/run index e2a078f..8f81ef1 100644 --- a/root/etc/services.d/dbus/run +++ b/root/etc/services.d/dbus/run @@ -2,4 +2,3 @@ echo "Starting dbus-daemon" exec dbus-daemon --system --nofork - diff --git a/root/etc/services.d/plex/run b/root/etc/services.d/plex/run index cd91d22..947921d 100644 --- a/root/etc/services.d/plex/run +++ b/root/etc/services.d/plex/run @@ -4,5 +4,3 @@ echo "Starting Plex Media Server." exec \ s6-setuidgid abc /bin/bash -c \ '/usr/lib/plexmediaserver/Plex\ Media\ Server' - - From 7b95c710b1407eb27afd6edc39d11b05ad06aeae Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Thu, 12 Jan 2017 23:01:09 +0000 Subject: [PATCH 9/9] chown the root of /config and files non-recursive --- root/etc/cont-init.d/40-chown-files | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/root/etc/cont-init.d/40-chown-files b/root/etc/cont-init.d/40-chown-files index 509665a..47ecba9 100644 --- a/root/etc/cont-init.d/40-chown-files +++ b/root/etc/cont-init.d/40-chown-files @@ -14,3 +14,8 @@ if [ ! "$(stat -c %u /config/Library)" = "$PUID" ]; then chown abc:abc -R \ /config/Library fi + +# permissions (non-recursive) on config root and folders +chown abc:abc \ + /config \ + /config/*