From adf576fbe17f40c13c1d77dd9751f2e9dbf523a1 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 9 Sep 2025 20:08:33 +0200 Subject: [PATCH] fix(setup/update): detect native installs first (/opt/picpeak/app/backend or systemd unit); avoid false docker updates on root --- scripts/setup.sh | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 796ac25..ec826d7 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -944,16 +944,31 @@ print_success_message() { update_installation() { print_header "Updating PicPeak" - - # Detect existing installation - if [[ -d "$DOCKER_APP_DIR" ]] || [[ -d "/home/${SUDO_USER:-}/picpeak" ]]; then - INSTALL_METHOD="docker" - update_docker_installation - elif [[ -d "$NATIVE_APP_DIR" ]]; then + + # Prefer explicit native install detection first + native_detected=false + docker_detected=false + + # Native detection: app/backend exists OR systemd unit present + if [[ -d "$NATIVE_APP_DIR/app/backend" ]]; then + native_detected=true + elif command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q '^picpeak-backend.service'; then + native_detected=true + fi + + # Docker detection: docker app dir or user home picpeak dir exists + if [[ -d "$DOCKER_APP_DIR" ]] || [[ -n "${SUDO_USER:-}" && -d "/home/${SUDO_USER}/picpeak" ]]; then + docker_detected=true + fi + + if [[ "$native_detected" == true ]]; then INSTALL_METHOD="native" update_native_installation + elif [[ "$docker_detected" == true ]]; then + INSTALL_METHOD="docker" + update_docker_installation else - die "No existing PicPeak installation found" + die "No existing PicPeak installation found (native dir $NATIVE_APP_DIR/app/backend or docker dir $DOCKER_APP_DIR not present)" fi }