From 92ae5a4c8d567f73f19ba82d312ef3bd921f16a5 Mon Sep 17 00:00:00 2001 From: Patrick Double Date: Thu, 2 Jul 2015 13:28:28 -0500 Subject: [PATCH 1/6] Install avahi-daemon --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a9b2a6f..19a0424 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ CMD ["/sbin/my_init"] # Install Plex RUN apt-get -q update && \ VERSION=$(curl https://raw.githubusercontent.com/linuxserver/misc-files/master/plex-version/public) && \ -apt-get install -qy dbus gdebi-core wget && \ +apt-get install -qy dbus avahi-daemon gdebi-core wget && \ wget -P /tmp "http://downloads.plexapp.com/plex-media-server/$VERSION/plexmediaserver_${VERSION}_amd64.deb" && \ gdebi -n /tmp/plexmediaserver_${VERSION}_amd64.deb && \ rm -f /tmp/plexmediaserver_${VERSION}_amd64.deb && \ From a601ba4d0a72ebb7b65c390403399bf6797ba61e Mon Sep 17 00:00:00 2001 From: Patrick Double Date: Thu, 16 Jul 2015 16:34:12 -0500 Subject: [PATCH 2/6] Set config permissions --- init/90_uid_gid_fix.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init/90_uid_gid_fix.sh b/init/90_uid_gid_fix.sh index 1bd486e..ee2fb40 100644 --- a/init/90_uid_gid_fix.sh +++ b/init/90_uid_gid_fix.sh @@ -2,6 +2,9 @@ if [ "$(id -u abc)" != "$PUID" ]; then usermod -u "$PUID" abc ; fi if [ "$(id -g abc)" != "$PGID" ]; then groupmod -o -g "$PGID" abc ; fi +chown -R abc:abc /config +chmod ug+rw /config +find /config -type d -print0 | xargs -0 chmod ug+rwx echo " ----------------------------------- From bcca313eee7df68f1c81070c6ce621fce2bd56fb Mon Sep 17 00:00:00 2001 From: Patrick Double Date: Mon, 27 Jul 2015 14:08:05 -0500 Subject: [PATCH 3/6] Improve chown startup time --- init/90_uid_gid_fix.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/init/90_uid_gid_fix.sh b/init/90_uid_gid_fix.sh index ee2fb40..e70654f 100644 --- a/init/90_uid_gid_fix.sh +++ b/init/90_uid_gid_fix.sh @@ -2,9 +2,10 @@ if [ "$(id -u abc)" != "$PUID" ]; then usermod -u "$PUID" abc ; fi if [ "$(id -g abc)" != "$PGID" ]; then groupmod -o -g "$PGID" abc ; fi -chown -R abc:abc /config -chmod ug+rw /config -find /config -type d -print0 | xargs -0 chmod ug+rwx +find /config -not \( -user abc -a -group abc \) -exec chown abc:abc {} + +# May not be a good idea to mess with permissions set by Plex +#find /config -type f -a -perm -0660 -exec chmod ug+rw {} + +#find /config -type d -a -perm -0770 -exec chmod ug+rwx {} + echo " ----------------------------------- From 38a39c1224b5ac046a1b1f2add70bc4bf27351f9 Mon Sep 17 00:00:00 2001 From: Patrick Double Date: Tue, 28 Jul 2015 09:16:17 -0500 Subject: [PATCH 4/6] Improve performance of chown by doing a quick smoke test --- init/90_uid_gid_fix.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/init/90_uid_gid_fix.sh b/init/90_uid_gid_fix.sh index e70654f..02e31ac 100644 --- a/init/90_uid_gid_fix.sh +++ b/init/90_uid_gid_fix.sh @@ -1,11 +1,13 @@ #!/bin/bash -if [ "$(id -u abc)" != "$PUID" ]; then usermod -u "$PUID" abc ; fi -if [ "$(id -g abc)" != "$PGID" ]; then groupmod -o -g "$PGID" abc ; fi -find /config -not \( -user abc -a -group abc \) -exec chown abc:abc {} + -# May not be a good idea to mess with permissions set by Plex -#find /config -type f -a -perm -0660 -exec chmod ug+rw {} + -#find /config -type d -a -perm -0770 -exec chmod ug+rwx {} + +if [ -n "$PUID" -a "$(id -u abc)" != "$PUID" ]; then usermod -u "$PUID" abc ; fi +if [ -n "$PGID" -a "$(id -g abc)" != "$PGID" ]; then groupmod -o -g "$PGID" abc ; fi + +# There will be a lot of files in the config and searching through all of them will take a long time. +# Only Plex should modify these, so do a quick test to see if we need to search deeper. +if [ -n "$( find /config -maxdepth 2 -not \( -user abc -a -group abc \) )" ]; then + find /config -not \( -user abc -a -group abc \) -exec chown abc:abc {} + +fi echo " ----------------------------------- From f07f9d553fc9d58acb9cd8b59fe88523807c1ed8 Mon Sep 17 00:00:00 2001 From: Patrick Double Date: Wed, 5 Aug 2015 11:03:05 -0500 Subject: [PATCH 5/6] Handle case of EUID or EGID not set --- init/11_new_user.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/11_new_user.sh b/init/11_new_user.sh index b5ac305..9d0cf40 100644 --- a/init/11_new_user.sh +++ b/init/11_new_user.sh @@ -1,7 +1,7 @@ #!/bin/bash -if [ "$(id -u abc)" != "$PUID" ]; then usermod -o -u "$PUID" abc ; fi -if [ "$(id -g abc)" != "$PGID" ]; then groupmod -o -g "$PGID" abc ; fi +if [ -n "$PUID" -a "$(id -u abc)" != "$PUID" ]; then usermod -o -u "$PUID" abc ; fi +if [ -n "$PGID" -a "$(id -g abc)" != "$PGID" ]; then groupmod -o -g "$PGID" abc ; fi echo " ----------------------------------- From 2018f9046ec4c2b2553502afeeb86377107ab7f2 Mon Sep 17 00:00:00 2001 From: Patrick Double Date: Wed, 5 Aug 2015 11:03:46 -0500 Subject: [PATCH 6/6] Handle empty /config, pass multiple args to chown --- init/99_chown_plex_owned_files.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/init/99_chown_plex_owned_files.sh b/init/99_chown_plex_owned_files.sh index 66a976e..f7d37fc 100644 --- a/init/99_chown_plex_owned_files.sh +++ b/init/99_chown_plex_owned_files.sh @@ -2,6 +2,9 @@ if [ -d "/config/Library" ]; then -find /config/Library ! \( -user abc -a -group abc \) -exec chown -hv abc:abc {} \; +find /config/Library ! \( -user abc -a -group abc \) -exec chown -hv abc:abc {} + +else +mkdir /config/Library +chown abc:abc /config/Library fi