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

feat(entrypoint): add debug mode for entrypoint #2311

Open
wants to merge 3 commits 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,15 @@ docker exec container-name chown -R www-data:root /var/www/html
```

After changing the permissions, restart the container and the permission errors should disappear.

# Troubleshooting

The Nextcloud image entrypoint supports a debug (verbose) mode that can be toggled on via an environment variable. This can be used to troubleshoot container start-up, Nextcloud installation, entrypoint changes, etc.

- `IMAGE_DEBUG=1`

Note the container log will be highly verbose with this on!

# Help (Questions / Issues)

**If you have any questions or problems while using the image, please ask for assistance on the Help Forum first (https://help.nextcloud.com)**.
Expand Down
22 changes: 18 additions & 4 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/sh
set -eu

if [ -n "${IMAGE_DEBUG+x}" ]; then
echo "**Image debugging enabled**"
set -x
fi

# version_greater A B returns whether A > B
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ]
Expand Down Expand Up @@ -165,10 +170,14 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "Upgrading nextcloud from $installed_version ..."
run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before
fi
rsync_options=''
if [ -n "${IMAGE_DEBUG+x}" ]; then
rsync_options='-vv'
fi
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown $user:$group"
rsync_options="$rsync_options -rlDog --chown $user:$group"
else
rsync_options="-rlD"
rsync_options="$rsync_options -rlD"
fi

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/
Expand All @@ -188,8 +197,12 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP

install=false
if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then
install_options=''
if [ -n "${IMAGE_DEBUG+x}" ]; then
install_options='-v '
fi
# shellcheck disable=SC2016
install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"'
install_options=$install_options'-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"'
if [ -n "${NEXTCLOUD_DATA_DIR+x}" ]; then
# shellcheck disable=SC2016
install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"'
Expand Down Expand Up @@ -227,9 +240,10 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
try=0
until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options"
do
echo "Retrying install..."
echo "Nextcloud installation failed; will retry in 10s..."
try=$((try+1))
sleep 10s
echo "Retrying nextcloud install now... ($try of $max_retries attempts)"
done
if [ "$try" -gt "$max_retries" ]; then
echo "Installing of nextcloud failed!"
Expand Down
Loading