From 6876c06eadece58f5acacc5228c868f8385f8ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Tue, 5 May 2026 08:50:21 +0200 Subject: [PATCH] nextcloud/user_run: centralise Flatpak app ID and data dir path Introduce NC_FLATPAK_APP and NC_FLATPAK_DIR variables so the app ID and ~/.var/app path are defined once and referenced everywhere, rather than repeated as literals. Also fixes a stray leading '/' in the nextcloud.cfg grep path. Co-Authored-By: Claude Sonnet 4.6 --- .../0050_nextcloud_desktopclient/user_run.sh | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index 5dd6408..2c68fa0 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -10,7 +10,9 @@ echo "Setup Nextcloud- Sync" #Local Vars -BASECMD="/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=nextcloud com.nextcloud.desktopclient.nextcloud" +NC_FLATPAK_APP="com.nextcloud.desktopclient.nextcloud" +NC_FLATPAK_DIR="${HOME}/.var/app/${NC_FLATPAK_APP}" +BASECMD="/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=nextcloud ${NC_FLATPAK_APP}" #Check Token if [ "${DAVTOKEN_USER}." = "." ]; then @@ -21,9 +23,9 @@ fi #Remove Nextcloud from autostart anyway! Must be started by this script manually, because if it was started befor the ecrypted mount, #it will never sync and always throw an error that the local dir is missing -if [ -f "$HOME/.config/autostart/com.nextcloud.desktopclient.nextcloud.desktop" ]; then +if [ -f "$HOME/.config/autostart/${NC_FLATPAK_APP}.desktop" ]; then echo "Remove Autostart Nextcloud (old)" - rm $HOME/.config/autostart/com.nextcloud.desktopclient.nextcloud.desktop + rm $HOME/.config/autostart/${NC_FLATPAK_APP}.desktop fi # Same for NCs nuild-in autostart if [ -f "$HOME/.config/autostart/Nextcloud.desktop" ]; then @@ -34,7 +36,7 @@ fi NC_PID=$( pgrep -u $USER nextcloud ) if [ -n "${NC_PID}" ]; then echo "Stopping Nextcloud with PID ${NC_PID}" - /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=nextcloud com.nextcloud.desktopclient.nextcloud --quit >/dev/null + /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=nextcloud ${NC_FLATPAK_APP} --quit >/dev/null if [ $? -ne 0 ]; then echo "Service could not be stopped, please check why." exit 1 @@ -45,14 +47,14 @@ fi NC_PID=$( pgrep -u $USER nextcloud ) if [ -n "${NC_PID}" ]; then echo "Nextcloud still running with PID ${NC_PID}. Force stop" - # Kill does not remove lockfiles in ~/.var/app/com.nextcloud.desktopclient.nextcloud/cache/tmp/ which will prevent next start + # Kill does not remove lockfiles in ${NC_FLATPAK_DIR}/cache/tmp/ which will prevent next start kill ${NC_PID} if [ $? -ne 0 ]; then echo "Service could not be stopped, please check why." exit 1 fi sleep 0.5 - rm -rif ${HOME}/.var/app/com.nextcloud.desktopclient.nextcloud/cache/temp/* + rm -rif ${NC_FLATPAK_DIR}/cache/temp/* fi #Check if Option is Configured to use Nextcloud Desktop Data- Sync @@ -95,7 +97,7 @@ 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 + if grep -q "localPath=${CLIENT_DATA_SYNC_LINE[0]}" "${NC_FLATPAK_DIR}/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 @@ -116,8 +118,8 @@ for CLIENT_DATA_DECLARE_LINE in "${CLIENT_DATA_SYNC[@]}"; do echo "Exec: ${SYNCCMD_HIDDENPW}" 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 + rm -rif ${NC_FLATPAK_DIR}/data/Nextcloud + rm -rif ${NC_FLATPAK_DIR}/config/Nextcloud _nc_wipe_done=1 fi #Now, execute Nextcloud autoprovisionig