feat(PROJ-30): Xapian → Manticore Search Migration
- internal/index/manticore.go: ManticoreTenantManager + manticoreIndex (RT-Indizes, CGO-frei) - internal/index/index.go: TenantIndexer Interface (Xapian + Manticore) - internal/index/tenant_worker.go: mgr-Typ auf TenantIndexer Interface - internal/api/server.go: idxMgr auf TenantIndexer Interface - config/config.go: IndexConfig.ManticoreDSN Feld - cmd/archivmail/cmd_reindex.go: reindex Subkommando - cmd/archivmail/main.go: Manticore-Branch + reindex Case - go.mod: github.com/go-sql-driver/mysql v1.8.1 - update.sh: Manticore auto-install, CGO_ENABLED=0, config.yml migration, auto-reindex fix(IMAP): TCP-Deadline-Wrapper für steckengebliebene Imports fix(auth): Email-Claim in JWT für User-Isolation fix(search): User-Isolation via sess.Email (fail-safe) fix(ui): Admin-Login Auth-Cache, Logout-Redirect, IMAP-Polling-Resilienz Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -50,6 +50,33 @@ command -v node >/dev/null || die "node nicht gefunden"
|
||||
command -v npm >/dev/null || die "npm nicht gefunden"
|
||||
command -v go >/dev/null || die "go nicht gefunden — apt-get install golang-go"
|
||||
|
||||
# ── Manticore Search prüfen / installieren ────────────────────────────────
|
||||
|
||||
if ! command -v searchd >/dev/null 2>&1 && ! systemctl is-active --quiet manticore 2>/dev/null; then
|
||||
info "Manticore Search nicht gefunden — installiere..."
|
||||
apt-get install -y wget gnupg2 lsb-release 2>/dev/null || true
|
||||
MANTICORE_CODENAME=$(lsb_release -cs 2>/dev/null || echo "bookworm")
|
||||
wget -q -O /tmp/manticore.deb \
|
||||
"https://repo.manticoresearch.com/repository/manticoresearch_${MANTICORE_CODENAME}/pool/main/m/manticoresearch/manticoresearch_6.3.6_amd64.deb" 2>/dev/null \
|
||||
|| wget -q -O /tmp/manticore.deb \
|
||||
"https://github.com/manticoresoftware/manticoresearch/releases/download/6.3.6/manticoresearch_6.3.6.202408011246.4c39781ba-1+${MANTICORE_CODENAME}_amd64.deb" 2>/dev/null \
|
||||
|| true
|
||||
if [[ -f /tmp/manticore.deb ]]; then
|
||||
dpkg -i /tmp/manticore.deb 2>/dev/null || apt-get install -f -y 2>/dev/null || true
|
||||
rm -f /tmp/manticore.deb
|
||||
log "Manticore Search installiert"
|
||||
else
|
||||
warn "Manticore Search konnte nicht automatisch installiert werden — bitte manuell installieren"
|
||||
warn "Siehe: https://manticoresearch.com/install/"
|
||||
fi
|
||||
fi
|
||||
|
||||
if systemctl list-unit-files manticore.service >/dev/null 2>&1; then
|
||||
systemctl enable manticore 2>/dev/null || true
|
||||
systemctl is-active --quiet manticore || systemctl start manticore 2>/dev/null || warn "Manticore-Dienst konnte nicht gestartet werden"
|
||||
systemctl is-active --quiet manticore && log "Manticore Search läuft"
|
||||
fi
|
||||
|
||||
# ── Quellcode holen ───────────────────────────────────────────────────────
|
||||
|
||||
if [[ -d "$BUILD_DIR/.git" ]]; then
|
||||
@@ -69,8 +96,8 @@ fi
|
||||
|
||||
info "Baue Go Backend..."
|
||||
cd "$BUILD_DIR"
|
||||
go mod download
|
||||
CGO_ENABLED=1 go build -tags xapian -buildvcs=false -o "$BUILD_DIR/archivmail-new" ./cmd/archivmail/
|
||||
go mod tidy && go mod download
|
||||
CGO_ENABLED=0 go build -buildvcs=false -o "$BUILD_DIR/archivmail-new" ./cmd/archivmail/
|
||||
log "Go Backend gebaut"
|
||||
|
||||
# ── Next.js Frontend bauen ────────────────────────────────────────────────
|
||||
@@ -89,11 +116,26 @@ info "Stoppe Dienste..."
|
||||
systemctl stop archivmail-web 2>/dev/null || warn "archivmail-web nicht aktiv"
|
||||
systemctl stop archivmail 2>/dev/null || warn "archivmail nicht aktiv"
|
||||
|
||||
# Xapian-Lockfile entfernen (verhindert DatabaseLockError beim Neustart)
|
||||
XAPIAN_LOCK=$(grep -A2 'index:' /etc/archivmail/config.yml 2>/dev/null | awk '/path:/{print $2}')
|
||||
if [[ -n "$XAPIAN_LOCK" && -f "$XAPIAN_LOCK/flintlock" ]]; then
|
||||
rm -f "$XAPIAN_LOCK/flintlock"
|
||||
log "Xapian-Lockfile entfernt"
|
||||
# ── Manticore als Standard-Backend in config.yml setzen ──────────────────
|
||||
CONFIG_FILE="/etc/archivmail/config.yml"
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
# Backend auf manticore umstellen falls noch nicht gesetzt
|
||||
if grep -q 'backend:' "$CONFIG_FILE"; then
|
||||
if ! grep -q 'backend: manticore' "$CONFIG_FILE"; then
|
||||
sed -i 's/^\([[:space:]]*\)backend:.*/\1backend: manticore/' "$CONFIG_FILE"
|
||||
info "Index-Backend auf 'manticore' gesetzt"
|
||||
fi
|
||||
else
|
||||
# backend: Zeile unter index: einfuegen
|
||||
sed -i '/^index:/a\ backend: manticore' "$CONFIG_FILE"
|
||||
info "Index-Backend 'manticore' hinzugefuegt"
|
||||
fi
|
||||
# manticore_dsn setzen falls nicht vorhanden
|
||||
if ! grep -q 'manticore_dsn' "$CONFIG_FILE"; then
|
||||
sed -i '/backend: manticore/a\ manticore_dsn: "manticore@tcp(127.0.0.1:9306)/"' "$CONFIG_FILE"
|
||||
info "Manticore-DSN gesetzt"
|
||||
fi
|
||||
log "Manticore-Konfiguration aktualisiert"
|
||||
fi
|
||||
|
||||
# ── Dateien einspielen ────────────────────────────────────────────────────
|
||||
@@ -132,6 +174,19 @@ systemctl start archivmail
|
||||
systemctl start archivmail-web
|
||||
log "Dienste gestartet"
|
||||
|
||||
# ── Manticore Reindex (einmalig nach Backend-Umstieg) ─────────────────────
|
||||
sleep 2
|
||||
if grep -q 'backend: manticore' /etc/archivmail/config.yml 2>/dev/null \
|
||||
&& systemctl is-active --quiet archivmail 2>/dev/null \
|
||||
&& systemctl is-active --quiet manticore 2>/dev/null; then
|
||||
info "Baue Manticore-Suchindex auf (alle Mails)..."
|
||||
if timeout 600 /opt/archivmail/bin/archivmail reindex --config /etc/archivmail/config.yml; then
|
||||
log "Manticore-Index aufgebaut"
|
||||
else
|
||||
warn "Reindex nicht abgeschlossen — bei Bedarf manuell: archivmail reindex"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── Status prüfen ─────────────────────────────────────────────────────────
|
||||
|
||||
sleep 2
|
||||
|
||||
Reference in New Issue
Block a user