From d478d8079acb1af60a6604f0badeb22c7f9c78d9 Mon Sep 17 00:00:00 2001 From: "Bernd (Hermes)" Date: Sun, 12 Jul 2026 14:34:20 +0200 Subject: [PATCH] fix(install): M11 numpy/faiss via uv pip, M12 bootstrap.sh + broken clone recovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit M11: _venv_install() helper nutzt uv pip (Hermes v0.18.0+) mit Fallback-Kette: uv pip > pip > python -m pip, für venv/ und .venv/. Ersetzt alle 3 numpy/faiss-Installationsblöcke (perform_update, perform_update_only, main install path). M12: bootstrap.sh als One-Command-Entrypoint: ssh-keyscan → git clone (SSH→HTTP fallback) → exec install.sh. _bootstrap_repo() erkennt jetzt broken clones (.git ja, plugin/ nein) und löscht + cloned neu statt fatal abzubrechen. --- bootstrap.sh | 63 ++++++++++++++++++++++++++++++++++++++++++ install.sh | 78 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 112 insertions(+), 29 deletions(-) create mode 100755 bootstrap.sh diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..46dfb51 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# +# Hermes Rocket.Chat Plugin — Bootstrap (One-Command Installer) +# https://gitea.thomander.de/andreas/Hermes_rocket.chat_Plugin +# +# Usage (fresh VM, no repo cloned yet): +# curl -sSL https://192.168.180.47/Andreas/Hermes_rocket.chat_Plugin/raw/branch/main/bootstrap.sh | bash +# +# Or locally: +# ./bootstrap.sh [install.sh arguments...] +# +# What this does: +# 1. ssh-keyscan: ensures Gitea host key is in known_hosts (M12 fix) +# 2. git clone: clones the plugin repo (SSH → HTTP fallback) +# 3. exec: hands off to install.sh with all arguments preserved +# +set -euo pipefail + +GITEA_HOST="192.168.180.47" +GITEA_PORT="222" +REPO_PATH="Andreas/Hermes_rocket.chat_Plugin" +CLONE_TARGET="$HOME/Hermes_rocket.chat_Plugin" + +# ── Step 1: ssh-keyscan (M12 — muss VOR git clone laufen) ── +echo "🔑 Ensuring Gitea host key is in known_hosts..." +mkdir -p "$HOME/.ssh" +chmod 700 "$HOME/.ssh" +if ! grep -q "${GITEA_HOST}" "$HOME/.ssh/known_hosts" 2>/dev/null; then + ssh-keyscan -p "${GITEA_PORT}" "${GITEA_HOST}" >> "$HOME/.ssh/known_hosts" 2>/dev/null || { + echo "⚠️ ssh-keyscan failed — git clone via SSH may fail, HTTP fallback will be used" + } + echo " Host key added." +else + echo " Host key already present." +fi + +# ── Step 2: Clone repo (falls nicht vorhanden) ── +if [ -d "$CLONE_TARGET/.git" ] && [ -d "$CLONE_TARGET/plugin" ]; then + echo "✅ Repo already present at $CLONE_TARGET" +elif [ -d "$CLONE_TARGET/.git" ]; then + echo "⚠️ Broken clone detected — removing and re-cloning..." + rm -rf "$CLONE_TARGET" +fi + +if [ ! -d "$CLONE_TARGET/.git" ]; then + echo "📦 Cloning plugin repo..." + SSH_URL="git@${GITEA_HOST}:${REPO_PATH}.git" + HTTP_URL="https://${GITEA_HOST}/${REPO_PATH}.git" + + if git clone "$SSH_URL" "$CLONE_TARGET" 2>/dev/null; then + echo "✅ Clone via SSH successful" + elif git clone "$HTTP_URL" "$CLONE_TARGET" 2>/dev/null; then + echo "✅ Clone via HTTP (fallback) successful" + else + echo "❌ Clone failed — SSH key for Gitea (${GITEA_HOST}:${GITEA_PORT}) or HTTP access required" + echo " Manual: git clone $SSH_URL $CLONE_TARGET" + exit 1 + fi +fi + +# ── Step 3: Hand off to install.sh ── +echo "🚀 Starting install.sh..." +exec "$CLONE_TARGET/install.sh" "$@" diff --git a/install.sh b/install.sh index c197e78..22ad6bb 100755 --- a/install.sh +++ b/install.sh @@ -43,14 +43,23 @@ _bootstrap_repo() { # U2: git clone mit SSH→HTTP Fallback echo "📦 Klone Plugin-Repo..." if [ -d "$clone_target/.git" ]; then - echo "✅ Repo bereits vorhanden unter $clone_target" - elif git clone "$ssh_url" "$clone_target" 2>/dev/null; then - echo "✅ Clone via SSH erfolgreich" - elif git clone "$http_url" "$clone_target" 2>/dev/null; then - echo "✅ Clone via HTTP (Fallback) erfolgreich" - else - echo "❌ Git clone fehlgeschlagen — SSH-Key für Gitea (${gitea_host}:${gitea_port}) oder HTTP-Zugang nötig" - exit 1 + # M12: Broken Clone erkennen — .git vorhanden aber plugin/ fehlt + if [ ! -d "$clone_target/plugin" ]; then + echo "⚠️ Broken clone detected (no plugin/) — removing and re-cloning..." + rm -rf "$clone_target" + else + echo "✅ Repo bereits vorhanden unter $clone_target" + fi + fi + if [ ! -d "$clone_target/.git" ]; then + if git clone "$ssh_url" "$clone_target" 2>/dev/null; then + echo "✅ Clone via SSH erfolgreich" + elif git clone "$http_url" "$clone_target" 2>/dev/null; then + echo "✅ Clone via HTTP (Fallback) erfolgreich" + else + echo "❌ Git clone fehlgeschlagen — SSH-Key für Gitea (${gitea_host}:${gitea_port}) oder HTTP-Zugang nötig" + exit 1 + fi fi # Guard: .git vorhanden aber plugin/ fehlt → unvollständiger Clone → fatal (verhindert Endlosschleife) @@ -220,6 +229,29 @@ load_lang() { } # ─── Helper ────────────────────────────────────────────── +# M11: Install a package in the Hermes venv. +# Hermes v0.18.0+ uses uv; older versions use pip. +# Priority: uv pip > pip > python -m pip (for both venv/ and .venv/). +_venv_install() { + local hermes_dir="$1" pkg="$2" + if [ -f "$hermes_dir/venv/bin/uv" ]; then + "$hermes_dir/venv/bin/uv" pip install "$pkg" 2>&1 | tail -1 + elif [ -f "$hermes_dir/venv/bin/pip" ]; then + "$hermes_dir/venv/bin/pip" install "$pkg" 2>&1 | tail -1 + elif [ -f "$hermes_dir/venv/bin/python" ]; then + "$hermes_dir/venv/bin/python" -m pip install "$pkg" 2>&1 | tail -1 + elif [ -f "$hermes_dir/.venv/bin/uv" ]; then + "$hermes_dir/.venv/bin/uv" pip install "$pkg" 2>&1 | tail -1 + elif [ -f "$hermes_dir/.venv/bin/pip" ]; then + "$hermes_dir/.venv/bin/pip" install "$pkg" 2>&1 | tail -1 + elif [ -f "$hermes_dir/.venv/bin/python" ]; then + "$hermes_dir/.venv/bin/python" -m pip install "$pkg" 2>&1 | tail -1 + else + echo "⚠️ Cannot install $pkg — no venv found in $hermes_dir" + return 1 + fi +} + confirm_or_edit() { # $1 = env-var name (RC_URL, RC_BOT_USER, …) # $2 = message key (enter_url, enter_botuser, …) @@ -456,14 +488,10 @@ perform_update() { # Archivar braucht numpy + faiss für FAISS Phase-1 RoomIndex. # Nur im Multi-Room-Agent-Modus nötig; Single-Room-Bot bleibt schlank. # M9: numpy ist Pflicht, faiss-cpu best-effort (kann auf ARM fehlen). + # M11: _venv_install nutzt uv pip (Hermes v0.18.0+) mit pip-Fallback. if [ "$RC_MULTIROOM" = "true" ]; then - if [ -f "$hermes_dir/venv/bin/pip" ]; then - "$hermes_dir/venv/bin/pip" install numpy 2>&1 | tail -1 - "$hermes_dir/venv/bin/pip" install faiss-cpu 2>/dev/null || echo "⚠️ faiss-cpu not available (ARM?) — Archivar uses fallback" - elif [ -f "$hermes_dir/.venv/bin/pip" ]; then - "$hermes_dir/.venv/bin/pip" install numpy 2>&1 | tail -1 - "$hermes_dir/.venv/bin/pip" install faiss-cpu 2>/dev/null || echo "⚠️ faiss-cpu not available (ARM?) — Archivar uses fallback" - fi + _venv_install "$hermes_dir" numpy + _venv_install "$hermes_dir" faiss-cpu 2>/dev/null || echo "⚠️ faiss-cpu not available (ARM?) — Archivar uses fallback" fi # ─── FIX: room-map.json bereitstellen (nur Multi-Room) ───────── @@ -690,14 +718,10 @@ perform_update_only() { # Archivar braucht numpy + faiss für FAISS Phase-1 RoomIndex. # Nur im Multi-Room-Agent-Modus nötig; Single-Room-Bot bleibt schlank. # M9: numpy ist Pflicht, faiss-cpu best-effort (kann auf ARM fehlen). + # M11: _venv_install nutzt uv pip (Hermes v0.18.0+) mit pip-Fallback. if [ "$RC_MULTIROOM" = "true" ]; then - if [ -f "$hermes_dir/venv/bin/pip" ]; then - "$hermes_dir/venv/bin/pip" install numpy 2>&1 | tail -1 - "$hermes_dir/venv/bin/pip" install faiss-cpu 2>/dev/null || echo "⚠️ faiss-cpu not available (ARM?) — Archivar uses fallback" - elif [ -f "$hermes_dir/.venv/bin/pip" ]; then - "$hermes_dir/.venv/bin/pip" install numpy 2>&1 | tail -1 - "$hermes_dir/.venv/bin/pip" install faiss-cpu 2>/dev/null || echo "⚠️ faiss-cpu not available (ARM?) — Archivar uses fallback" - fi + _venv_install "$hermes_dir" numpy + _venv_install "$hermes_dir" faiss-cpu 2>/dev/null || echo "⚠️ faiss-cpu not available (ARM?) — Archivar uses fallback" fi # ─── FIX: room-map.json bereitstellen (nur Multi-Room) ───────── @@ -1087,14 +1111,10 @@ msg cache_cleared # Archivar braucht numpy + faiss für FAISS Phase-1 RoomIndex. # Nur im Multi-Room-Agent-Modus nötig; Single-Room-Bot bleibt schlank. # M9: numpy ist Pflicht, faiss-cpu best-effort (kann auf ARM fehlen). +# M11: _venv_install nutzt uv pip (Hermes v0.18.0+) mit pip-Fallback. if [ "$RC_MULTIROOM" = "true" ]; then - if [ -f "$HERMES_DIR/venv/bin/pip" ]; then - "$HERMES_DIR/venv/bin/pip" install numpy 2>&1 | tail -1 - "$HERMES_DIR/venv/bin/pip" install faiss-cpu 2>/dev/null || echo "⚠️ faiss-cpu not available (ARM?) — Archivar uses fallback" - elif [ -f "$HERMES_DIR/.venv/bin/pip" ]; then - "$HERMES_DIR/.venv/bin/pip" install numpy 2>&1 | tail -1 - "$HERMES_DIR/.venv/bin/pip" install faiss-cpu 2>/dev/null || echo "⚠️ faiss-cpu not available (ARM?) — Archivar uses fallback" - fi + _venv_install "$HERMES_DIR" numpy + _venv_install "$HERMES_DIR" faiss-cpu 2>/dev/null || echo "⚠️ faiss-cpu not available (ARM?) — Archivar uses fallback" fi # ─── FIX: room-map.json bereitstellen ────────────────────────