From 54a0fdbb44cf3db73ae3f7e6fcddf480af163769 Mon Sep 17 00:00:00 2001 From: Alvaro Aleman Date: Sun, 6 Nov 2016 00:37:44 +0100 Subject: [PATCH] Make nextcloud chown idempotent (#62) * Make nextcloud chown idempotent * Remove redundant chowns in nextcloud images --- nextcloud/10.0-armhf/run.sh | 8 +++++--- nextcloud/10.0/run.sh | 8 +++++--- nextcloud/daily-armhf/run.sh | 8 +++++--- nextcloud/daily/run.sh | 8 +++++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/nextcloud/10.0-armhf/run.sh b/nextcloud/10.0-armhf/run.sh index 2c2144f..48aa6da 100644 --- a/nextcloud/10.0-armhf/run.sh +++ b/nextcloud/10.0-armhf/run.sh @@ -10,7 +10,11 @@ sed -i -e "s//$UPLOAD_MAX_SIZE/g" /etc/nginx/nginx.conf /etc/ph ln -sf /config/config.php /nextcloud/config/config.php &>/dev/null ln -sf /apps2 /nextcloud &>/dev/null -chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /var/lib/redis /tmp /etc/s6.d +for dir in /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /var/lib/redis /tmp /etc/s6.d; do + if $(find $dir ! -user $UID -o ! -group $GID|egrep '.' -q); then + chown -R $UID:$GID $dir + fi +done if [ ! -f /config/config.php ]; then # New installation, run the setup @@ -26,6 +30,4 @@ else fi fi -chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /etc/s6.d - exec su-exec $UID:$GID /bin/s6-svscan /etc/s6.d diff --git a/nextcloud/10.0/run.sh b/nextcloud/10.0/run.sh index 2c2144f..48aa6da 100644 --- a/nextcloud/10.0/run.sh +++ b/nextcloud/10.0/run.sh @@ -10,7 +10,11 @@ sed -i -e "s//$UPLOAD_MAX_SIZE/g" /etc/nginx/nginx.conf /etc/ph ln -sf /config/config.php /nextcloud/config/config.php &>/dev/null ln -sf /apps2 /nextcloud &>/dev/null -chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /var/lib/redis /tmp /etc/s6.d +for dir in /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /var/lib/redis /tmp /etc/s6.d; do + if $(find $dir ! -user $UID -o ! -group $GID|egrep '.' -q); then + chown -R $UID:$GID $dir + fi +done if [ ! -f /config/config.php ]; then # New installation, run the setup @@ -26,6 +30,4 @@ else fi fi -chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /etc/s6.d - exec su-exec $UID:$GID /bin/s6-svscan /etc/s6.d diff --git a/nextcloud/daily-armhf/run.sh b/nextcloud/daily-armhf/run.sh index 2c2144f..48aa6da 100644 --- a/nextcloud/daily-armhf/run.sh +++ b/nextcloud/daily-armhf/run.sh @@ -10,7 +10,11 @@ sed -i -e "s//$UPLOAD_MAX_SIZE/g" /etc/nginx/nginx.conf /etc/ph ln -sf /config/config.php /nextcloud/config/config.php &>/dev/null ln -sf /apps2 /nextcloud &>/dev/null -chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /var/lib/redis /tmp /etc/s6.d +for dir in /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /var/lib/redis /tmp /etc/s6.d; do + if $(find $dir ! -user $UID -o ! -group $GID|egrep '.' -q); then + chown -R $UID:$GID $dir + fi +done if [ ! -f /config/config.php ]; then # New installation, run the setup @@ -26,6 +30,4 @@ else fi fi -chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /etc/s6.d - exec su-exec $UID:$GID /bin/s6-svscan /etc/s6.d diff --git a/nextcloud/daily/run.sh b/nextcloud/daily/run.sh index 2c2144f..48aa6da 100644 --- a/nextcloud/daily/run.sh +++ b/nextcloud/daily/run.sh @@ -10,7 +10,11 @@ sed -i -e "s//$UPLOAD_MAX_SIZE/g" /etc/nginx/nginx.conf /etc/ph ln -sf /config/config.php /nextcloud/config/config.php &>/dev/null ln -sf /apps2 /nextcloud &>/dev/null -chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /var/lib/redis /tmp /etc/s6.d +for dir in /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /var/lib/redis /tmp /etc/s6.d; do + if $(find $dir ! -user $UID -o ! -group $GID|egrep '.' -q); then + chown -R $UID:$GID $dir + fi +done if [ ! -f /config/config.php ]; then # New installation, run the setup @@ -26,6 +30,4 @@ else fi fi -chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /etc/s6.d - exec su-exec $UID:$GID /bin/s6-svscan /etc/s6.d