Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not overwrite existing data when creating initial directories. #2063

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions 25/apache/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rsync_options="-rlD"
fi

if [ "$installed_version" = "0.0.0.0" ]; then
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
echo "New instance and /var/www/html is not empty, refusing to overwrite existing files."
exit 1
fi
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /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
Expand Down
7 changes: 7 additions & 0 deletions 25/fpm-alpine/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rsync_options="-rlD"
fi

if [ "$installed_version" = "0.0.0.0" ]; then
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
echo "New instance and /var/www/html is not empty, refusing to overwrite existing files."
exit 1
fi
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /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
Expand Down
7 changes: 7 additions & 0 deletions 25/fpm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rsync_options="-rlD"
fi

if [ "$installed_version" = "0.0.0.0" ]; then
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
echo "New instance and /var/www/html is not empty, refusing to overwrite existing files."
exit 1
fi
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /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
Expand Down
7 changes: 7 additions & 0 deletions 26/apache/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rsync_options="-rlD"
fi

if [ "$installed_version" = "0.0.0.0" ]; then
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
echo "New instance and /var/www/html is not empty, refusing to overwrite existing files."
exit 1
fi
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /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
Expand Down
7 changes: 7 additions & 0 deletions 26/fpm-alpine/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rsync_options="-rlD"
fi

if [ "$installed_version" = "0.0.0.0" ]; then
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
echo "New instance and /var/www/html is not empty, refusing to overwrite existing files."
exit 1
fi
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /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
Expand Down
7 changes: 7 additions & 0 deletions 26/fpm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rsync_options="-rlD"
fi

if [ "$installed_version" = "0.0.0.0" ]; then
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
echo "New instance and /var/www/html is not empty, refusing to overwrite existing files."
exit 1
fi
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /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
Expand Down
7 changes: 7 additions & 0 deletions 27/apache/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rsync_options="-rlD"
fi

if [ "$installed_version" = "0.0.0.0" ]; then
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
echo "New instance and /var/www/html is not empty, refusing to overwrite existing files."
exit 1
fi
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /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
Expand Down
7 changes: 7 additions & 0 deletions 27/fpm-alpine/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rsync_options="-rlD"
fi

if [ "$installed_version" = "0.0.0.0" ]; then
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
echo "New instance and /var/www/html is not empty, refusing to overwrite existing files."
exit 1
fi
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /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
Expand Down
7 changes: 7 additions & 0 deletions 27/fpm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rsync_options="-rlD"
fi

if [ "$installed_version" = "0.0.0.0" ]; then
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
echo "New instance and /var/www/html is not empty, refusing to overwrite existing files."
exit 1
fi
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /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
Expand Down
7 changes: 7 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
rsync_options="-rlD"
fi

if [ "$installed_version" = "0.0.0.0" ]; then
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [ -n "$(ls -1 -A /var/www/html | grep -v -w "nextcloud-init-sync.lock")" ]; then
if find /var/www/html -type f | grep -F -q -v "nextcloud-init-sync.lock"; then

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find could be really slow here, I prefer to just use ls.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use -maxdepth 1

echo "New instance and /var/www/html is not empty, refusing to overwrite existing files."
exit 1
fi
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /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
Expand Down