From 64f2abcdd11defa69d48199682fec93eb9cbe753 Mon Sep 17 00:00:00 2001 From: Lucas Media Date: Mon, 26 Oct 2026 18:55:04 +0100 Subject: [PATCH] feat(syncNC): waiting function for psgrep nextcloud wait 3x20s for nextcloudcmds to finish before exiting --- nextcloud/syncNC.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/nextcloud/syncNC.sh b/nextcloud/syncNC.sh index c3bf588..7cd46a1 100755 --- a/nextcloud/syncNC.sh +++ b/nextcloud/syncNC.sh @@ -250,6 +250,20 @@ sync_all() { return 1 } +wait_for_nextcloud() { + for _ in {1..3}; do + if ! pgrep -x "nextcloudcmd" >/dev/null; then + return 0 + fi + + echo "Nextcloud sync is already active, waiting 20 seconds..." + sleep 20 + done + + echo "Nextcloud sync is still active after 3 retries, stopping." + return 1 +} + main() { parse_args "$@" validate_sync_options @@ -262,11 +276,7 @@ main() { die "Cannot read credentials file: $NETRC" fi - if pgrep -x "nextcloudcmd" >/dev/null; then - echo "Nextcloud sync is already active, stopping." - return 1 - fi - + wait_for_nextcloud echo "Starting Nextcloud synchronization..." sync_all