summaryrefslogtreecommitdiffstats
path: root/12.0/fpm/docker-entrypoint.sh
diff options
context:
space:
mode:
Diffstat (limited to '12.0/fpm/docker-entrypoint.sh')
-rwxr-xr-x12.0/fpm/docker-entrypoint.sh34
1 files changed, 19 insertions, 15 deletions
diff --git a/12.0/fpm/docker-entrypoint.sh b/12.0/fpm/docker-entrypoint.sh
index f073581e..9298bb47 100755
--- a/12.0/fpm/docker-entrypoint.sh
+++ b/12.0/fpm/docker-entrypoint.sh
@@ -11,6 +11,13 @@ function directory_empty() {
[ -n "$(find "$1"/ -prune -empty)" ]
}
+function run_as() {
+ if [[ $EUID -eq 0 ]]; then
+ su - www-data -s /bin/bash -c "$1"
+ else
+ bash -c "$1"
+ fi
+}
installed_version="0.0.0~unknown"
if [ -f /var/www/html/version.php ]; then
@@ -25,28 +32,25 @@ fi
if version_greater "$image_version" "$installed_version"; then
if [ "$installed_version" != "0.0.0~unknown" ]; then
- su - www-data -s /bin/bash -c 'php /var/www/html/occ app:list' > /tmp/list_before
+ run_as 'php /var/www/html/occ app:list' > /tmp/list_before
+ fi
+ if [[ $EUID -eq 0 ]]; then
+ rsync_options="-rlDog --chown www-data:root"
+ else
+ rsync_options="-rlD"
fi
- rsync -a --delete --exclude /config/ --exclude /data/ --exclude /custom_apps/ --exclude /themes/ /usr/src/nextcloud/ /var/www/html/
-
- for dir in config data themes; do
+ rsync $rsync_options --delete --exclude /config/ --exclude /data/ --exclude /custom_apps/ --exclude /themes/ /usr/src/nextcloud/ /var/www/html/
+
+ for dir in config data custom_apps themes; do
if [ ! -d /var/www/html/"$dir" ] || directory_empty /var/www/html/"$dir"; then
- cp -arT /usr/src/nextcloud/"$dir" /var/www/html/"$dir"
+ rsync $rsync_options --include /"$dir"/ --exclude '/*' /usr/src/nextcloud/ /var/www/html/
fi
done
- if [ ! -d /var/www/html/custom_apps ] && [ ! -f /var/www/html/config/apps.config.php ]; then
- cp -a /usr/src/nextcloud/config/apps.config.php /var/www/html/config/apps.config.php
- fi
-
- if [ ! -d /var/www/html/custom_apps ] || directory_empty /var/www/html/custom_apps; then
- cp -arT /usr/src/nextcloud/custom_apps /var/www/html/custom_apps
- fi
-
if [ "$installed_version" != "0.0.0~unknown" ]; then
- su - www-data -s /bin/bash -c 'php /var/www/html/occ upgrade --no-app-disable'
+ run_as 'php /var/www/html/occ upgrade --no-app-disable'
- su - www-data -s /bin/bash -c 'php /var/www/html/occ app:list' > /tmp/list_after
+ run_as 'php /var/www/html/occ app:list' > /tmp/list_after
echo "The following apps have beed disabled:"
diff <(sed -n "/Enabled:/,/Disabled:/p" /tmp/list_before) <(sed -n "/Enabled:/,/Disabled:/p" /tmp/list_after) | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after