diff --git a/Dockerfile b/Dockerfile index 73a4632..bf0cb02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,17 @@ 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" -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_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" \ +PLEX_MEDIA_SERVER_USER=abc \ +LD_LIBRARY_PATH="/usr/lib/plexmediaserver:$LD_LIBRARY_PATH" # install packages RUN \ @@ -23,6 +27,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..47ecba9 100644 --- a/root/etc/cont-init.d/40-chown-files +++ b/root/etc/cont-init.d/40-chown-files @@ -1,12 +1,21 @@ #!/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 \ +# create folders +if [ ! -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" ]; then \ +mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" +chown -R abc:abc /config +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 \ /config/Library fi + +# permissions (non-recursive) on config root and folders +chown abc:abc \ + /config \ + /config/* 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 0a979f9..947921d 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/bash -c \ + '/usr/lib/plexmediaserver/Plex\ Media\ Server'