fix(install): handle pre-existing install dir during git clone

The 'Creating directory structure' step runs mkdir -p on INSTALL_DIR
before the clone step, so git clone fails if the directory is non-empty.
Clone to a temp directory and copy contents into place to preserve any
existing data/ and logs/ subdirectories.
This commit is contained in:
NixReaper
2026-04-11 08:31:42 -05:00
parent eebcce027b
commit 6e59552e4f
+6 -1
View File
@@ -482,7 +482,12 @@ if [[ -d "$INSTALL_DIR/.git" ]]; then
git -C "$INSTALL_DIR" pull --ff-only git -C "$INSTALL_DIR" pull --ff-only
else else
info "Cloning repository into $INSTALL_DIR..." info "Cloning repository into $INSTALL_DIR..."
git clone https://github.com/NixReaper/nixpanel-server.git "$INSTALL_DIR" # The directory may already exist (created by the mkdir step above).
# Clone to a temp dir then copy contents in so data/ and logs/ are preserved.
TMP_CLONE=$(mktemp -d)
git clone https://github.com/NixReaper/nixpanel-server.git "$TMP_CLONE"
cp -a "$TMP_CLONE/." "$INSTALL_DIR/"
rm -rf "$TMP_CLONE"
fi fi
success "NixPanel source ready at $INSTALL_DIR" success "NixPanel source ready at $INSTALL_DIR"