From 97c034e31bdc3dabb16c214196190a59ca888c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 13:08:07 +0200 Subject: [PATCH 01/27] install.sh: add existing OEMDRV reuse, git origin conflict handling, refined permissions - Detect existing OEMDRV partition at startup; offer to reuse it instead of creating a new one (mounts if needed, sources existing setup_system.inc.sh before cloning) - When existing repo origin/branch differs from REPO_URL/REPO_BRANCH, offer to pull from existing origin, migrate to new origin (preserving gitignored local files), or fall through to fresh clone - Extract finish_install() and do_clone_and_done() helpers to share clone, permissions, and configure.sh prompt across all paths - Replace generic chmod with chown root:root + chmod ug=rwX,o=rX recursively, plus o+w on config/ and config.d/ Co-Authored-By: Claude Sonnet 4.6 --- system_setup/install.sh | 174 +++++++++++++----- {config => system_setup/skel}/pack_skel.sh | 0 .../skel}/skel.tar.zst.dist | Bin 3 files changed, 131 insertions(+), 43 deletions(-) rename {config => system_setup/skel}/pack_skel.sh (100%) rename {config => system_setup/skel}/skel.tar.zst.dist (100%) diff --git a/system_setup/install.sh b/system_setup/install.sh index ee7293e..865cb70 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -24,6 +24,51 @@ die() { echo; echo "ERROR: $*" >&2; exit 1; } info() { echo; echo ">>> $*"; } hr() { printf '%.0s─' {1..100}; echo; } +finish_install() { + local dev="$1" + + chown root:root "$MOUNT_POINT" -R + chmod ug=rwX,o=rX "$MOUNT_POINT" -R + chmod o+w "$MOUNT_POINT/config" "$MOUNT_POINT/config.d" + + info "Done." + echo + echo " OEMDRV device : $dev" + echo " Mounted at : $MOUNT_POINT" + echo + + CONF_SCRIPT="$MOUNT_POINT/system_setup/configure.sh" + + echo + read -r -p "Run configure.sh now to set up your environment? [y/N]: " RUN_CONF + if [[ "${RUN_CONF,,}" == "y" ]]; then + if [[ -n "$SUDO_USER" ]]; then + info "Running configure.sh as user '$SUDO_USER'..." + su - "$SUDO_USER" -c "DISPLAY='${DISPLAY}' WAYLAND_DISPLAY='${WAYLAND_DISPLAY}' bash '$CONF_SCRIPT'" + else + echo + echo "configure.sh must be run as a non-root user. Please run:" + echo " bash $CONF_SCRIPT" + fi + else + echo + echo "Next steps:" + echo " 1. Run: bash $CONF_SCRIPT" + echo " 2. Boot the Kickstart installer — it will detect the OEMDRV partition automatically." + echo + fi +} + +do_clone_and_done() { + local dev="$1" + + info "Cloning $REPO_URL into $MOUNT_POINT..." + cd "$MOUNT_POINT" || die "Cannot cd to $MOUNT_POINT." + git clone --progress --depth 1 -b $REPO_BRANCH "$REPO_URL" . || die "git clone failed." + source "$(dirname "$0")/setup_system.inc.sh" + finish_install "$dev" +} + require_root() { [[ "$EUID" -eq 0 ]] || die "This script must be run as root." } @@ -293,6 +338,90 @@ new_part_device() { require_root check_tools +# ── Check for existing OEMDRV partition ─────────────────────────────────────── + +EXISTING_OEMDRV_DEV=$(blkid -L "$OEMDRV_LABEL" 2>/dev/null || true) +if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then + echo + echo "Found existing '$OEMDRV_LABEL' partition: $EXISTING_OEMDRV_DEV" + read -r -p " Use this partition and overwrite its install files? [y/N]: " ans + if [[ "${ans,,}" == "y" ]]; then + EXISTING_MNT=$(lsblk -n -o MOUNTPOINT "$EXISTING_OEMDRV_DEV" 2>/dev/null | grep -v '^$' | head -1) + if [[ -n "$EXISTING_MNT" ]]; then + echo " Partition is already mounted at $EXISTING_MNT — using that mountpoint." + MOUNT_POINT="$EXISTING_MNT" + else + info "Mounting $EXISTING_OEMDRV_DEV to $MOUNT_POINT..." + [[ -d "$MOUNT_POINT" ]] || mkdir -p "$MOUNT_POINT" + mount -o "$MOUNT_OPTS" "$EXISTING_OEMDRV_DEV" "$MOUNT_POINT" || die "mount failed." + fi + + if [[ -f "$MOUNT_POINT/system_setup/setup_system.inc.sh" ]]; then + info "Sourcing existing setup_system.inc.sh..." + pushd "$MOUNT_POINT/system_setup" > /dev/null + source setup_system.inc.sh + popd > /dev/null + fi + + # ── Check existing git repository origin ────────────────────────────── + if git -C "$MOUNT_POINT" rev-parse --git-dir >/dev/null 2>&1; then + EXIST_URL=$(git -C "$MOUNT_POINT" remote get-url origin 2>/dev/null || true) + EXIST_BRANCH=$(git -C "$MOUNT_POINT" symbolic-ref --short HEAD 2>/dev/null \ + || git -C "$MOUNT_POINT" rev-parse --abbrev-ref HEAD 2>/dev/null || true) + if [[ -n "$EXIST_URL" && ( "$EXIST_URL" != "$REPO_URL" || "$EXIST_BRANCH" != "$REPO_BRANCH" ) ]]; then + echo + echo " The existing repository differs from the configured values:" + printf " %-12s %-55s %s\n" "" "Origin" "Branch" + printf " %-12s %-55s %s\n" "Existing:" "$EXIST_URL" "$EXIST_BRANCH" + printf " %-12s %-55s %s\n" "Configured:" "$REPO_URL" "$REPO_BRANCH" + echo + echo " How should this be resolved?" + echo " 1) Keep existing origin/branch — pull latest from $EXIST_URL / $EXIST_BRANCH" + echo " 2) Switch to configured origin — migrate to $REPO_URL / $REPO_BRANCH (preserves local files)" + echo " 3) Fresh clone from configured origin — clears all existing content" + read -r -p " Choice [1/2/3]: " GIT_CHOICE + case "${GIT_CHOICE}" in + 1) + REPO_URL="$EXIST_URL" + REPO_BRANCH="$EXIST_BRANCH" + info "Fetching latest from $REPO_URL (branch: $REPO_BRANCH)..." + git -C "$MOUNT_POINT" fetch --depth 1 origin "$REPO_BRANCH" \ + || die "git fetch failed." + git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \ + || die "git checkout failed." + source "$MOUNT_POINT/system_setup/setup_system.inc.sh" + finish_install "$EXISTING_OEMDRV_DEV" + exit 0 + ;; + 2) + info "Switching origin to $REPO_URL (branch: $REPO_BRANCH)..." + git -C "$MOUNT_POINT" remote set-url origin "$REPO_URL" \ + || die "git remote set-url failed." + git -C "$MOUNT_POINT" fetch --depth 1 origin "$REPO_BRANCH" \ + || die "git fetch failed." + git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \ + || die "git checkout failed." + source "$MOUNT_POINT/system_setup/setup_system.inc.sh" + finish_install "$EXISTING_OEMDRV_DEV" + exit 0 + ;; + *) + # Option 3 or anything else: fall through to clear + fresh clone + ;; + esac + fi + fi + + if [[ -n "$(ls -A "$MOUNT_POINT" 2>/dev/null)" ]]; then + info "Clearing existing content in $MOUNT_POINT before fresh clone..." + find "$MOUNT_POINT" -mindepth 1 -delete + fi + + do_clone_and_done "$EXISTING_OEMDRV_DEV" + exit 0 + fi +fi + info "Verifying repository URL..." check_repo_url case $? in @@ -497,47 +626,6 @@ info "Mounting $OEMDRV_DEV to $MOUNT_POINT (options: $MOUNT_OPTS)..." [[ -d "$MOUNT_POINT" ]] || mkdir -p "$MOUNT_POINT" mount -o "$MOUNT_OPTS" "$OEMDRV_DEV" "$MOUNT_POINT" || die "mount failed." -# ── Clone repository ────────────────────────────────────────────────────────── +# ── Clone repository + done ─────────────────────────────────────────────────── -info "Cloning $REPO_URL into $MOUNT_POINT..." -cd "$MOUNT_POINT" || die "Cannot cd to $MOUNT_POINT." -git clone --progress --depth 1 -b $REPO_BRANCH "$REPO_URL" . || die "git clone failed." - -# Write hardware UUID to a user-readable per-machine file -dmidecode -t system | grep -i 'UUID' \ - | sed 's/UUID: //' | tr '[:upper:]' '[:lower:]' \ - | sed 's/[^0-9a-z]*//g' | xargs | tail -c 13 \ - > "./config.d/machine_uuid.sys" - - chmod o=rwX . -R # to make changes to the configuration possible after install - -# ── Done ────────────────────────────────────────────────────────────────────── - -info "Done." -echo -echo " OEMDRV device : $OEMDRV_DEV" -echo " Mounted at : $MOUNT_POINT" -echo - -# ── Optionally run configure.sh ─────────────────────────────────────────────── - -CONF_SCRIPT="$MOUNT_POINT/system_setup/configure.sh" - -echo -read -r -p "Run configure.sh now to set up your environment? [y/N]: " RUN_CONF -if [[ "${RUN_CONF,,}" == "y" ]]; then - if [[ -n "$SUDO_USER" ]]; then - info "Running configure.sh as user '$SUDO_USER'..." - su - "$SUDO_USER" -c "DISPLAY='${DISPLAY}' WAYLAND_DISPLAY='${WAYLAND_DISPLAY}' bash '$CONF_SCRIPT'" - else - echo - echo "configure.sh must be run as a non-root user. Please run:" - echo " bash $CONF_SCRIPT" - fi -else - echo - echo "Next steps:" - echo " 1. Run: bash $CONF_SCRIPT" - echo " 2. Boot the Kickstart installer — it will detect the OEMDRV partition automatically." - echo -fi +do_clone_and_done "$OEMDRV_DEV" diff --git a/config/pack_skel.sh b/system_setup/skel/pack_skel.sh similarity index 100% rename from config/pack_skel.sh rename to system_setup/skel/pack_skel.sh diff --git a/config/skel.tar.zst.dist b/system_setup/skel/skel.tar.zst.dist similarity index 100% rename from config/skel.tar.zst.dist rename to system_setup/skel/skel.tar.zst.dist From 9264ca8e92d5b9fff8c884b0d1495198d7d8786c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 13:28:44 +0200 Subject: [PATCH 02/27] Relocate dist files, fix path references, and misc script improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move setup_system.conf.dist to system_setup/config.dist/ and skel.tar.zst.dist + pack_skel.sh to system_setup/skel/; config/ now holds only gitignored local files - Fix configure.sh CONF_DIST path (was pointing at non-existent config/setup_system.conf.dist) - Fix skel/pack_skel.sh: remove vestigial source line whose path was wrong in both old and new location - Update error messages in setup_system.inc.sh and sync_client_software.sh to reference new dist file location - Move machine_uuid reading/writing into setup_system.inc.sh so all scripts have MACHINEID available; setup_system.conf.dist now uses MACHINEID conditionally with a hostname fallback - sync_client_software.sh: fix && / typo (should be && \) that broke the flatpak remote-add → install chain; add network error handling after flatpak install; cleanup upgrade logic and chown placement - Update CLAUDE.md and install.md to reflect new dist file locations Co-Authored-By: Claude Sonnet 4.6 --- CLAUDE.md | 8 ++--- install.md | 2 +- .../config.dist}/setup_system.conf.dist | 15 +++++----- system_setup/configure.sh | 2 +- system_setup/setup_skel.sh | 2 +- system_setup/setup_system.inc.sh | 15 +++++++++- system_setup/skel/pack_skel.sh | 1 - system_setup/sync_client_software.sh | 29 ++++++++++++------- 8 files changed, 47 insertions(+), 27 deletions(-) rename {config => system_setup/config.dist}/setup_system.conf.dist (90%) diff --git a/CLAUDE.md b/CLAUDE.md index 3bdc345..23c46af 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -13,16 +13,16 @@ A Fedora automated mass-installation and post-setup scripting collection. It use Before any script runs, copy the dist file and fill in your environment: ```sh -cp /opt/sys_config/config/setup_system.conf.dist /opt/sys_config/config/setup_system.conf +cp /opt/sys_config/system_setup/config.dist/setup_system.conf.dist /opt/sys_config/config/setup_system.conf # Edit setup_system.conf with your domain, server FQDNs, paths, etc. ``` Local per-machine overrides go in `config.d/*.conf` (gitignored). These are sourced after `setup_system.conf` and can override any exported variable (e.g. `config.d/system_defines.conf` overrides `UPGRADEBRANCH`). -`config/skel.tar.zst` (gitignored) holds the `/etc/skel` archive deployed to new installs. The `.dist` version is the default. To modify skel: extract, edit, then repack: +`config/skel.tar.zst` (gitignored) holds the `/etc/skel` archive deployed to new installs. The `.dist` version is at `system_setup/skel/skel.tar.zst.dist`. To modify skel: extract, edit, then repack: ```sh cd /opt/sys_config/config -tar -I 'zstd -9' -cf skel.tar.zst skel/ # or use pack_skel.sh +tar -I 'zstd -9' -cf skel.tar.zst skel/ # or use system_setup/skel/pack_skel.sh ``` ## Installation lifecycle @@ -51,7 +51,7 @@ tar -I 'zstd -9' -cf skel.tar.zst skel/ # or use pack_skel.sh | `system_setup/mount_ecrypt_home.sh` | user | called by logon_script.sh | | `system_setup/mozilla_starter.sh` | user | called by logon_script.sh; args: `firefox\|thunderbird run\|sync [profile]` | | `system_setup/setup_skel.sh` | root | called by setup_system_full.sh or manually | -| `config/pack_skel.sh` | root | manually, to repack skel archive after editing | +| `system_setup/skel/pack_skel.sh` | root | manually, to repack skel archive after editing | | `system_setup/create_nc_package_from_sys_config.sh` | user | manually, creates `~/temp/sys_config.tar.zst` | ## client_software layout diff --git a/install.md b/install.md index 6a9a284..8703b3b 100644 --- a/install.md +++ b/install.md @@ -44,7 +44,7 @@ Both are optional. That way, install.sh should know what to pull. Configure your environment before running any installation: ```sh -cp /opt/sys_config/config/setup_system.conf.dist /opt/sys_config/config/setup_system.conf +cp /opt/sys_config/system_setup/config.dist/setup_system.conf.dist /opt/sys_config/config/setup_system.conf # Edit setup_system.conf — set TLDOMAIN, SERVERFQDN_IPA, SERVERFQDN_NC, and paths. ``` diff --git a/config/setup_system.conf.dist b/system_setup/config.dist/setup_system.conf.dist similarity index 90% rename from config/setup_system.conf.dist rename to system_setup/config.dist/setup_system.conf.dist index 6cb1fcd..08b541b 100644 --- a/config/setup_system.conf.dist +++ b/system_setup/config.dist/setup_system.conf.dist @@ -21,14 +21,13 @@ export DISTCONFIGPATH_SRC="/Shared/sw_geteilt/client_settings" export CLIENTADMINGROUP="clientadmins" # Method to determine Unique Hostname / FQDN of the Client. May be replaced by your needs -#Should always had been set by install.sh and should be there anyway. -#if [ ! -r ${SYSCONFIGPATH}/config.d/machine_uuid.sys ]; then -#elif [ "$EUID" -eq 0 ]; then -# export HOSTNM="pc-$( dmidecode -t system | grep -i 'UUID' | sed 's/UUID: //' | tr '[:upper:]' '[:lower:]' | sed 's/[^0-9a-z]*//g' | xargs|tail -c 13)" -#else -# export HOSTNM=$( hostname -s ) -#fi -export HOSTNM="pc-$( cat /opt/sys_config/config.d/machine_uuid.sys )" +# MACHINEID should be set by install.sh. The Determination is done by setup_system.inc.sh as root for old installs. +if [ -z ${MACHINEID} ]; then + #Fallback if not configured, should only be needed once for very old installations + export HOSTNM=$( hostname -s ) +else + export HOSTNM="pc-${MACHINEID}" +fi export FQDN=${HOSTNM}.${DOMAIN} #Additional Client-Software- Repository-Folder in Nextcloud (Shared Folder / Systemwide) diff --git a/system_setup/configure.sh b/system_setup/configure.sh index 557c449..2850479 100755 --- a/system_setup/configure.sh +++ b/system_setup/configure.sh @@ -5,7 +5,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" -CONF_DIST="${SCRIPTDIR}/../config/setup_system.conf.dist" +CONF_DIST="${SCRIPTDIR}/config.dist/setup_system.conf.dist" CONF_FILE="${SCRIPTDIR}/../config.d/configure.conf" if [[ "$EUID" -eq 0 ]]; then diff --git a/system_setup/setup_skel.sh b/system_setup/setup_skel.sh index f5e9cf5..494da91 100755 --- a/system_setup/setup_skel.sh +++ b/system_setup/setup_skel.sh @@ -3,7 +3,7 @@ source $(dirname "$0")/setup_system.inc.sh EXECDIR=$(pwd) SRCFILE="${SYSCONFIGPATH}/config/skel.tar.zst" -SRCFILEDIST="${SYSCONFIGPATH}/config/skel.tar.zst.dist" +SRCFILEDIST="$(dirname "$0")/skel/skel.tar.zst.dist" #Check for root if [ "$EUID" -ne 0 ]; then diff --git a/system_setup/setup_system.inc.sh b/system_setup/setup_system.inc.sh index 6256c27..590e4c2 100755 --- a/system_setup/setup_system.inc.sh +++ b/system_setup/setup_system.inc.sh @@ -16,6 +16,19 @@ # return 0 #} +#First, get the machine_uuid wich is needed by some userspace programs. +#As all Parameters that are bound to CPU or Mainboard, are only readable by root, we need to get the values at installtime. +#On old installations without the file, we will write it whenever possible +if [ -f $( dirname "$0" )/config.d/machine_uuid.sys ]; then + export MACHINEID="$( cat $( dirname "$0" )/config.d/machine_uuid.sys )" +elif [ "$EUID" -eq 0 ]; then + dmidecode -t system | grep -i 'UUID' \ + | sed 's/UUID: //' | tr '[:upper:]' '[:lower:]' \ + | sed 's/[^0-9a-z]*//g' | xargs | tail -c 13 \ + > "$( dirname "$0" )/config.d/machine_uuid.sys" + export MACHINEID="$( cat $( dirname "$0" )/config.d/machine_uuid.sys )" +fi + #Check for configure.conf - used for frist setup of system if [[ -f $(dirname "$0")/../config.d/configure.conf ]]; then echo "System in configure-mode. Will use $(dirname "$0")/../config.d/configure.conf for setup." @@ -23,7 +36,7 @@ if [[ -f $(dirname "$0")/../config.d/configure.conf ]]; then else #Load default system setup file if [[ ! -f $(dirname "$0")/../config/setup_system.conf ]]; then - echo "System configuration not found. Please make a copy of setup_system.conf.dist, name it setup_system.conf and check the settings in it before running." + echo "System configuration not found. Please copy system_setup/config.dist/setup_system.conf.dist to config/setup_system.conf and adjust the settings before running." echo "Press any key to continue" && read -n 1 -s -r && exit 1 fi source $(dirname "$0")/../config/setup_system.conf diff --git a/system_setup/skel/pack_skel.sh b/system_setup/skel/pack_skel.sh index 6b84c00..2b5a2fa 100755 --- a/system_setup/skel/pack_skel.sh +++ b/system_setup/skel/pack_skel.sh @@ -1,7 +1,6 @@ #!/usr/bin/env sh # Usage: will make a tar-file from folder skel found in the directory where executed # If you want to change skel- content, extrakt your skel.tar.zstd to this directory, edit the files and use this script to repack -source $(dirname "$0")/setup_system.inc.sh mv skel.tar.zst backup_skel.tar.zst if [ $? -eq 0 ]; then echo "Old Archive renamed to backup_skel.tar.zst" diff --git a/system_setup/sync_client_software.sh b/system_setup/sync_client_software.sh index 488d9e3..3f4fcf3 100755 --- a/system_setup/sync_client_software.sh +++ b/system_setup/sync_client_software.sh @@ -20,15 +20,20 @@ fi #Install or update Nextcloud com.nextcloud.desktopclient.nextcloud echo "Update or install Nextcloud client" -/usr/bin/flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo +/usr/bin/flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo && \ /usr/bin/flatpak install -y --or-update --noninteractive flathub com.nextcloud.desktopclient.nextcloud && echo "Done Update/Install of Nextcloud." +if [[ $? -ne 0 ]]; then + echo "" + echo "There seems to be a problem with your network connection. Please first check, if your network can be established before reuming." + echo "You can press CRTL+C to abort now. Than your data wont be accessible and you need to run \"$0\" again." + echo "You can also continue without network. You may need your personal encryptionkey for accessing your data." + read -n 1 -s -r -p "Please check Network and press any Key to continue" +fi echo "" -#Sync remote Files +#Do an upgrade of the Base package if its configured and if there are changes chown root:${CLIENTADMINGROUP} -R ${SYSCONFIGPATH} chmod ug+rwX,o=rX -R ${SYSCONFIGPATH} - -#Do an upgrade of the Base package if its configured and if there are changes if [[ ! -z "${UPGRADEURL}" ]]; then echo "Checking for Upgrades on ${UPGRADEURL} and Branch ${UPGRADEBRANCH}" REMOTEURL=$( git config --get remote.origin.url ) @@ -43,14 +48,17 @@ if [[ ! -z "${UPGRADEURL}" ]]; then else # Doing upgrade, discarding all local changes frist (is more save than forced pull) echo "Checks have passed, we are now upgrading via git." - git fetch origin - git reset --hard origin/${UPGRADEBRANCH} - #Remove all history - git rebase HEAD^ + #Fetch latest Updates and remove all history + git fetch origin && git reset --hard origin/${UPGRADEBRANCH} && git rebase HEAD^ + if [[ $? -ne 0 ]]; then + echo "Error: Failure while updating, will continue as is." + fi fi fi - echo "" +else + echo "UPGRADEURL is not specified in conf - No Upgrade option available." fi +echo "" # At first, sync central configs if they are configured to be synced if [[ ! -z "${DISTCONFIGPATH_SRC}" ]]; then @@ -85,12 +93,13 @@ if [[ ! -z "${DISTCONFIGPATH_SRC}" ]]; then echo "System is in configure-mode and configuration repository was found and synced, but still not configuration was found" echo "checking file $(dirname "$0")/../config/setup_system.conf" echo "" - echo "Please make a inital copy of config/setup_system.conf.dist to config/setup_system.conf and check all settings there." + echo "Please make a copy of system_setup/config.dist/setup_system.conf.dist to config/setup_system.conf and check all settings there." echo "Then rerun the logon script to sync the file to your repository." echo "Press any key to continue" && read -n 1 -s -r && exit 1 fi fi fi + #Check if Repository is defined if [ "${CLIENT_SOFTWARE_DST}." == "." ]; then echo "No central softwarerepository defined (CLIENT_SOFTWARE_DST). Skipping sync." From 94e857f340295494101a46caf61a59fce32eb1a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 13:43:09 +0200 Subject: [PATCH 03/27] configure.sh: allow root and non-root execution - install.sh: pre-create ks.cfg with o+w after permission setup so non-root users can overwrite it (OEMDRV root itself stays o=rX) - install.sh: restore su drop to $SUDO_USER when it is set and not root; fall back to direct root execution otherwise - configure.sh: remove the hard root check so both cases work - configure.md: update docs to reflect root/non-root support Co-Authored-By: Claude Sonnet 4.6 --- configure.md | 2 +- system_setup/configure.sh | 5 ----- system_setup/install.sh | 12 ++++++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/configure.md b/configure.md index 1afc83a..6803540 100644 --- a/configure.md +++ b/configure.md @@ -1,6 +1,6 @@ # configure.sh — First-time setup wizard -Run `system_setup/configure.sh` as a **normal user** (not root) on the machine that has the OEMDRV partition mounted. It guides you through all site-specific settings, tests the configuration, and leaves the system ready for a Fedora installation. +Run `system_setup/configure.sh` on the machine that has the OEMDRV partition mounted. It guides you through all site-specific settings, tests the configuration, and leaves the system ready for a Fedora installation. Can be run as root or as a normal user — `install.sh` pre-creates `ks.cfg` at the OEMDRV root with world-write permission so both cases work. ```bash bash /opt/sys_config/system_setup/configure.sh diff --git a/system_setup/configure.sh b/system_setup/configure.sh index 2850479..acdbe02 100755 --- a/system_setup/configure.sh +++ b/system_setup/configure.sh @@ -8,11 +8,6 @@ SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" CONF_DIST="${SCRIPTDIR}/config.dist/setup_system.conf.dist" CONF_FILE="${SCRIPTDIR}/../config.d/configure.conf" -if [[ "$EUID" -eq 0 ]]; then - echo "ERROR: This script must not be run as root." >&2 - exit 1 -fi - # Prompt for a single value; returns the old value unchanged if the user presses Enter. prompt_value() { local name="$1" current="$2" new_val diff --git a/system_setup/install.sh b/system_setup/install.sh index 865cb70..849f2bb 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -31,6 +31,11 @@ finish_install() { chmod ug=rwX,o=rX "$MOUNT_POINT" -R chmod o+w "$MOUNT_POINT/config" "$MOUNT_POINT/config.d" + # Create an empty ks.cfg at the OEMDRV root so non-root can overwrite it + # with configure.sh (the OEMDRV root itself is not world-writable). + touch "$MOUNT_POINT/ks.cfg" + chmod o+w "$MOUNT_POINT/ks.cfg" + info "Done." echo echo " OEMDRV device : $dev" @@ -42,13 +47,12 @@ finish_install() { echo read -r -p "Run configure.sh now to set up your environment? [y/N]: " RUN_CONF if [[ "${RUN_CONF,,}" == "y" ]]; then - if [[ -n "$SUDO_USER" ]]; then + if [[ -n "$SUDO_USER" && "$SUDO_USER" != "root" ]]; then info "Running configure.sh as user '$SUDO_USER'..." su - "$SUDO_USER" -c "DISPLAY='${DISPLAY}' WAYLAND_DISPLAY='${WAYLAND_DISPLAY}' bash '$CONF_SCRIPT'" else - echo - echo "configure.sh must be run as a non-root user. Please run:" - echo " bash $CONF_SCRIPT" + info "Running configure.sh as root..." + bash "$CONF_SCRIPT" fi else echo From 3e78a77623381451581ea5f57acb2aa81546c205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 13:51:39 +0200 Subject: [PATCH 04/27] configure.sh: seed wizard from setup_system.conf when it exists Use config/setup_system.conf as the template for configure.conf when present, so existing values appear as defaults. Falls back to the dist file on a fresh install. Co-Authored-By: Claude Sonnet 4.6 --- system_setup/configure.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/system_setup/configure.sh b/system_setup/configure.sh index acdbe02..5b4d785 100755 --- a/system_setup/configure.sh +++ b/system_setup/configure.sh @@ -5,9 +5,15 @@ # SPDX-License-Identifier: AGPL-3.0-or-later SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" -CONF_DIST="${SCRIPTDIR}/config.dist/setup_system.conf.dist" CONF_FILE="${SCRIPTDIR}/../config.d/configure.conf" +CONF_EXISTING="${SCRIPTDIR}/../config/setup_system.conf" +if [[ -f "$CONF_EXISTING" ]]; then + CONF_DIST="$CONF_EXISTING" +else + CONF_DIST="${SCRIPTDIR}/config.dist/setup_system.conf.dist" +fi + # Prompt for a single value; returns the old value unchanged if the user presses Enter. prompt_value() { local name="$1" current="$2" new_val From db61cf36cd50905b058208763250f0f3d01e2cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 14:00:38 +0200 Subject: [PATCH 05/27] ks: detect target disk dynamically, drop hardcoded ignoredisk basic_pre_script.inc already identifies the disk holding OEMDRV ($SYSDRIVE). Write its short name to /tmp/disk-include.cfg after the GPT check so both cinnamon and KDE profiles can %include it instead of the hardcoded 'ignoredisk --only-use=sda,nvme0n1' that fails on systems without an NVMe drive (or without sda). Co-Authored-By: Claude Sonnet 4.6 --- ks_base_profiles/basic_pre_script.inc | 3 +++ ks_base_profiles/cinnamon_fullsetup.cfg | 4 ++-- ks_base_profiles/kde_fullsetup.cfg | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ks_base_profiles/basic_pre_script.inc b/ks_base_profiles/basic_pre_script.inc index 3f0deff..b3fbdb9 100644 --- a/ks_base_profiles/basic_pre_script.inc +++ b/ks_base_profiles/basic_pre_script.inc @@ -65,6 +65,9 @@ else echo "The Drive ${SYSDRIVE} contains a GPT." fi +# Write the target disk for %include in the kickstart main section +echo "ignoredisk --only-use=${SYSDRIVE:5}" > /tmp/disk-include.cfg + OEMDRVPARTSHORT=${OEMDRVPART:5} ALLPARTS=$(lsblk -n -l -o NAME "${SYSDRIVE}" -Q 'TYPE=="part"') REMPARTS=$(echo "$ALLPARTS" | grep -v "${OEMDRVPARTSHORT}") diff --git a/ks_base_profiles/cinnamon_fullsetup.cfg b/ks_base_profiles/cinnamon_fullsetup.cfg index c8a2743..e1fd04b 100644 --- a/ks_base_profiles/cinnamon_fullsetup.cfg +++ b/ks_base_profiles/cinnamon_fullsetup.cfg @@ -81,8 +81,8 @@ nss-pam-ldapd authselect enable-feature with-fingerprint -# Generated using Blivet version 3.12.1 -ignoredisk --only-use=sda,nvme0n1 +# Disk selection written by %pre via basic_pre_script.inc +%include /tmp/disk-include.cfg # Partition clearing information - do NOT USE --initlabel ! clearpart --none autopart --type=btrfs diff --git a/ks_base_profiles/kde_fullsetup.cfg b/ks_base_profiles/kde_fullsetup.cfg index 235b498..cab7c62 100644 --- a/ks_base_profiles/kde_fullsetup.cfg +++ b/ks_base_profiles/kde_fullsetup.cfg @@ -92,8 +92,8 @@ nss-pam-ldapd # System authorization information authselect enable-feature with-fingerprint -# Generated using Blivet version 3.12.1 -ignoredisk --only-use=sda,nvme0n1 +# Disk selection written by %pre via basic_pre_script.inc +%include /tmp/disk-include.cfg # Partition clearing information - do NOT USE --initlabel ! clearpart --none autopart --type=btrfs From 1d5c72129fdb71273cc9312b228f0fa668e69333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 15:21:53 +0200 Subject: [PATCH 06/27] isnatll: fixed config check before sourcing --- system_setup/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_setup/install.sh b/system_setup/install.sh index 849f2bb..67dcab5 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -360,7 +360,7 @@ if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then mount -o "$MOUNT_OPTS" "$EXISTING_OEMDRV_DEV" "$MOUNT_POINT" || die "mount failed." fi - if [[ -f "$MOUNT_POINT/system_setup/setup_system.inc.sh" ]]; then + if [[ -f "$MOUNT_POINT/system_setup/setup_system.inc.sh" && -f "$MOUNT_POINT/config/setup_system.conf" ]]; then info "Sourcing existing setup_system.inc.sh..." pushd "$MOUNT_POINT/system_setup" > /dev/null source setup_system.inc.sh From 2e329a3807bd1be929c1cb26765238932aca5979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 15:32:07 +0200 Subject: [PATCH 07/27] Install: Don't source setup_system.inc.sh, because it would not find the rigth settings --- system_setup/install.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/system_setup/install.sh b/system_setup/install.sh index 67dcab5..e02618f 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -69,7 +69,7 @@ do_clone_and_done() { info "Cloning $REPO_URL into $MOUNT_POINT..." cd "$MOUNT_POINT" || die "Cannot cd to $MOUNT_POINT." git clone --progress --depth 1 -b $REPO_BRANCH "$REPO_URL" . || die "git clone failed." - source "$(dirname "$0")/setup_system.inc.sh" + ${MOUNT_POINT}/setup_system.inc.sh finish_install "$dev" } @@ -361,10 +361,8 @@ if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then fi if [[ -f "$MOUNT_POINT/system_setup/setup_system.inc.sh" && -f "$MOUNT_POINT/config/setup_system.conf" ]]; then - info "Sourcing existing setup_system.inc.sh..." - pushd "$MOUNT_POINT/system_setup" > /dev/null - source setup_system.inc.sh - popd > /dev/null + info "Reading existing configuration..." + $MOUNT_POINT/system_setup/setup_system.inc.sh fi # ── Check existing git repository origin ────────────────────────────── @@ -393,7 +391,7 @@ if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then || die "git fetch failed." git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \ || die "git checkout failed." - source "$MOUNT_POINT/system_setup/setup_system.inc.sh" + $MOUNT_POINT/system_setup/setup_system.inc.sh finish_install "$EXISTING_OEMDRV_DEV" exit 0 ;; @@ -405,7 +403,7 @@ if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then || die "git fetch failed." git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \ || die "git checkout failed." - source "$MOUNT_POINT/system_setup/setup_system.inc.sh" + $MOUNT_POINT/system_setup/setup_system.inc.sh finish_install "$EXISTING_OEMDRV_DEV" exit 0 ;; From 08df1c28972895fb4e9c8c828d87d449f3e331e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 15:34:19 +0200 Subject: [PATCH 08/27] Added Readme for config dir --- config/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 config/README.md diff --git a/config/README.md b/config/README.md new file mode 100644 index 0000000..93535b1 --- /dev/null +++ b/config/README.md @@ -0,0 +1,4 @@ +# Shared config Files + +in this directory, you should have at least the setup_system.conf as a modified copy of system_setup/config.dist/setup_system.conf.dist for your needs. +This directory will be synced with DISTCONFIGPATH_SRC on your nextcloud instance an thus be delivered to all clients. From cfae3ac1f6d55422cc054da4545d887f77eee846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 15:36:54 +0200 Subject: [PATCH 09/27] install: Fixed directory for reading config after git --- system_setup/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_setup/install.sh b/system_setup/install.sh index e02618f..99672ce 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -69,7 +69,7 @@ do_clone_and_done() { info "Cloning $REPO_URL into $MOUNT_POINT..." cd "$MOUNT_POINT" || die "Cannot cd to $MOUNT_POINT." git clone --progress --depth 1 -b $REPO_BRANCH "$REPO_URL" . || die "git clone failed." - ${MOUNT_POINT}/setup_system.inc.sh + ${MOUNT_POINT}/system_setup/setup_system.inc.sh finish_install "$dev" } From 8652131882d423d65c2878bfc9c1850a8aef1dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 18:42:12 +0200 Subject: [PATCH 10/27] inc.sh: use BASH_SOURCE for path resolution; add --missingconfok; fix install.sh sourcing and git pull logic setup_system.inc.sh: replace $(dirname "$0") with $(dirname "${BASH_SOURCE[0]:-$0}") so paths resolve correctly whether the file is sourced or executed directly. Add --missingconfok flag to warn-and-continue instead of prompting+aborting when config is missing. Fix machine_uuid path (missing ../). Move `source config` into the else branch so it is not reached when missingconfok skips the exit. install.sh: source inc.sh instead of executing it as a subprocess so exported variables (REPO_URL etc.) propagate back to the caller. Fix git-origin conflict handling: when reusing an existing OEMDRV partition the user has already confirmed they want to keep it, so remove the "fresh clone / wipe" option entirely. Now always pulls (fetch+checkout) when a git repo is present; clears and fresh-clones only when no git repo exists on the partition. basic_pre_script.inc: dot-source inc.sh so INSTALLDOCS and other config vars are available. config.dist, sync_client_software.sh: rename UPGRADEURL/UPGRADEBRANCH to REPO_URL/REPO_BRANCH to match the variable names already used in install.sh. Co-Authored-By: Claude Sonnet 4.6 --- CLAUDE.md | 2 +- install.md | 2 +- ks_base_profiles/basic_pre_script.inc | 2 +- .../config.dist/setup_system.conf.dist | 6 +- system_setup/install.sh | 70 +++++++++---------- system_setup/setup_system.inc.sh | 57 ++++++++------- system_setup/sync_client_software.sh | 12 ++-- 7 files changed, 80 insertions(+), 71 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 23c46af..f7be501 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -17,7 +17,7 @@ cp /opt/sys_config/system_setup/config.dist/setup_system.conf.dist /opt/sys_conf # Edit setup_system.conf with your domain, server FQDNs, paths, etc. ``` -Local per-machine overrides go in `config.d/*.conf` (gitignored). These are sourced after `setup_system.conf` and can override any exported variable (e.g. `config.d/system_defines.conf` overrides `UPGRADEBRANCH`). +Local per-machine overrides go in `config.d/*.conf` (gitignored). These are sourced after `setup_system.conf` and can override any exported variable (e.g. `config.d/system_defines.conf` overrides `REPO_BRANCH`). `config/skel.tar.zst` (gitignored) holds the `/etc/skel` archive deployed to new installs. The `.dist` version is at `system_setup/skel/skel.tar.zst.dist`. To modify skel: extract, edit, then repack: ```sh diff --git a/install.md b/install.md index 8703b3b..a3910fa 100644 --- a/install.md +++ b/install.md @@ -52,7 +52,7 @@ Optionally add local per-machine overrides in `config.d/`: ```sh # Example: use the devel branch on this machine -echo 'export UPGRADEBRANCH="devel"' > /opt/sys_config/config.d/system_defines.conf +echo 'export REPO_BRANCH="devel"' > /opt/sys_config/config.d/system_defines.conf ``` Once configured, boot the Fedora installer from USB — Anaconda will detect the `OEMDRV` partition and run the Kickstart automatically. diff --git a/ks_base_profiles/basic_pre_script.inc b/ks_base_profiles/basic_pre_script.inc index b3fbdb9..d59a90a 100644 --- a/ks_base_profiles/basic_pre_script.inc +++ b/ks_base_profiles/basic_pre_script.inc @@ -33,7 +33,7 @@ if [ ! -f ${FQFILENAME} ]; then fi # Check if there is a Partition OEMDRV and on which Drive -/mnt/anaconda_pre/system_setup/setup_system.inc.sh +. /mnt/anaconda_pre/system_setup/setup_system.inc.sh OEMDRVINFO=$(blkid | grep 'LABEL="OEMDRV"') if [ "${OEMDRVINFO}." == "." ] ; then echo "* Error: Required partition with label 'OEMDRV' is not found." diff --git a/system_setup/config.dist/setup_system.conf.dist b/system_setup/config.dist/setup_system.conf.dist index 08b541b..9a0afc3 100644 --- a/system_setup/config.dist/setup_system.conf.dist +++ b/system_setup/config.dist/setup_system.conf.dist @@ -8,9 +8,9 @@ export SERVERFQDN_IPA=ipa.${TLDOMAIN} # Needs to be the IPA- Server export SERVERFQDN_NC=nextcloud.${TLDOMAIN} export INSTALLDOCS="https://gitea.dtext.online/obel1x/fedora-OEMDRV/src/branch/main/README.md" -#If the UPGRADEURL and branch is set, this script collection will do automatic upgrades -export UPGRADEURL="https://gitea.dtext.online/obel1x/fedora-OEMDRV.git" -export UPGRADEBRANCH="main" +#If the REPO_URL and REPO_BRANCH is set, this script collection will do automatic upgrades +export REPO_URL="https://gitea.dtext.online/obel1x/fedora-OEMDRV.git" +export REPO_BRANCH="main" #Configuration Files - maybe syned with your companies settings export SYSCONFIGPATH="/opt/sys_config" diff --git a/system_setup/install.sh b/system_setup/install.sh index 99672ce..c25ac49 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -69,7 +69,7 @@ do_clone_and_done() { info "Cloning $REPO_URL into $MOUNT_POINT..." cd "$MOUNT_POINT" || die "Cannot cd to $MOUNT_POINT." git clone --progress --depth 1 -b $REPO_BRANCH "$REPO_URL" . || die "git clone failed." - ${MOUNT_POINT}/system_setup/setup_system.inc.sh + source "$MOUNT_POINT/system_setup/setup_system.inc.sh" --missingconfok finish_install "$dev" } @@ -361,8 +361,8 @@ if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then fi if [[ -f "$MOUNT_POINT/system_setup/setup_system.inc.sh" && -f "$MOUNT_POINT/config/setup_system.conf" ]]; then - info "Reading existing configuration..." - $MOUNT_POINT/system_setup/setup_system.inc.sh + info "Reading existing configuration from ${MOUNT_POINT} ..." + source "$MOUNT_POINT/system_setup/setup_system.inc.sh" fi # ── Check existing git repository origin ────────────────────────────── @@ -377,45 +377,45 @@ if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then printf " %-12s %-55s %s\n" "Existing:" "$EXIST_URL" "$EXIST_BRANCH" printf " %-12s %-55s %s\n" "Configured:" "$REPO_URL" "$REPO_BRANCH" echo + echo " Hint: set REPO_URL / REPO_BRANCH env vars before running to override the configured values." + echo echo " How should this be resolved?" echo " 1) Keep existing origin/branch — pull latest from $EXIST_URL / $EXIST_BRANCH" echo " 2) Switch to configured origin — migrate to $REPO_URL / $REPO_BRANCH (preserves local files)" - echo " 3) Fresh clone from configured origin — clears all existing content" - read -r -p " Choice [1/2/3]: " GIT_CHOICE - case "${GIT_CHOICE}" in - 1) - REPO_URL="$EXIST_URL" - REPO_BRANCH="$EXIST_BRANCH" - info "Fetching latest from $REPO_URL (branch: $REPO_BRANCH)..." - git -C "$MOUNT_POINT" fetch --depth 1 origin "$REPO_BRANCH" \ - || die "git fetch failed." - git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \ - || die "git checkout failed." - $MOUNT_POINT/system_setup/setup_system.inc.sh - finish_install "$EXISTING_OEMDRV_DEV" - exit 0 - ;; - 2) - info "Switching origin to $REPO_URL (branch: $REPO_BRANCH)..." - git -C "$MOUNT_POINT" remote set-url origin "$REPO_URL" \ - || die "git remote set-url failed." - git -C "$MOUNT_POINT" fetch --depth 1 origin "$REPO_BRANCH" \ - || die "git fetch failed." - git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \ - || die "git checkout failed." - $MOUNT_POINT/system_setup/setup_system.inc.sh - finish_install "$EXISTING_OEMDRV_DEV" - exit 0 - ;; - *) - # Option 3 or anything else: fall through to clear + fresh clone - ;; - esac + while true; do + read -r -p " Choice [1/2]: " GIT_CHOICE + case "${GIT_CHOICE}" in + 1) + REPO_URL="$EXIST_URL" + REPO_BRANCH="$EXIST_BRANCH" + break + ;; + 2) + info "Switching origin to $REPO_URL (branch: $REPO_BRANCH)..." + git -C "$MOUNT_POINT" remote set-url origin "$REPO_URL" \ + || die "git remote set-url failed." + break + ;; + *) + echo " Please enter 1 or 2." + ;; + esac + done fi + + info "Pulling latest from $REPO_URL (branch: $REPO_BRANCH)..." + git -C "$MOUNT_POINT" fetch --depth 1 origin "$REPO_BRANCH" \ + || die "git fetch failed." + git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \ + || die "git checkout failed." + source "$MOUNT_POINT/system_setup/setup_system.inc.sh" + finish_install "$EXISTING_OEMDRV_DEV" + exit 0 fi + # No git repo on the partition — clear and do a fresh clone if [[ -n "$(ls -A "$MOUNT_POINT" 2>/dev/null)" ]]; then - info "Clearing existing content in $MOUNT_POINT before fresh clone..." + info "No git repository found on $MOUNT_POINT — clearing before fresh clone..." find "$MOUNT_POINT" -mindepth 1 -delete fi diff --git a/system_setup/setup_system.inc.sh b/system_setup/setup_system.inc.sh index 590e4c2..b8c4c89 100755 --- a/system_setup/setup_system.inc.sh +++ b/system_setup/setup_system.inc.sh @@ -5,45 +5,54 @@ # SPDX-License-Identifier: AGPL-3.0-or-later # # This is not a runnig script-file. No real logic to execute. Its used for includes in other scripts. +# +# Parameters (pass as arguments to the `source` call, e.g. source setup_system.inc.sh --missingconfok): +# --missingconfok Print a warning instead of prompting and aborting when config/setup_system.conf is missing. -#Check if we are root -# Deprectaed - use if Statement itself -#check_root() -#{ -# if [ "$EUID" -ne 0 ]; then -# return 1 -# fi -# return 0 -#} +# Parse flags passed to this inc (e.g. source setup_system.inc.sh --missingconfok). +# In bash, arguments to `source` temporarily replace $@ for the duration of the sourced file. +_INC_MISSINGCONFOK=0 +for _inc_arg in "$@"; do + [[ "$_inc_arg" == "--missingconfok" ]] && _INC_MISSINGCONFOK=1 +done +unset _inc_arg -#First, get the machine_uuid wich is needed by some userspace programs. +#Get the machine_uuid wich is needed by some userspace programs. #As all Parameters that are bound to CPU or Mainboard, are only readable by root, we need to get the values at installtime. #On old installations without the file, we will write it whenever possible -if [ -f $( dirname "$0" )/config.d/machine_uuid.sys ]; then - export MACHINEID="$( cat $( dirname "$0" )/config.d/machine_uuid.sys )" +if [ -f $( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys ]; then + export MACHINEID="$( cat $( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys )" elif [ "$EUID" -eq 0 ]; then dmidecode -t system | grep -i 'UUID' \ | sed 's/UUID: //' | tr '[:upper:]' '[:lower:]' \ | sed 's/[^0-9a-z]*//g' | xargs | tail -c 13 \ - > "$( dirname "$0" )/config.d/machine_uuid.sys" - export MACHINEID="$( cat $( dirname "$0" )/config.d/machine_uuid.sys )" + > "$( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys" + export MACHINEID="$( cat $( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys )" fi -#Check for configure.conf - used for frist setup of system -if [[ -f $(dirname "$0")/../config.d/configure.conf ]]; then - echo "System in configure-mode. Will use $(dirname "$0")/../config.d/configure.conf for setup." - source $(dirname "$0")/../config.d/configure.conf +#Check for configure.conf - used for first setup of system +if [[ -f $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/configure.conf ]]; then + echo "System in configure-mode. Will use $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/configure.conf for setup." + source $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/configure.conf else #Load default system setup file - if [[ ! -f $(dirname "$0")/../config/setup_system.conf ]]; then - echo "System configuration not found. Please copy system_setup/config.dist/setup_system.conf.dist to config/setup_system.conf and adjust the settings before running." - echo "Press any key to continue" && read -n 1 -s -r && exit 1 + if [[ ! -f $(dirname "${BASH_SOURCE[0]:-$0}")/../config/setup_system.conf ]]; then + echo "System configuration not found." + echo "Please copy system_setup/config.dist/setup_system.conf.dist to config/setup_system.conf and adjust the settings before running." + if [[ $_INC_MISSINGCONFOK -eq 1 ]]; then + echo "WARNING: Continuing without system configuration (--missingconfok)." + else + echo "Press any key to continue" && read -n 1 -s -r && exit 1 + fi + else + echo "Found and use configfile $(dirname "${BASH_SOURCE[0]:-$0}")/../config/setup_system.conf" + source $(dirname "${BASH_SOURCE[0]:-$0}")/../config/setup_system.conf fi - source $(dirname "$0")/../config/setup_system.conf #Parse additional client-configs - if [[ `ls -1 $(dirname "$0")/../config.d/*.conf 2>/dev/null | wc -l ` -gt 0 ]]; then - source $(dirname "$0")/../config.d/*.conf + if [[ `ls -1 $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/*.conf 2>/dev/null | wc -l ` -gt 0 ]]; then + echo "Additional config file found $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/*.conf - using it" + source $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/*.conf fi fi diff --git a/system_setup/sync_client_software.sh b/system_setup/sync_client_software.sh index 3f4fcf3..7e6f32c 100755 --- a/system_setup/sync_client_software.sh +++ b/system_setup/sync_client_software.sh @@ -34,29 +34,29 @@ echo "" #Do an upgrade of the Base package if its configured and if there are changes chown root:${CLIENTADMINGROUP} -R ${SYSCONFIGPATH} chmod ug+rwX,o=rX -R ${SYSCONFIGPATH} -if [[ ! -z "${UPGRADEURL}" ]]; then - echo "Checking for Upgrades on ${UPGRADEURL} and Branch ${UPGRADEBRANCH}" +if [[ ! -z "${REPO_URL}" ]]; then + echo "Checking for Upgrades on ${REPO_URL} and Branch ${REPO_BRANCH}" REMOTEURL=$( git config --get remote.origin.url ) echo "Remote git URL is ${REMOTEURL}" - if [[ "${REMOTEURL}" != "${UPGRADEURL}" ]]; then + if [[ "${REMOTEURL}" != "${REPO_URL}" ]]; then echo "This Repo is not on the matching URL, so no update is possible. If you want to change this, check out the docs on how to setup from scratch." else GITBRANCH=$( git rev-parse --abbrev-ref HEAD ) echo "Current branch is ${GITBRANCH}" - if [[ "${GITBRANCH}" != "${UPGRADEBRANCH}" ]]; then + if [[ "${GITBRANCH}" != "${REPO_BRANCH}" ]]; then echo "This Repo is not on the right branch, so no update is possible." else # Doing upgrade, discarding all local changes frist (is more save than forced pull) echo "Checks have passed, we are now upgrading via git." #Fetch latest Updates and remove all history - git fetch origin && git reset --hard origin/${UPGRADEBRANCH} && git rebase HEAD^ + git fetch origin && git reset --hard origin/${REPO_BRANCH} && git rebase HEAD^ if [[ $? -ne 0 ]]; then echo "Error: Failure while updating, will continue as is." fi fi fi else - echo "UPGRADEURL is not specified in conf - No Upgrade option available." + echo "REPO_URL is not specified in conf - No Upgrade option available." fi echo "" From 527a124bb1158d28014c7705c72988743141e8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 18:47:53 +0200 Subject: [PATCH 11/27] Install: Add missingconfok for broken existing installs without config --- system_setup/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_setup/install.sh b/system_setup/install.sh index c25ac49..25ce3b6 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -408,7 +408,7 @@ if [[ -n "$EXISTING_OEMDRV_DEV" ]]; then || die "git fetch failed." git -C "$MOUNT_POINT" checkout -B "$REPO_BRANCH" FETCH_HEAD \ || die "git checkout failed." - source "$MOUNT_POINT/system_setup/setup_system.inc.sh" + source "$MOUNT_POINT/system_setup/setup_system.inc.sh" --missingconfok finish_install "$EXISTING_OEMDRV_DEV" exit 0 fi From 0f7dc9c043176a8c460a94db0af88423a4a009c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 19:01:02 +0200 Subject: [PATCH 12/27] configure: use setup_system.inc.sh to get machineid for configuration --- system_setup/configure.sh | 4 ++-- system_setup/setup_system.inc.sh | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/system_setup/configure.sh b/system_setup/configure.sh index 5b4d785..e9cba52 100755 --- a/system_setup/configure.sh +++ b/system_setup/configure.sh @@ -51,7 +51,7 @@ do_configure() { echo "=== System Configuration ===" echo "Press Enter to keep the current value, or type a new one." - source "$CONF_FILE" + source "$( dirname "$0" )/setup_system.inc.sh" VARS=("TLDOMAIN" "SERVERFQDN_IPA" "DOMAIN" "SERVERFQDN_NC" "IPAVAULTUSE" "IPAVAULTNAME" "DISTCONFIGPATH_SRC" "CLIENTADMINGROUP" ) for ELE in "${VARS[@]}" do @@ -59,7 +59,7 @@ do_configure() { echo "" new_ELE=$(prompt_value "${ELE}" "${!ELE}") set_conf_var "${ELE}" "${new_ELE}" - source "$CONF_FILE" + source "$( dirname "$0" )/setup_system.inc.sh" REPEAT_TEST=1 case ${ELE} in "SERVERFQDN_NC") echo "=== Testing: Nextcloud server ===" diff --git a/system_setup/setup_system.inc.sh b/system_setup/setup_system.inc.sh index b8c4c89..388d35c 100755 --- a/system_setup/setup_system.inc.sh +++ b/system_setup/setup_system.inc.sh @@ -20,14 +20,16 @@ unset _inc_arg #Get the machine_uuid wich is needed by some userspace programs. #As all Parameters that are bound to CPU or Mainboard, are only readable by root, we need to get the values at installtime. #On old installations without the file, we will write it whenever possible -if [ -f $( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys ]; then - export MACHINEID="$( cat $( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys )" +MACHINEID_FILE="$( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys" +if [ -f ${MACHINEID_FILE} ]; then + export MACHINEID="$( cat ${MACHINEID_FILE} )" elif [ "$EUID" -eq 0 ]; then dmidecode -t system | grep -i 'UUID' \ | sed 's/UUID: //' | tr '[:upper:]' '[:lower:]' \ | sed 's/[^0-9a-z]*//g' | xargs | tail -c 13 \ - > "$( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys" - export MACHINEID="$( cat $( dirname "${BASH_SOURCE[0]:-$0}" )/../config.d/machine_uuid.sys )" + > "${MACHINEID_FILE}" + export MACHINEID="$( cat ${MACHINEID_FILE} )" + echo "Wrote MACHINEID ${MACHINEID} to ${MACHINEID_FILE}" fi #Check for configure.conf - used for first setup of system From 8e0faed130d2c17219b671b707837fc8bc0937cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 19:11:19 +0200 Subject: [PATCH 13/27] Install: Fix permissions --- system_setup/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_setup/install.sh b/system_setup/install.sh index 25ce3b6..8d560c0 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -29,7 +29,7 @@ finish_install() { chown root:root "$MOUNT_POINT" -R chmod ug=rwX,o=rX "$MOUNT_POINT" -R - chmod o+w "$MOUNT_POINT/config" "$MOUNT_POINT/config.d" + chmod o+w "$MOUNT_POINT/config" "$MOUNT_POINT/config.d" -R # Create an empty ks.cfg at the OEMDRV root so non-root can overwrite it # with configure.sh (the OEMDRV root itself is not world-writable). From 7d109111c1155e5f3b1b02a324b00a86f93bb87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 20:18:54 +0200 Subject: [PATCH 14/27] Logon: Don't need KDE --- system_setup/logon_script.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/system_setup/logon_script.sh b/system_setup/logon_script.sh index a2431cb..b6f1adf 100755 --- a/system_setup/logon_script.sh +++ b/system_setup/logon_script.sh @@ -33,11 +33,7 @@ fi #TODO C: Check if Desktop is KDE/Plasma and support other Displays # Make kdesu use sudo -kwriteconfig5 --file kdesurc --group super-user-command --key super-user-command sudo -if [ $? -ne 0 ]; then - elog_add "This script should be run in KDE- Desktop. The setup of kwriteconfig5 has failed. Please check, if you are using KDE." - echo "Press any key to continue" && read -n 1 -s -r && exit 1 -fi +kwriteconfig5 --file kdesurc --group super-user-command --key super-user-command sudo >/dev/null 2>&1 # Mount the private Directory elog_add_command "${SYSCONFIGPATH}/system_setup/mount_ecrypt_home.sh" From 73de38efe6481e088f467acdfee84a442e00ed51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 20:39:56 +0200 Subject: [PATCH 15/27] small changes in output --- system_setup/logon_script.sh | 1 - system_setup/setup_system.inc.sh | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/system_setup/logon_script.sh b/system_setup/logon_script.sh index b6f1adf..1e2a651 100755 --- a/system_setup/logon_script.sh +++ b/system_setup/logon_script.sh @@ -30,7 +30,6 @@ if [[ $? -ne 0 ]]; then echo "Error: python3-ipaclient is not installed. Please install it via: sudo dnf install python3-ipaclient" fi - #TODO C: Check if Desktop is KDE/Plasma and support other Displays # Make kdesu use sudo kwriteconfig5 --file kdesurc --group super-user-command --key super-user-command sudo >/dev/null 2>&1 diff --git a/system_setup/setup_system.inc.sh b/system_setup/setup_system.inc.sh index 388d35c..62dc379 100755 --- a/system_setup/setup_system.inc.sh +++ b/system_setup/setup_system.inc.sh @@ -39,11 +39,11 @@ if [[ -f $(dirname "${BASH_SOURCE[0]:-$0}")/../config.d/configure.conf ]]; then else #Load default system setup file if [[ ! -f $(dirname "${BASH_SOURCE[0]:-$0}")/../config/setup_system.conf ]]; then - echo "System configuration not found." - echo "Please copy system_setup/config.dist/setup_system.conf.dist to config/setup_system.conf and adjust the settings before running." + echo "WARNING: System configuration not found." if [[ $_INC_MISSINGCONFOK -eq 1 ]]; then - echo "WARNING: Continuing without system configuration (--missingconfok)." + echo "Continuing without system configuration (--missingconfok), but this should only be for installing." else + echo "Please copy system_setup/config.dist/setup_system.conf.dist to config/setup_system.conf and adjust the settings before running." echo "Press any key to continue" && read -n 1 -s -r && exit 1 fi else From b214880351dab55582aa6d8a41610eb3e19debef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 20:56:34 +0200 Subject: [PATCH 16/27] nextcloud: fix GTK module warning, Qt session error, skip KWallet on non-KDE cinnamon_fullsetup.cfg: add xapps package so the xapp-gtk3-module GTK module referenced in Cinnamon's GTK settings is present for Flatpak apps. user_run.sh: pass --setenv=SESSION_MANAGER= to systemd-run so Qt does not try to connect to an X11 session manager socket that may not exist (fixes "Could not open network socket" on Wayland and non-KDE desktops). Guard the KWallet D-Bus block behind a session-bus presence check (qdbus | grep org.kde.kwalletd) so it is skipped entirely on Cinnamon and other non-KDE desktops instead of producing D-Bus errors. Co-Authored-By: Claude Sonnet 4.6 --- .../0050_nextcloud_desktopclient/user_run.sh | 42 +++++++++++-------- ks_base_profiles/cinnamon_fullsetup.cfg | 1 + 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index adb1ff2..f046584 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -102,25 +102,31 @@ for i in {0..99}; do NC_WALLET_APPID="logon_script" NC_QB_CMD="qdbus-qt6" if ! command -v ${NC_QB_CMD} >/dev/null 2>&1; then NC_QB_CMD="qdbus"; fi - NC_QB_SVC="org.kde.kwalletd" - NC_QB_PATH="/modules/kwalletd6" - if ! ( ${NC_QB_CMD} "${NC_QB_SVC}" | grep -q "${NC_QB_PATH}" ); then - NC_QB_PATH="/modules/kwalletd5" - fi - echo "Writing Nextcloud app password to KWallet via D-Bus (${NC_QB_PATH})" - NC_WALLET_HANDLE=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.open "kdewallet" 0 "${NC_WALLET_APPID}") - if [[ -n "${NC_WALLET_HANDLE}" && "${NC_WALLET_HANDLE}" != "-1" ]]; then - HAS_FOLDER=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasFolder "${NC_WALLET_HANDLE}" "Nextcloud" "${NC_WALLET_APPID}") - if [[ "${HAS_FOLDER}" != "true" ]]; then - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.createFolder "${NC_WALLET_HANDLE}" "Nextcloud" "${NC_WALLET_APPID}" >/dev/null + # Only attempt KWallet on KDE: check that the service is registered on the session bus. + if command -v "${NC_QB_CMD}" >/dev/null 2>&1 && \ + "${NC_QB_CMD}" 2>/dev/null | grep -q "org.kde.kwalletd"; then + NC_QB_SVC="org.kde.kwalletd" + NC_QB_PATH="/modules/kwalletd6" + if ! ( ${NC_QB_CMD} "${NC_QB_SVC}" | grep -q "${NC_QB_PATH}" ); then + NC_QB_PATH="/modules/kwalletd5" + fi + echo "Writing Nextcloud app password to KWallet via D-Bus (${NC_QB_PATH})" + NC_WALLET_HANDLE=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.open "kdewallet" 0 "${NC_WALLET_APPID}") + if [[ -n "${NC_WALLET_HANDLE}" && "${NC_WALLET_HANDLE}" != "-1" ]]; then + HAS_FOLDER=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasFolder "${NC_WALLET_HANDLE}" "Nextcloud" "${NC_WALLET_APPID}") + if [[ "${HAS_FOLDER}" != "true" ]]; then + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.createFolder "${NC_WALLET_HANDLE}" "Nextcloud" "${NC_WALLET_APPID}" >/dev/null + fi + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}_app-password:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.sync "${NC_WALLET_HANDLE}" "${NC_WALLET_APPID}" >/dev/null + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.close "${NC_WALLET_HANDLE}" false "${NC_WALLET_APPID}" >/dev/null + echo "Nextcloud app password written to KWallet successfully." + else + echo "Warning: Could not open KWallet (handle: ${NC_WALLET_HANDLE}). Nextcloud may prompt for credentials on next start." fi - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}_app-password:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.sync "${NC_WALLET_HANDLE}" "${NC_WALLET_APPID}" >/dev/null - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.close "${NC_WALLET_HANDLE}" false "${NC_WALLET_APPID}" >/dev/null - echo "Nextcloud app password written to KWallet successfully." else - echo "Warning: Could not open KWallet (handle: ${NC_WALLET_HANDLE}). Nextcloud may prompt for credentials on next start." + echo "KWallet not available (non-KDE desktop) — skipping credential storage." fi fi done @@ -151,7 +157,7 @@ done #fi # Now start Nextcloud echo "Starting Nextcloud Client in Background" -systemd-run --user --no-block --unit=nextcloud-client.service ${BASECMD} >>${TEMPDIR}/nc_desktop_client.log 2>&1 +systemd-run --user --no-block --unit=nextcloud-client.service --setenv=SESSION_MANAGER= ${BASECMD} >>${TEMPDIR}/nc_desktop_client.log 2>&1 sleep 2 echo "Done Setup of Nextcloud." exit 0 diff --git a/ks_base_profiles/cinnamon_fullsetup.cfg b/ks_base_profiles/cinnamon_fullsetup.cfg index e1fd04b..723aacc 100644 --- a/ks_base_profiles/cinnamon_fullsetup.cfg +++ b/ks_base_profiles/cinnamon_fullsetup.cfg @@ -63,6 +63,7 @@ flatpak btrfs-assistant btrbk transmission-gtk +xapps cadaver git diffuse From 48803d89a489b5f08fbbdcfcf9f5c93e6ef01660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 21:48:52 +0200 Subject: [PATCH 17/27] Configure: Take given REPO_URL and BRANCH to new installation --- system_setup/configure.sh | 8 ++++++++ system_setup/sync_client_software.sh | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/system_setup/configure.sh b/system_setup/configure.sh index e9cba52..ac022dc 100755 --- a/system_setup/configure.sh +++ b/system_setup/configure.sh @@ -51,6 +51,14 @@ do_configure() { echo "=== System Configuration ===" echo "Press Enter to keep the current value, or type a new one." + # If other Repo infos are given, set them first + if [[ ! -z $REPO_URL ]]; then + set_conf_var "REPO_URL" "$REPO_URL" + fi + if [[ ! -z $REPO_BRANCH ]]; then + set_conf_var "REPO_BRANCH" "$REPO_BRANCH" + fi + source "$( dirname "$0" )/setup_system.inc.sh" VARS=("TLDOMAIN" "SERVERFQDN_IPA" "DOMAIN" "SERVERFQDN_NC" "IPAVAULTUSE" "IPAVAULTNAME" "DISTCONFIGPATH_SRC" "CLIENTADMINGROUP" ) for ELE in "${VARS[@]}" diff --git a/system_setup/sync_client_software.sh b/system_setup/sync_client_software.sh index 7e6f32c..b015552 100755 --- a/system_setup/sync_client_software.sh +++ b/system_setup/sync_client_software.sh @@ -88,7 +88,24 @@ if [[ ! -z "${DISTCONFIGPATH_SRC}" ]]; then echo "Existing configuration found in Repository, removing configure-mode and reread the configuration." rm -f $(dirname "$0")/../config.d/configure.conf.bak >/dev/null mv $(dirname "$0")/../config.d/configure.conf $(dirname "$0")/../config.d/configure.conf.bak - source $(dirname "$0")/../config/setup_system.conf + OLD_REPO_URL="$REPO_URL" + OLD_REPO_BRANCH="$REPO_BRANCH" + source $(dirname "$0")/setup_system.inc.sh + #Compare the Repository URLS after that + if [ "$REPO_URL" != "$OLD_REPO_URL" || "$REPO_BRANCH" != "$OLD_REPO_BRANCH" ]; then + echo "The Repository for installation was" + echo "$OLD_REPO_URL Branch $OLD_REPO_BRANCH" + echo "After reading the config, the Repository has changed to" + echo "$REPO_URL Branch $REPO_BRANCH" + echo + echo "Do you want to create a system specific configuration for the installation Repository, so that" + read -r -p "only this system will stay on the Repository for installation? [y/N]: " CREATE_REPO_CONF + if [[ "${CREATE_REPO_CONF,,}" == "y" ]]; then + echo "export REPO_URL=\"$OLD_REPO_URL\"" >$(dirname "$0")/../config.d/repo.conf + echo "export REPO_BRANCH=\"$OLD_REPO_BRANCH\"" >>$(dirname "$0")/../config.d/repo.conf + echo "Wrote new $(dirname "$0")/../config.d/repo.conf" + fi + fi else echo "System is in configure-mode and configuration repository was found and synced, but still not configuration was found" echo "checking file $(dirname "$0")/../config/setup_system.conf" From f8143ee06eb7694ff8b690ac71a1e316ec53e7ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 21:49:09 +0200 Subject: [PATCH 18/27] ks: add Fedora 44 source include, update both profiles to use it Add source_fedora_44.inc with verified mirror URLs for Fedora 44 base, updates, cisco-openh264, and RPM Fusion free/nonfree. Both kde_fullsetup.cfg and cinnamon_fullsetup.cfg now %include this file instead of inlining the repo lines. Fix stale comment in source_fedora_44.inc (said Fedora 43). Co-Authored-By: Claude Sonnet 4.6 --- ks_base_profiles/cinnamon_fullsetup.cfg | 24 +++++++++--------------- ks_base_profiles/kde_fullsetup.cfg | 10 ++-------- ks_base_profiles/source_fedora_44.inc | 8 ++++++++ 3 files changed, 19 insertions(+), 23 deletions(-) create mode 100644 ks_base_profiles/source_fedora_44.inc diff --git a/ks_base_profiles/cinnamon_fullsetup.cfg b/ks_base_profiles/cinnamon_fullsetup.cfg index 723aacc..f8d51b4 100644 --- a/ks_base_profiles/cinnamon_fullsetup.cfg +++ b/ks_base_profiles/cinnamon_fullsetup.cfg @@ -4,14 +4,15 @@ graphical text -# Configure installation method -url --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-43&arch=x86_64" -repo --name=fedora-updates --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f43&arch=x86_64" --cost=0 -repo --name=fedora-cisco-openh264 --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-cisco-openh264-43&arch=x86_64" --install -repo --name=rpmfusion-free --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-43&arch=x86_64" -repo --name=rpmfusion-free-updates --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-updates-released-43&arch=x86_64" --cost=0 -repo --name=rpmfusion-nonfree --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-43&arch=x86_64" -repo --name=rpmfusion-nonfree-updates --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-updates-released-43&arch=x86_64" --cost=0 +#Pre script +%pre --log=/root/ks-pre.log +mkdir /mnt/anaconda_pre +mount -L OEMDRV /mnt/anaconda_pre +/bin/sh /mnt/anaconda_pre/ks_base_profiles/basic_pre_script.inc +%end + +# Configure installation source +%include /mnt/anaconda_pre/ks_base_profiles/source_fedora_44.inc # Keyboard layouts keyboard --vckeymap=de-nodeadkeys --xlayouts='de (nodeadkeys)' @@ -20,12 +21,6 @@ lang de_DE.UTF-8 # System timezone timezone Europe/Berlin --utc -%pre --log=/root/ks-pre.log -mkdir /mnt/anaconda_pre -mount -L OEMDRV /mnt/anaconda_pre -/bin/sh /mnt/anaconda_pre/ks_base_profiles/basic_pre_script.inc -%end - %packages @^cinnamon-desktop-environment @core @@ -81,7 +76,6 @@ nss-pam-ldapd # System authorization information authselect enable-feature with-fingerprint - # Disk selection written by %pre via basic_pre_script.inc %include /tmp/disk-include.cfg # Partition clearing information - do NOT USE --initlabel ! diff --git a/ks_base_profiles/kde_fullsetup.cfg b/ks_base_profiles/kde_fullsetup.cfg index cab7c62..ae45fb3 100644 --- a/ks_base_profiles/kde_fullsetup.cfg +++ b/ks_base_profiles/kde_fullsetup.cfg @@ -4,14 +4,8 @@ graphical text -# Configure installation method -url --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-43&arch=x86_64" -repo --name=fedora-updates --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f43&arch=x86_64" --cost=0 -repo --name=fedora-cisco-openh264 --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-cisco-openh264-43&arch=x86_64" --install -repo --name=rpmfusion-free --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-43&arch=x86_64" -repo --name=rpmfusion-free-updates --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-updates-released-43&arch=x86_64" --cost=0 -repo --name=rpmfusion-nonfree --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-43&arch=x86_64" -repo --name=rpmfusion-nonfree-updates --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-updates-released-43&arch=x86_64" --cost=0 +# Configure installation source +%include /mnt/anaconda_pre/ks_base_profiles/source_fedora_44.inc # Keyboard layouts keyboard --vckeymap=de-nodeadkeys --xlayouts='de (nodeadkeys)' diff --git a/ks_base_profiles/source_fedora_44.inc b/ks_base_profiles/source_fedora_44.inc new file mode 100644 index 0000000..1a9c460 --- /dev/null +++ b/ks_base_profiles/source_fedora_44.inc @@ -0,0 +1,8 @@ +#Sources for Fedora 44 +url --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-44&arch=x86_64" +repo --name=fedora-updates --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f44&arch=x86_64" --cost=0 +repo --name=fedora-cisco-openh264 --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-cisco-openh264-44&arch=x86_64" --install +repo --name=rpmfusion-free --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-44&arch=x86_64" +repo --name=rpmfusion-free-updates --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-updates-released-44&arch=x86_64" --cost=0 +repo --name=rpmfusion-nonfree --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-44&arch=x86_64" +repo --name=rpmfusion-nonfree-updates --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-updates-released-44&arch=x86_64" --cost=0 From 9a2d8ca6be342e83012c0e7524593cdabf46eed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Sun, 3 May 2026 21:50:22 +0200 Subject: [PATCH 19/27] Base Profile: Fedora 43 --- ks_base_profiles/source_fedora_43.inc | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 ks_base_profiles/source_fedora_43.inc diff --git a/ks_base_profiles/source_fedora_43.inc b/ks_base_profiles/source_fedora_43.inc new file mode 100644 index 0000000..e4664cb --- /dev/null +++ b/ks_base_profiles/source_fedora_43.inc @@ -0,0 +1,9 @@ +#Sources for Fedora 43 +url --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-43&arch=x86_64" +repo --name=fedora-updates --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f43&arch=x86_64" --cost=0 +repo --name=fedora-cisco-openh264 --mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-cisco-openh264-43&arch=x86_64" --install +repo --name=rpmfusion-free --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-43&arch=x86_64" +repo --name=rpmfusion-free-updates --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-updates-released-43&arch=x86_64" --cost=0 +repo --name=rpmfusion-nonfree --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-43&arch=x86_64" +repo --name=rpmfusion-nonfree-updates --mirrorlist="https://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-updates-released-43&arch=x86_64" --cost=0 + From 5eacd55153b0ad0cde3080f56b4772905b7dae63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Mon, 4 May 2026 12:24:24 +0200 Subject: [PATCH 20/27] nextcloud/install: session-bus override, KWallet existence check, pass REPO vars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - sync_client_software.sh: add system-wide flatpak session-bus override for Nextcloud so KWallet D-Bus access works for all users; fix broken compound test ([ a || b ] → [ a ] || [ b ]) - user_run.sh: check KWallet entries with hasEntry before writing — skip write and print info message when both passwords are already present; remove stale commented-out code - install.sh: forward REPO_URL and REPO_BRANCH into configure.sh environment for both the su- and direct-bash invocation paths - configure.sh: simplify do_configure (user cleanup) Co-Authored-By: Claude Sonnet 4.6 --- .../0050_nextcloud_desktopclient/user_run.sh | 46 +++++++------------ system_setup/configure.sh | 7 +-- system_setup/install.sh | 4 +- system_setup/sync_client_software.sh | 5 +- 4 files changed, 23 insertions(+), 39 deletions(-) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index f046584..f37b760 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -4,6 +4,9 @@ # # Sofwareinstallation script for Nextcloud Desktop # +# Hint: No check for installed Nextcloud needed, because it will be installed by calling script sync_client_software.sh +# before as it is needed there already + echo "Setup Nextcloud- Sync" #Local Vars @@ -93,7 +96,9 @@ for i in {0..99}; do echo "Please check the above output!" exit 1 fi - # The Flatpak autoprovisioning may not successfully write the apppassword to +done + +# The Flatpak autoprovisioning may not successfully write the apppassword to # KWallet from inside the sandbox, so write it directly via D-Bus. # Nextcloud stores HTTP credentials in folder "Nextcloud" with keys: # user:url/:0 (legacy password entry) @@ -110,18 +115,24 @@ for i in {0..99}; do if ! ( ${NC_QB_CMD} "${NC_QB_SVC}" | grep -q "${NC_QB_PATH}" ); then NC_QB_PATH="/modules/kwalletd5" fi - echo "Writing Nextcloud app password to KWallet via D-Bus (${NC_QB_PATH})" + echo "Checking Nextcloud app password in KWallet via D-Bus (${NC_QB_PATH})" NC_WALLET_HANDLE=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.open "kdewallet" 0 "${NC_WALLET_APPID}") if [[ -n "${NC_WALLET_HANDLE}" && "${NC_WALLET_HANDLE}" != "-1" ]]; then HAS_FOLDER=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasFolder "${NC_WALLET_HANDLE}" "Nextcloud" "${NC_WALLET_APPID}") if [[ "${HAS_FOLDER}" != "true" ]]; then ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.createFolder "${NC_WALLET_HANDLE}" "Nextcloud" "${NC_WALLET_APPID}" >/dev/null fi - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}_app-password:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null + HAS_PW1=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasEntry "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}:${NC_WALLET_URL}:0" "${NC_WALLET_APPID}") + HAS_PW2=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasEntry "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}_app-password:${NC_WALLET_URL}:0" "${NC_WALLET_APPID}") + if [[ "${HAS_PW1}" == "true" && "${HAS_PW2}" == "true" ]]; then + echo "Nextcloud app password already present in KWallet — no change needed." + else + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}_app-password:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null + echo "Nextcloud app password written to KWallet successfully." + fi ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.sync "${NC_WALLET_HANDLE}" "${NC_WALLET_APPID}" >/dev/null ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.close "${NC_WALLET_HANDLE}" false "${NC_WALLET_APPID}" >/dev/null - echo "Nextcloud app password written to KWallet successfully." else echo "Warning: Could not open KWallet (handle: ${NC_WALLET_HANDLE}). Nextcloud may prompt for credentials on next start." fi @@ -129,32 +140,7 @@ for i in {0..99}; do echo "KWallet not available (non-KDE desktop) — skipping credential storage." fi fi -done -##Check if Nextcloud was already setup -#if [ $SETUP_NEEDED = "0" ]; then -# echo "Nextcloud was already setup, skipping configure and starting Service" -# echo "If you want to reset, please delete the Folder [HOME]/.var/app/com.nextcloud.desktopclient.nextcloud manually." -# echo "Command: rm -rif ~/.var/app/com.nextcloud.desktopclient.nextcloud/" -# su -c "nohup ${BASECMD} 1>/dev/null 2>/dev/null &" $SUDO_USER -# exit $? -#fi - -#No check for installed Nextcloud needed, because it will be installed by calling script sync_client_software.sh - -#Cleanup Nextcloud Configuration completely, while otherwise, the configure will not work -#echo "Remove $SUDO_HOME/.var/app/com.nextcloud.desktopclient.nextcloud" -#rm -rif "$SUDO_HOME/.var/app/com.nextcloud.desktopclient.nextcloud" - -#echo "Exec as $SUDO_USER: ${SYNCCMD}" -#echo "Exec as $SUDO_USER: ${SYNCCMD_HIDDENPW}" -#su -c "${SYNCCMD}" $SUDO_USER -#if [ $? -ne 0 ]; then -# echo "=========== !!! ========================" -# echo "Error: It looks like this did not work!" -# echo "Please check the above output!" -# exit 1 -#fi # Now start Nextcloud echo "Starting Nextcloud Client in Background" systemd-run --user --no-block --unit=nextcloud-client.service --setenv=SESSION_MANAGER= ${BASECMD} >>${TEMPDIR}/nc_desktop_client.log 2>&1 diff --git a/system_setup/configure.sh b/system_setup/configure.sh index ac022dc..016426f 100755 --- a/system_setup/configure.sh +++ b/system_setup/configure.sh @@ -40,12 +40,7 @@ override_conf_var() { do_configure() { mkdir -p "$(dirname "$CONF_FILE")" - cp "$CONF_DIST" "$CONF_FILE" - - # Source the dist defaults (unset computed vars first so they are re-evaluated). - unset TLDOMAIN DOMAIN SERVERFQDN_IPA SERVERFQDN_NC CLIENTADMINGROUP \ - DECRYPTEDDATADIR ENCRYPTEDDATADIR IPAVAULTUSE IPAVAULTNAME HOSTNM FQDN - # shellcheck disable=SC1090 + cp "$CONF_DIST" "$CONF_FILE" # Either setup_system.conf or setup_system.conf.dist to config.d/configure.conf echo "" echo "=== System Configuration ===" diff --git a/system_setup/install.sh b/system_setup/install.sh index 8d560c0..522e050 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -49,10 +49,10 @@ finish_install() { if [[ "${RUN_CONF,,}" == "y" ]]; then if [[ -n "$SUDO_USER" && "$SUDO_USER" != "root" ]]; then info "Running configure.sh as user '$SUDO_USER'..." - su - "$SUDO_USER" -c "DISPLAY='${DISPLAY}' WAYLAND_DISPLAY='${WAYLAND_DISPLAY}' bash '$CONF_SCRIPT'" + su - "$SUDO_USER" -c "DISPLAY='${DISPLAY}' WAYLAND_DISPLAY='${WAYLAND_DISPLAY}' REPO_URL='${REPO_URL}' REPO_BRANCH='${REPO_BRANCH}' bash '$CONF_SCRIPT'" else info "Running configure.sh as root..." - bash "$CONF_SCRIPT" + REPO_URL="$REPO_URL" REPO_BRANCH="$REPO_BRANCH" bash "$CONF_SCRIPT" fi else echo diff --git a/system_setup/sync_client_software.sh b/system_setup/sync_client_software.sh index b015552..bc19f3f 100755 --- a/system_setup/sync_client_software.sh +++ b/system_setup/sync_client_software.sh @@ -31,6 +31,9 @@ if [[ $? -ne 0 ]]; then fi echo "" +# Ensure session bus access for Nextcloud (may be blocked by Flatseal or missing from manifest) +/usr/bin/flatpak override --system --socket=session-bus com.nextcloud.desktopclient.nextcloud + #Do an upgrade of the Base package if its configured and if there are changes chown root:${CLIENTADMINGROUP} -R ${SYSCONFIGPATH} chmod ug+rwX,o=rX -R ${SYSCONFIGPATH} @@ -92,7 +95,7 @@ if [[ ! -z "${DISTCONFIGPATH_SRC}" ]]; then OLD_REPO_BRANCH="$REPO_BRANCH" source $(dirname "$0")/setup_system.inc.sh #Compare the Repository URLS after that - if [ "$REPO_URL" != "$OLD_REPO_URL" || "$REPO_BRANCH" != "$OLD_REPO_BRANCH" ]; then + if [ "$REPO_URL" != "$OLD_REPO_URL" ] || [ "$REPO_BRANCH" != "$OLD_REPO_BRANCH" ]; then echo "The Repository for installation was" echo "$OLD_REPO_URL Branch $OLD_REPO_BRANCH" echo "After reading the config, the Repository has changed to" From 4143925ff71ca669a30fc3330a514d0d9570efdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Mon, 4 May 2026 12:40:00 +0200 Subject: [PATCH 21/27] configure: some usable output --- system_setup/configure.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system_setup/configure.sh b/system_setup/configure.sh index 016426f..9f36f03 100755 --- a/system_setup/configure.sh +++ b/system_setup/configure.sh @@ -45,12 +45,16 @@ do_configure() { echo "" echo "=== System Configuration ===" echo "Press Enter to keep the current value, or type a new one." + echo "Configuration will be reread for each value to make sure the settings are applied." + echo # If other Repo infos are given, set them first if [[ ! -z $REPO_URL ]]; then + echo "REPO_URL is set to $REPO_URL . Will use it for configure.conf." set_conf_var "REPO_URL" "$REPO_URL" fi if [[ ! -z $REPO_BRANCH ]]; then + echo "REPO_BRANCH is set to $REPO_BRANCH . Will use it for configure.conf." set_conf_var "REPO_BRANCH" "$REPO_BRANCH" fi From 2a1530f4f9bf4385f6dbd67fb090824382f9e4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Mon, 4 May 2026 13:23:08 +0200 Subject: [PATCH 22/27] nextcloud/user_run: convert to POSIX sh, clean up loop and alignment - Shebang changed to sh; replace all [[ ]] with [ ], == with = in [ ] - Loop over CLIENT_DATA_SYNC[@] directly instead of counting to 100; replace index-based first-entry check with a _nc_first flag - Fix missing fi before done, remove stray fi after KWallet block - Dedent KWallet block to top level (was left indented from inside the loop) Co-Authored-By: Claude Sonnet 4.6 --- .../0050_nextcloud_desktopclient/user_run.sh | 118 +++++++++--------- 1 file changed, 58 insertions(+), 60 deletions(-) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index f37b760..5a7e50f 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -13,7 +13,7 @@ echo "Setup Nextcloud- Sync" BASECMD="/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=nextcloud com.nextcloud.desktopclient.nextcloud" #Check Token -if [ "${DAVTOKEN_USER}." == "." ]; then +if [ "${DAVTOKEN_USER}." = "." ]; then # Todo: Move all task to some function to logon as user and get all vars, call it and proceed here echo "Error: Script cannot be executed standalone and needs a prereserved Environment. Quit." exit 1 @@ -22,29 +22,29 @@ 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 "$SUDO_HOME/.config/autostart/com.nextcloud.desktopclient.nextcloud.desktop" ]; then - echo "Remove Autostart Nextcloud" - rm $SUDO_HOME/.config/autostart/com.nextcloud.desktopclient.nextcloud.desktop + echo "Remove Autostart Nextcloud" + rm $SUDO_HOME/.config/autostart/com.nextcloud.desktopclient.nextcloud.desktop fi NC_PID=$( pgrep -u $USER nextcloud ) -if [[ ! -z ${NC_PID} ]]; then +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 - if [[ $? -ne 0 ]]; then - echo "Service could not be stopped, please check why." - exit 1 + if [ $? -ne 0 ]; then + echo "Service could not be stopped, please check why." + exit 1 fi sleep 0.5 fi NC_PID=$( pgrep -u $USER nextcloud ) -if [[ ! -z ${NC_PID} ]]; then +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 ${NC_PID} - if [[ $? -ne 0 ]]; then - echo "Service could not be stopped, please check why." - exit 1 + 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/* @@ -55,17 +55,14 @@ declare -p CLIENT_DATA_SYNC_DECLARE >/dev/null eval "${CLIENT_DATA_SYNC_DECLARE}" declare -p CLIENT_DATA_SYNC_DECLARE CLIENT_DATA_SYNC >/dev/null eval "${CLIENT_DATA_SYNC}" -if [[ "${#CLIENT_DATA_SYNC[@]}" == "0" ]]; then +if [ "${#CLIENT_DATA_SYNC[@]}" -eq 0 ]; then echo "CLIENT_DATA_SYNC not set, skipping setup of Nextcloud Desktop sync" exit 0 fi #Loop through all Entries -for i in {0..99}; do - if [[ -z ${CLIENT_DATA_SYNC[$i]} ]]; then - break - fi - CLIENT_DATA_DECLARE_LINE="${CLIENT_DATA_SYNC[$i]}" +_nc_first=1 +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 @@ -73,10 +70,11 @@ for i in {0..99}; do echo "Already found configured local folder ${CLIENT_DATA_SYNC_LINE[0]} syncing with ${CLIENT_DATA_SYNC_LINE[1]} . Leaving it unchanged." else echo "Setup new sync from remote ${CLIENT_DATA_SYNC_LINE[1]} to local ${CLIENT_DATA_SYNC_LINE[0]}" - if [[ $i -gt 0 ]]; then - echo "Due to Bug in Nextcloud Client, more than one synced Folder cannot be setup currently. Maybe in the Future." - continue; + 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" @@ -96,50 +94,50 @@ for i in {0..99}; do echo "Please check the above output!" exit 1 fi + fi done # The Flatpak autoprovisioning may not successfully write the apppassword to - # KWallet from inside the sandbox, so write it directly via D-Bus. - # Nextcloud stores HTTP credentials in folder "Nextcloud" with keys: - # user:url/:0 (legacy password entry) - # user_app-password:url/:0 (app password entry, used for auth) - NC_WALLET_URL="https://${SERVERFQDN_NC}/" - NC_WALLET_APPID="logon_script" - NC_QB_CMD="qdbus-qt6" - if ! command -v ${NC_QB_CMD} >/dev/null 2>&1; then NC_QB_CMD="qdbus"; fi - # Only attempt KWallet on KDE: check that the service is registered on the session bus. - if command -v "${NC_QB_CMD}" >/dev/null 2>&1 && \ - "${NC_QB_CMD}" 2>/dev/null | grep -q "org.kde.kwalletd"; then - NC_QB_SVC="org.kde.kwalletd" - NC_QB_PATH="/modules/kwalletd6" - if ! ( ${NC_QB_CMD} "${NC_QB_SVC}" | grep -q "${NC_QB_PATH}" ); then - NC_QB_PATH="/modules/kwalletd5" - fi - echo "Checking Nextcloud app password in KWallet via D-Bus (${NC_QB_PATH})" - NC_WALLET_HANDLE=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.open "kdewallet" 0 "${NC_WALLET_APPID}") - if [[ -n "${NC_WALLET_HANDLE}" && "${NC_WALLET_HANDLE}" != "-1" ]]; then - HAS_FOLDER=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasFolder "${NC_WALLET_HANDLE}" "Nextcloud" "${NC_WALLET_APPID}") - if [[ "${HAS_FOLDER}" != "true" ]]; then - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.createFolder "${NC_WALLET_HANDLE}" "Nextcloud" "${NC_WALLET_APPID}" >/dev/null - fi - HAS_PW1=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasEntry "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}:${NC_WALLET_URL}:0" "${NC_WALLET_APPID}") - HAS_PW2=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasEntry "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}_app-password:${NC_WALLET_URL}:0" "${NC_WALLET_APPID}") - if [[ "${HAS_PW1}" == "true" && "${HAS_PW2}" == "true" ]]; then - echo "Nextcloud app password already present in KWallet — no change needed." - else - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}_app-password:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null - echo "Nextcloud app password written to KWallet successfully." - fi - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.sync "${NC_WALLET_HANDLE}" "${NC_WALLET_APPID}" >/dev/null - ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.close "${NC_WALLET_HANDLE}" false "${NC_WALLET_APPID}" >/dev/null - else - echo "Warning: Could not open KWallet (handle: ${NC_WALLET_HANDLE}). Nextcloud may prompt for credentials on next start." - fi - else - echo "KWallet not available (non-KDE desktop) — skipping credential storage." - fi +# KWallet from inside the sandbox, so write it directly via D-Bus. +# Nextcloud stores HTTP credentials in folder "Nextcloud" with keys: +# user:url/:0 (legacy password entry) +# user_app-password:url/:0 (app password entry, used for auth) +NC_WALLET_URL="https://${SERVERFQDN_NC}/" +NC_WALLET_APPID="logon_script" +NC_QB_CMD="qdbus-qt6" +if ! command -v ${NC_QB_CMD} >/dev/null 2>&1; then NC_QB_CMD="qdbus"; fi +# Only attempt KWallet on KDE: check that the service is registered on the session bus. +if command -v "${NC_QB_CMD}" >/dev/null 2>&1 && \ + "${NC_QB_CMD}" 2>/dev/null | grep -q "org.kde.kwalletd"; then + NC_QB_SVC="org.kde.kwalletd" + NC_QB_PATH="/modules/kwalletd6" + if ! ( ${NC_QB_CMD} "${NC_QB_SVC}" | grep -q "${NC_QB_PATH}" ); then + NC_QB_PATH="/modules/kwalletd5" fi + echo "Checking Nextcloud app password in KWallet via D-Bus (${NC_QB_PATH})" + NC_WALLET_HANDLE=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.open "kdewallet" 0 "${NC_WALLET_APPID}") + if [ -n "${NC_WALLET_HANDLE}" ] && [ "${NC_WALLET_HANDLE}" != "-1" ]; then + HAS_FOLDER=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasFolder "${NC_WALLET_HANDLE}" "Nextcloud" "${NC_WALLET_APPID}") + if [ "${HAS_FOLDER}" != "true" ]; then + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.createFolder "${NC_WALLET_HANDLE}" "Nextcloud" "${NC_WALLET_APPID}" >/dev/null + fi + HAS_PW1=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasEntry "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}:${NC_WALLET_URL}:0" "${NC_WALLET_APPID}") + HAS_PW2=$(${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.hasEntry "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}_app-password:${NC_WALLET_URL}:0" "${NC_WALLET_APPID}") + if [ "${HAS_PW1}" = "true" ] && [ "${HAS_PW2}" = "true" ]; then + echo "Nextcloud app password already present in KWallet — no change needed." + else + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.writePassword "${NC_WALLET_HANDLE}" "Nextcloud" "${DAVTOKEN_USER}_app-password:${NC_WALLET_URL}:0" "${DAVTOKEN_PASS}" "${NC_WALLET_APPID}" >/dev/null + echo "Nextcloud app password written to KWallet successfully." + fi + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.sync "${NC_WALLET_HANDLE}" "${NC_WALLET_APPID}" >/dev/null + ${NC_QB_CMD} ${NC_QB_SVC} ${NC_QB_PATH} org.kde.KWallet.close "${NC_WALLET_HANDLE}" false "${NC_WALLET_APPID}" >/dev/null + else + echo "Warning: Could not open KWallet (handle: ${NC_WALLET_HANDLE}). Nextcloud may prompt for credentials on next start." + fi +else + echo "KWallet not available (non-KDE desktop) — skipping credential storage." +fi # Now start Nextcloud echo "Starting Nextcloud Client in Background" 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 23/27] 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!" From 2bdee44e656e1f045277d595c05b20f3c420ce26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Mon, 4 May 2026 14:07:11 +0200 Subject: [PATCH 24/27] nextcloud/user_run: use timestamp suffix for renamed backup folders Replace static _bak suffix with _YYYYMMDDhhmmss.bak so repeated runs never fail trying to overwrite an existing backup directory. Co-Authored-By: Claude Sonnet 4.6 --- client_software/0050_nextcloud_desktopclient/user_run.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index 2abf296..cc5a332 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -78,8 +78,9 @@ for CLIENT_DATA_DECLARE_LINE in "${CLIENT_DATA_SYNC[@]}"; do # 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" + _nc_bak="${CLIENT_DATA_SYNC_LINE[0]}_$(date '+%Y%m%d%H%M%S').bak" + echo "Old unsynced Folder ${CLIENT_DATA_SYNC_LINE[0]} was found, renaming to ${_nc_bak}." + mv "${CLIENT_DATA_SYNC_LINE[0]}" "${_nc_bak}" fi mkdir -p ${CLIENT_DATA_SYNC_LINE[0]} SYNCCMD="$BASECMD --userid ${DAVTOKEN_USER} --apppassword ${DAVTOKEN_PASS} --localdirpath ${CLIENT_DATA_SYNC_LINE[0]} --remotedirpath ${CLIENT_DATA_SYNC_LINE[1]} --serverurl https://${SERVERFQDN_NC}" From fb726795db6c7a6a789ef851edec3600dfdfd7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Mon, 4 May 2026 14:11:39 +0200 Subject: [PATCH 25/27] nextcloud/user_run: prompt to clean up leftover .bak folders before sync Before the sync loop, find all *.bak directories in the parent dirs of configured sync paths, list them with their size, and ask the user to delete them with a y/N prompt. Co-Authored-By: Claude Sonnet 4.6 --- .../0050_nextcloud_desktopclient/user_run.sh | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index cc5a332..ecc4064 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -60,6 +60,29 @@ if [ "${#CLIENT_DATA_SYNC[@]}" -eq 0 ]; then exit 0 fi +#Check for leftover .bak directories from previous failed setups +_nc_bak_list=$( + for CLIENT_DATA_DECLARE_LINE in "${CLIENT_DATA_SYNC[@]}"; do + eval "${CLIENT_DATA_DECLARE_LINE}" + find "$(dirname "${CLIENT_DATA_SYNC_LINE[0]}")" -maxdepth 1 -type d -name "*.bak" 2>/dev/null + done | sort -u +) +if [ -n "${_nc_bak_list}" ]; then + echo "The following old backup folders were found and should be removed:" + echo "${_nc_bak_list}" | while IFS= read -r _nc_d; do + [ -n "${_nc_d}" ] && echo " $(du -sh "${_nc_d}" 2>/dev/null | cut -f1) ${_nc_d}" + done + read -r -p "Delete these backup folders? [y/N]: " _nc_del + if [ "${_nc_del}" = "y" ] || [ "${_nc_del}" = "Y" ]; then + echo "${_nc_bak_list}" | while IFS= read -r _nc_d; do + if [ -n "${_nc_d}" ]; then + rm -rf "${_nc_d}" + echo "Deleted: ${_nc_d}" + fi + done + fi +fi + #Loop through all Entries #_nc_first=1 _nc_wipe_done=0 From f04bbdf9f16ac529163a66bb1959204fe235b219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Mon, 4 May 2026 14:12:41 +0200 Subject: [PATCH 26/27] nextcloud/user_run: reactivate _nc_first single-folder guard Co-Authored-By: Claude Sonnet 4.6 --- .../0050_nextcloud_desktopclient/user_run.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index ecc4064..27274e4 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -84,7 +84,7 @@ if [ -n "${_nc_bak_list}" ]; 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}" @@ -92,14 +92,13 @@ for CLIENT_DATA_DECLARE_LINE in "${CLIENT_DATA_SYNC[@]}"; do # 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 _nc_bak="${CLIENT_DATA_SYNC_LINE[0]}_$(date '+%Y%m%d%H%M%S').bak" echo "Old unsynced Folder ${CLIENT_DATA_SYNC_LINE[0]} was found, renaming to ${_nc_bak}." From 3b392c78628b7352cc8a1fa0e703b575b585f3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Mon, 4 May 2026 15:21:48 +0200 Subject: [PATCH 27/27] nextcloud/user_run: block new setups when any folder is already configured Set _nc_first=0 in the already-found branch so that a configured folder prevents subsequent entries from wiping the Nextcloud config. Co-Authored-By: Claude Sonnet 4.6 --- client_software/0050_nextcloud_desktopclient/user_run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index 27274e4..61f886e 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -92,6 +92,7 @@ for CLIENT_DATA_DECLARE_LINE in "${CLIENT_DATA_SYNC[@]}"; do # 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