From e8c869f10983859deeab5b88ef62aaa095c597c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Mon, 4 May 2026 13:48:08 +0200 Subject: [PATCH] nextcloud/user_run: wipe config only once for first new sync folder Config wipe now guarded by _nc_wipe_done flag so subsequent new entries do not destroy the previous setup. _nc_first logic kept as comments for later activation when multi-folder support is confirmed working. Co-Authored-By: Claude Sonnet 4.6 --- .../0050_nextcloud_desktopclient/user_run.sh | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index 5a7e50f..2abf296 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -61,20 +61,22 @@ if [ "${#CLIENT_DATA_SYNC[@]}" -eq 0 ]; then fi #Loop through all Entries -_nc_first=1 +#_nc_first=1 +_nc_wipe_done=0 for CLIENT_DATA_DECLARE_LINE in "${CLIENT_DATA_SYNC[@]}"; do eval "${CLIENT_DATA_DECLARE_LINE}" # echo "DEBUG user_run.sh(0020)_2: ${CLIENT_DATA_SYNC_LINE[@]}" # Now, CLIENT_DATA_SYNC_LINE[0] contains the local path and CLIENT_DATA_SYNC_LINE[1] contains the remote path if grep -q "localPath=${CLIENT_DATA_SYNC_LINE[0]}" "/${HOME}/.var/app/com.nextcloud.desktopclient.nextcloud/config/Nextcloud/nextcloud.cfg"; then echo "Already found configured local folder ${CLIENT_DATA_SYNC_LINE[0]} syncing with ${CLIENT_DATA_SYNC_LINE[1]} . Leaving it unchanged." +# _nc_first=0 else echo "Setup new sync from remote ${CLIENT_DATA_SYNC_LINE[1]} to local ${CLIENT_DATA_SYNC_LINE[0]}" - if [ "${_nc_first}" -eq 0 ]; then - echo "Due to Bug in Nextcloud Client, more than one synced Folder cannot be setup currently. Maybe in the Future." - continue - fi - _nc_first=0 +# if [ "${_nc_first}" -eq 0 ]; then +# echo "Due to Bug in Nextcloud Client, more than one synced Folder cannot be setup currently. Maybe in the Future." +# continue +# fi +# _nc_first=0 if [ -d "${CLIENT_DATA_SYNC_LINE[0]}" ]; then echo "Old unsynced Folder ${CLIENT_DATA_SYNC_LINE[0]} was found, renaming to ${CLIENT_DATA_SYNC_LINE[0]}_bak." mv "${CLIENT_DATA_SYNC_LINE[0]}" "${CLIENT_DATA_SYNC_LINE[0]}_bak" @@ -83,11 +85,14 @@ for CLIENT_DATA_DECLARE_LINE in "${CLIENT_DATA_SYNC[@]}"; do SYNCCMD="$BASECMD --userid ${DAVTOKEN_USER} --apppassword ${DAVTOKEN_PASS} --localdirpath ${CLIENT_DATA_SYNC_LINE[0]} --remotedirpath ${CLIENT_DATA_SYNC_LINE[1]} --serverurl https://${SERVERFQDN_NC}" SYNCCMD_HIDDENPW=$( echo "${SYNCCMD/${DAVTOKEN_PASS}/***HIDDEN***}" ) echo "Exec: ${SYNCCMD_HIDDENPW}" - # Due to Bugs in Nextcloud, autoprovisioning will only work when no configuration is existent. Therefore delete any exitsing configs that may be there - rm -rif ${HOME}/.var/app/com.nextcloud.desktopclient.nextcloud/data/Nextcloud - rm -rif ${HOME}/.var/app/com.nextcloud.desktopclient.nextcloud/config/Nextcloud + if [ "${_nc_wipe_done}" -eq 0 ]; then + # Autoprovisioning only works when no configuration is existent — wipe once before first new setup + rm -rif ${HOME}/.var/app/com.nextcloud.desktopclient.nextcloud/data/Nextcloud + rm -rif ${HOME}/.var/app/com.nextcloud.desktopclient.nextcloud/config/Nextcloud + _nc_wipe_done=1 + fi #Now, execute Nextcloud autoprovisionig - ${SYNCCMD} + ${SYNCCMD} && sleep 0.5 if [ $? -ne 0 ]; then echo "=========== !!! ========================" echo "Error: It looks like this did not work!"