diff --git a/crumbpages-doktor.sh b/crumbpages-doktor.sh index 75da962..4538d21 100755 --- a/crumbpages-doktor.sh +++ b/crumbpages-doktor.sh @@ -28,6 +28,10 @@ CRUMB_API_TOKEN="changeme" CRUMB_SSH_USER="admin" CRUMB_SCP_TARGET="backup.crumbforest.de:/var/backups" +# Vektor DB (Qdrant) +CRUMB_QDRANT_URL="http://localhost:6333" +CRUMB_QDRANT_KEY="" + EOF echo -e "${GREEN}.env Template erstellt. Bitte anpassen!${NC}" sleep 2 @@ -331,6 +335,71 @@ EOF rm -f "$TOOL_RC" } +# ----------------------------------------------------------------------------- +# Modul: Qdrant Doktor (Vektor DB) +# ----------------------------------------------------------------------------- +function qdrant_doktor() { + echo -e "${BLUE}--- 🧠 Vektor Doktor (Qdrant) ---${NC}" + export QDRANT_RC="/tmp/qdrant_doktor.rc" + + cat > "$QDRANT_RC" << EOF +if [ -f /etc/bashrc ]; then source /etc/bashrc; fi +if [ -f ~/.bashrc ]; then source ~/.bashrc; fi + +export PS1="\[\033[1;35m\](🧠 Vektor) \u@\h:\w$ \[\033[0m\]" +export QDRANT_URL="$CRUMB_QDRANT_URL" +export QDRANT_KEY="$CRUMB_QDRANT_KEY" + +function q_help() { + echo "Target: \$QDRANT_URL" + echo "" + echo "Commands:" + echo " q_health -> Check Health (/healthz)" + echo " q_list -> List Collections" + echo " q_info -> Cluster Info" + echo " q_search
-> Search (Raw JSON)" +} + +function _q_curl() { + local endpoint="\$1" + local method="\${2:-GET}" + local body="\$3" + + ARGS=(-s) + if [ -n "\$QDRANT_KEY" ]; then ARGS+=(-H "api-key: \$QDRANT_KEY"); fi + ARGS+=(-H "Content-Type: application/json") + + if [ "$method" == "POST" ]; then + curl "\${ARGS[@]}" -X POST -d "\$body" "\$QDRANT_URL/\$endpoint" + else + curl "\${ARGS[@]}" "\$QDRANT_URL/\$endpoint" + fi +} + +function q_health() { + resp=\$(_q_curl "healthz") + echo "Status: \$resp" +} + +function q_list() { + _q_curl "collections" | jq .result.collections[] 2>/dev/null || _q_curl "collections" +} + +function q_info() { + _q_curl "" | jq 2>/dev/null || _q_curl "" +} + +alias ql="q_list" + +echo "" +q_help +EOF + + bash --rcfile "$QDRANT_RC" + rm -f "$QDRANT_RC" +} + + # ----------------------------------------------------------------------------- # Hauptmenü # ----------------------------------------------------------------------------- @@ -344,9 +413,10 @@ while true; do echo "4) 🕸️ Web Tools (API / Curl)" echo "5) 🔐 Remote Tools (SSH / SCP)" echo "6) 🛠️ General Tools (Shell)" - echo "7) 👋 Beenden" + echo "7) 🧠 Qdrant Doktor (Vektor DB)" + echo "8) 👋 Beenden" echo "" - read -p "Auswahl [1-7]: " CHOICE + read -p "Auswahl [1-8]: " CHOICE case $CHOICE in 1) git_doktor ;; @@ -355,7 +425,8 @@ while true; do 4) web_doktor ;; 5) remote_doktor ;; 6) tools_doktor ;; - 7) echo "Ahoi!"; exit 0 ;; - *) echo "Bitte 1-7 wählen."; sleep 1 ;; + 7) qdrant_doktor ;; + 8) echo "Ahoi!"; exit 0 ;; + *) echo "Bitte 1-8 wählen."; sleep 1 ;; esac done