From 38a39c1224b5ac046a1b1f2add70bc4bf27351f9 Mon Sep 17 00:00:00 2001 From: Patrick Double Date: Tue, 28 Jul 2015 09:16:17 -0500 Subject: [PATCH] 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 " -----------------------------------