chore: Projekt aufräumen - nicht benötigte Dateien entfernt

Entfernte Dateien:
- BotKonzept SaaS Workflows (Customer-Registration, Trial-Management)
- botkonzept-website/ (separates Projekt)
- Flowise-spezifische Scripts (install_flowise.sh, setup_flowise_account.sh)
- Test-Scripts (test_*.sh)
- Utility-Scripts (save_credentials.sh, update_credentials.sh, etc.)
- Redundante Template-Dateien (reload-workflow-fixed.sh, .backup)

Behalten:
- Kern-Installationsskripte (install.sh, libsupabase.sh, setup_nginx_proxy.sh)
- RAGKI-BotPGVector.json (Standard RAG Workflow)
- Alle Dokumentationen (.md Dateien)
- Logo (20250119_Logo_Botkozept.svg)
- templates/, sql/, credentials/, logs/, wiki/
This commit is contained in:
2026-01-28 22:04:39 +01:00
parent 583f30b498
commit bf1b3b05f2
20 changed files with 0 additions and 5609 deletions

View File

@@ -1,312 +0,0 @@
{
"name": "BotKonzept - Customer Registration & Trial Management",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "botkonzept-registration",
"responseMode": "responseNode",
"options": {}
},
"id": "webhook-registration",
"name": "Registration Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1.1,
"position": [250, 300],
"webhookId": "botkonzept-registration"
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json.body.email}}",
"operation": "isNotEmpty"
},
{
"value1": "={{$json.body.firstName}}",
"operation": "isNotEmpty"
},
{
"value1": "={{$json.body.lastName}}",
"operation": "isNotEmpty"
}
]
}
},
"id": "validate-input",
"name": "Validate Input",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [450, 300]
},
{
"parameters": {
"operation": "insert",
"schema": "public",
"table": "customers",
"columns": "email,first_name,last_name,company,status,created_at,trial_end_date",
"additionalFields": {
"returnFields": "*"
}
},
"id": "create-customer",
"name": "Create Customer in DB",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [650, 200],
"credentials": {
"postgres": {
"id": "supabase-local",
"name": "Supabase Local"
}
}
},
{
"parameters": {
"authentication": "privateKey",
"command": "=/root/customer-installer/install.sh --storage local-zfs --bridge vmbr0 --ip dhcp --vlan 90 --apt-proxy http://192.168.45.2:3142 --n8n-owner-email {{ $json.email }} --n8n-owner-pass \"{{ $('Generate-Password').item.json.password }}\"",
"cwd": "/root/customer-installer/"
},
"id": "create-instance",
"name": "Create Customer Instance",
"type": "n8n-nodes-base.ssh",
"typeVersion": 1,
"position": [850, 200],
"credentials": {
"sshPrivateKey": {
"id": "pve20-ssh",
"name": "PVE20"
}
}
},
{
"parameters": {
"jsCode": "// Parse installation output\nconst stdout = $input.item.json.stdout;\nconst installData = JSON.parse(stdout);\n\n// Add customer info\ninstallData.customer = {\n id: $('Create Customer in DB').item.json.id,\n email: $('Create Customer in DB').item.json.email,\n firstName: $('Create Customer in DB').item.json.first_name,\n lastName: $('Create Customer in DB').item.json.last_name,\n company: $('Create Customer in DB').item.json.company\n};\n\nreturn installData;"
},
"id": "parse-install-output",
"name": "Parse Install Output",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [1050, 200]
},
{
"parameters": {
"operation": "insert",
"schema": "public",
"table": "instances",
"columns": "customer_id,ctid,hostname,ip,fqdn,status,credentials,created_at,trial_end_date",
"additionalFields": {}
},
"id": "save-instance",
"name": "Save Instance to DB",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [1250, 200],
"credentials": {
"postgres": {
"id": "supabase-local",
"name": "Supabase Local"
}
}
},
{
"parameters": {
"fromEmail": "noreply@botkonzept.de",
"toEmail": "={{ $json.customer.email }}",
"subject": "Willkommen bei BotKonzept - Ihre Instanz ist bereit! 🎉",
"emailType": "html",
"message": "=<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"UTF-8\">\n <style>\n body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }\n .container { max-width: 600px; margin: 0 auto; padding: 20px; }\n .header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; text-align: center; border-radius: 10px 10px 0 0; }\n .content { background: #f9fafb; padding: 30px; }\n .credentials { background: white; padding: 20px; border-radius: 8px; margin: 20px 0; border-left: 4px solid #667eea; }\n .button { display: inline-block; background: #667eea; color: white; padding: 12px 30px; text-decoration: none; border-radius: 6px; margin: 20px 0; }\n .footer { text-align: center; padding: 20px; color: #6b7280; font-size: 14px; }\n .highlight { background: #fef3c7; padding: 2px 6px; border-radius: 3px; }\n </style>\n</head>\n<body>\n <div class=\"container\">\n <div class=\"header\">\n <h1>🎉 Willkommen bei BotKonzept!</h1>\n <p>Ihre KI-Chatbot-Instanz ist bereit</p>\n </div>\n \n <div class=\"content\">\n <p>Hallo {{ $json.customer.firstName }},</p>\n \n <p>vielen Dank für Ihre Registrierung! Ihre persönliche KI-Chatbot-Instanz wurde erfolgreich erstellt und ist jetzt einsatzbereit.</p>\n \n <div class=\"credentials\">\n <h3>📋 Ihre Zugangsdaten</h3>\n <p><strong>Dashboard-URL:</strong><br>\n <a href=\"{{ $json.urls.n8n_external }}\">{{ $json.urls.n8n_external }}</a></p>\n \n <p><strong>E-Mail:</strong> {{ $json.n8n.owner_email }}<br>\n <strong>Passwort:</strong> <span class=\"highlight\">{{ $json.n8n.owner_password }}</span></p>\n \n <p><strong>Chat-Webhook:</strong><br>\n <code>{{ $json.urls.chat_webhook }}</code></p>\n \n <p><strong>Upload-Formular:</strong><br>\n <a href=\"{{ $json.urls.upload_form }}\">{{ $json.urls.upload_form }}</a></p>\n </div>\n \n <h3>🚀 Nächste Schritte:</h3>\n <ol>\n <li><strong>Einloggen:</strong> Klicken Sie auf den Link oben und loggen Sie sich ein</li>\n <li><strong>Dokumente hochladen:</strong> Laden Sie Ihre PDFs, FAQs oder andere Dokumente hoch</li>\n <li><strong>Chatbot testen:</strong> Testen Sie Ihren Chatbot direkt im Dashboard</li>\n <li><strong>Code einbinden:</strong> Kopieren Sie den Widget-Code auf Ihre Website</li>\n </ol>\n \n <a href=\"{{ $json.urls.n8n_external }}\" class=\"button\">Jetzt Dashboard öffnen →</a>\n \n <div style=\"background: #fef3c7; padding: 15px; border-radius: 8px; margin: 20px 0;\">\n <p><strong>💰 Frühbucher-Angebot:</strong></p>\n <p>Upgraden Sie in den nächsten 3 Tagen und erhalten Sie <strong>30% Rabatt</strong> auf Ihr erstes Jahr!</p>\n </div>\n \n <p><strong>Trial-Zeitraum:</strong> 7 Tage (bis {{ $json.trial_end_date }})</p>\n \n <p>Bei Fragen stehen wir Ihnen jederzeit zur Verfügung!</p>\n \n <p>Viel Erfolg mit Ihrem KI-Chatbot!<br>\n Ihr BotKonzept-Team</p>\n </div>\n \n <div class=\"footer\">\n <p>BotKonzept | KI-Chatbots für moderne Unternehmen</p>\n <p><a href=\"https://botkonzept.de\">botkonzept.de</a> | <a href=\"mailto:support@botkonzept.de\">support@botkonzept.de</a></p>\n </div>\n </div>\n</body>\n</html>",
"options": {
"allowUnauthorizedCerts": false
}
},
"id": "send-welcome-email",
"name": "Send Welcome Email",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2.1,
"position": [1450, 200],
"credentials": {
"smtp": {
"id": "postfix-ses",
"name": "Postfix SES"
}
}
},
{
"parameters": {
"operation": "insert",
"schema": "public",
"table": "emails_sent",
"columns": "customer_id,email_type,sent_at",
"additionalFields": {}
},
"id": "log-email",
"name": "Log Email Sent",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [1650, 200],
"credentials": {
"postgres": {
"id": "supabase-local",
"name": "Supabase Local"
}
}
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ { \"success\": true, \"message\": \"Registrierung erfolgreich! Sie erhalten in Kürze eine E-Mail mit Ihren Zugangsdaten.\", \"customerId\": $json.customer.id, \"instanceUrl\": $json.urls.n8n_external } }}",
"options": {
"responseCode": 200
}
},
"id": "success-response",
"name": "Success Response",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [1850, 200]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ { \"success\": false, \"error\": \"Ungültige Eingabedaten. Bitte überprüfen Sie Ihre Angaben.\" } }}",
"options": {
"responseCode": 400
}
},
"id": "error-response",
"name": "Error Response",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [650, 400]
},
{
"parameters": {
"jsCode": "// Generate secure password\nconst length = 16;\nconst charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';\nlet password = '';\n\nfor (let i = 0; i < length; i++) {\n const randomIndex = Math.floor(Math.random() * charset.length);\n password += charset[randomIndex];\n}\n\n// Calculate trial end date (7 days from now)\nconst trialEndDate = new Date();\ntrialEndDate.setDate(trialEndDate.getDate() + 7);\n\nreturn {\n password: password,\n trialEndDate: trialEndDate.toISOString(),\n email: $json.body.email,\n firstName: $json.body.firstName,\n lastName: $json.body.lastName,\n company: $json.body.company || null\n};"
},
"id": "generate-password",
"name": "Generate Password & Trial Date",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [650, 100]
}
],
"connections": {
"Registration Webhook": {
"main": [
[
{
"node": "Validate Input",
"type": "main",
"index": 0
}
]
]
},
"Validate Input": {
"main": [
[
{
"node": "Generate Password & Trial Date",
"type": "main",
"index": 0
}
],
[
{
"node": "Error Response",
"type": "main",
"index": 0
}
]
]
},
"Generate Password & Trial Date": {
"main": [
[
{
"node": "Create Customer in DB",
"type": "main",
"index": 0
}
]
]
},
"Create Customer in DB": {
"main": [
[
{
"node": "Create Customer Instance",
"type": "main",
"index": 0
}
]
]
},
"Create Customer Instance": {
"main": [
[
{
"node": "Parse Install Output",
"type": "main",
"index": 0
}
]
]
},
"Parse Install Output": {
"main": [
[
{
"node": "Save Instance to DB",
"type": "main",
"index": 0
}
]
]
},
"Save Instance to DB": {
"main": [
[
{
"node": "Send Welcome Email",
"type": "main",
"index": 0
}
]
]
},
"Send Welcome Email": {
"main": [
[
{
"node": "Log Email Sent",
"type": "main",
"index": 0
}
]
]
},
"Log Email Sent": {
"main": [
[
{
"node": "Success Response",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"tags": [],
"triggerCount": 0,
"updatedAt": "2025-01-25T00:00:00.000Z",
"versionId": "1"
}

View File

@@ -1,122 +0,0 @@
{
"name": "BotKonzept - Trial Management & Email Automation",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "cronExpression",
"expression": "0 9 * * *"
}
]
}
},
"id": "daily-cron",
"name": "Daily at 9 AM",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.1,
"position": [250, 300]
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT c.id as customer_id, c.email, c.first_name, c.last_name, c.company, c.created_at, c.status, i.ctid, i.hostname, i.fqdn, i.trial_end_date, i.credentials, EXTRACT(DAY FROM (NOW() - c.created_at)) as days_since_registration FROM customers c JOIN instances i ON c.id = i.customer_id WHERE c.status = 'trial' AND i.status = 'active' AND c.created_at >= NOW() - INTERVAL '8 days'",
"additionalFields": {}
},
"id": "get-trial-customers",
"name": "Get Trial Customers",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [450, 300],
"credentials": {
"postgres": {
"id": "supabase-local",
"name": "Supabase Local"
}
}
},
{
"parameters": {
"conditions": {
"number": [
{
"value1": "={{$json.days_since_registration}}",
"operation": "equal",
"value2": 3
}
]
}
},
"id": "check-day-3",
"name": "Day 3?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [650, 200]
},
{
"parameters": {
"operation": "insert",
"schema": "public",
"table": "emails_sent",
"columns": "customer_id,email_type,sent_at",
"additionalFields": {}
},
"id": "log-email-sent",
"name": "Log Email Sent",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [1450, 200],
"credentials": {
"postgres": {
"id": "supabase-local",
"name": "Supabase Local"
}
}
}
],
"connections": {
"Daily at 9 AM": {
"main": [
[
{
"node": "Get Trial Customers",
"type": "main",
"index": 0
}
]
]
},
"Get Trial Customers": {
"main": [
[
{
"node": "Day 3?",
"type": "main",
"index": 0
}
]
]
},
"Day 3?": {
"main": [
[
{
"node": "Log Email Sent",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"tags": [],
"triggerCount": 0,
"updatedAt": "2025-01-25T00:00:00.000Z",
"versionId": "1"
}

View File

@@ -1,326 +0,0 @@
{
"name": "Install-Workflow",
"nodes": [
{
"parameters": {
"authentication": "privateKey",
"command": "/root/customer-installer/install.sh --storage local-zfs --bridge vmbr0 --ip dhcp --vlan 90 --apt-proxy http://192.168.45.2:3142",
"cwd": "/root/customer-installer/"
},
"type": "n8n-nodes-base.ssh",
"typeVersion": 1,
"position": [
192,
0
],
"id": "9878a864-651e-4a53-abfc-b0bc2d2f2d15",
"name": "Start Installer 1",
"credentials": {
"sshPrivateKey": {
"id": "bPl4nGXO7Iz4wJPJ",
"name": "PVE20"
}
}
},
{
"parameters": {
"authentication": "privateKey",
"command": "=./n8n_setup.sh --n8n_internal {{ $json.urls.n8n_internal }} --owner_email {{ $json.n8n.owner_email }} --owner_password \"{{ $json.n8n.owner_password }}\" --owner_first_name \"Max\" --owner_last_name \"Mustermann\" --timeout 30",
"cwd": "/root/customer-installer/"
},
"type": "n8n-nodes-base.ssh",
"typeVersion": 1,
"position": [
640,
0
],
"id": "62e1b647-7daa-445e-bf99-873efbe2bc94",
"name": "Setup n8n Owner",
"credentials": {
"sshPrivateKey": {
"id": "bPl4nGXO7Iz4wJPJ",
"name": "PVE20"
}
},
"disabled": true
},
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-32,
0
],
"id": "11aa3e6a-b20a-49b0-b6f9-4cec469c9916",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"authentication": "privateKey",
"command": "=bash setup_nginx_proxy.sh --ctid {{ $('install_JSON').item.json.ctid }} --hostname {{ $('install_JSON').item.json.hostname }} --fqdn {{ $('install_JSON').item.json.fqdn }} --backend-ip {{ $('install_JSON').item.json.ip }}",
"cwd": "/root/customer-installer/"
},
"type": "n8n-nodes-base.ssh",
"typeVersion": 1,
"position": [
1088,
0
],
"id": "176fd78c-9dd6-427b-a566-88dbf504347e",
"name": "setup_nginx_proxy",
"credentials": {
"sshPrivateKey": {
"id": "bPl4nGXO7Iz4wJPJ",
"name": "PVE20"
}
},
"disabled": true
},
{
"parameters": {
"formTitle": "Delete",
"formFields": {
"values": [
{
"fieldLabel": "Host-Number",
"requiredField": true
}
]
},
"options": {
"buttonLabel": "Löschen"
}
},
"type": "n8n-nodes-base.formTrigger",
"typeVersion": 2.5,
"position": [
-32,
208
],
"id": "4c9878ec-177c-4fbd-a83a-a3895ebd8193",
"name": "On form submission",
"webhookId": "12847d69-15c8-44e4-b595-645ff3109355"
},
{
"parameters": {
"jsCode": "// Code Node - JavaScript\nconst sshOutput = $input.all();\n\n// stdout-String parsen\nconst parsedData = JSON.parse(sshOutput[0].json.stdout);\n\nreturn [{\n json: parsedData\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
416,
0
],
"id": "67ace9d6-7ed2-4495-b3e6-6091fd252596",
"name": "install_JSON"
},
{
"parameters": {
"jsCode": "// Code Node - JavaScript\nconst sshOutput = $input.all();\n\n// stdout-String parsen\nconst parsedData = JSON.parse(sshOutput[0].json.stdout);\n\nreturn [{\n json: parsedData\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
864,
0
],
"id": "fc1b9d9f-5a70-476e-8ae2-4cfd81050527",
"name": "setupOwnerJSON",
"disabled": true
},
{
"parameters": {
"jsCode": "// Code Node - JavaScript\nconst sshOutput = $input.all();\n\n// stdout-String parsen\nconst parsedData = JSON.parse(sshOutput[0].json.stdout);\n\nreturn [{\n json: parsedData\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1312,
0
],
"id": "86b70266-cafe-4a4f-98d1-20434f61061b",
"name": "setupProxyJSON",
"disabled": true
},
{
"parameters": {
"chatId": "26805429",
"text": "=Done.\nhttps://{{ $json.fqdn }}\nUsername: {{ $('install_JSON').item.json.n8n.owner_email }}\nPassword: {{ $('install_JSON').item.json.n8n.owner_password }}\nChat: {{ $('install_JSON').item.json.urls.chat_webhook }}",
"additionalFields": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1536,
0
],
"id": "9e20ee75-c2ae-421f-ac4c-54f5643032f2",
"name": "Send a text message",
"webhookId": "55a97e93-a457-4bee-8b8f-3eea1ad62928",
"credentials": {
"telegramApi": {
"id": "7DYJfIx5JsxgKc0D",
"name": "LizTheLove_Bot"
}
}
},
{
"parameters": {
"authentication": "privateKey",
"command": "=/root/customer-installer/delete_nginx_proxy.sh --ctid {{ $('On form submission').item.json['Host-Number'] }}",
"cwd": "/root/customer-installer/"
},
"type": "n8n-nodes-base.ssh",
"typeVersion": 1,
"position": [
416,
208
],
"id": "34d50d3a-cdb8-4801-b54b-719ef60b4b63",
"name": "deleteProxy",
"credentials": {
"sshPrivateKey": {
"id": "bPl4nGXO7Iz4wJPJ",
"name": "PVE20"
}
}
},
{
"parameters": {
"authentication": "privateKey",
"command": "=pct stop {{ $json['Host-Number'] }} && pct destroy {{ $json['Host-Number'] }} ",
"cwd": "/root/customer-installer/"
},
"type": "n8n-nodes-base.ssh",
"typeVersion": 1,
"position": [
192,
208
],
"id": "4645ace7-30ef-4698-8288-065fe70ff9b0",
"name": "deleteLXC",
"credentials": {
"sshPrivateKey": {
"id": "bPl4nGXO7Iz4wJPJ",
"name": "PVE20"
}
}
}
],
"pinData": {},
"connections": {
"Start Installer 1": {
"main": [
[
{
"node": "install_JSON",
"type": "main",
"index": 0
}
]
]
},
"Setup n8n Owner": {
"main": [
[
{
"node": "setupOwnerJSON",
"type": "main",
"index": 0
}
]
]
},
"When clicking Execute workflow": {
"main": [
[
{
"node": "Start Installer 1",
"type": "main",
"index": 0
}
]
]
},
"On form submission": {
"main": [
[
{
"node": "deleteLXC",
"type": "main",
"index": 0
}
]
]
},
"install_JSON": {
"main": [
[
{
"node": "Setup n8n Owner",
"type": "main",
"index": 0
}
]
]
},
"setupOwnerJSON": {
"main": [
[
{
"node": "setup_nginx_proxy",
"type": "main",
"index": 0
}
]
]
},
"setup_nginx_proxy": {
"main": [
[
{
"node": "setupProxyJSON",
"type": "main",
"index": 0
}
]
]
},
"setupProxyJSON": {
"main": [
[
{
"node": "Send a text message",
"type": "main",
"index": 0
}
]
]
},
"deleteLXC": {
"main": [
[
{
"node": "deleteProxy",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"availableInMCP": false
},
"versionId": "7814a0dd-fae3-40e6-913b-f7b8bac10e81",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "c832ea07b2e6ccb9d5832b81bb497b720b31ed50006898070951c4f6d209f426"
},
"id": "ba7BxTeeQif4zu2F",
"tags": []
}

View File

@@ -1,884 +0,0 @@
/* ===================================
CSS Variables & Reset
=================================== */
:root {
--primary-color: #2563eb;
--primary-dark: #1e40af;
--primary-light: #3b82f6;
--secondary-color: #10b981;
--text-dark: #1f2937;
--text-light: #6b7280;
--bg-light: #f9fafb;
--bg-white: #ffffff;
--border-color: #e5e7eb;
--success-color: #10b981;
--error-color: #ef4444;
--warning-color: #f59e0b;
--font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
--font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
--radius-sm: 0.375rem;
--radius-md: 0.5rem;
--radius-lg: 0.75rem;
--radius-xl: 1rem;
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
scroll-behavior: smooth;
}
body {
font-family: var(--font-sans);
color: var(--text-dark);
line-height: 1.6;
background-color: var(--bg-white);
}
img {
max-width: 100%;
height: auto;
}
a {
text-decoration: none;
color: inherit;
transition: var(--transition);
}
ul {
list-style: none;
}
/* ===================================
Container & Layout
=================================== */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 1.5rem;
}
section {
padding: 5rem 0;
}
.section-header {
text-align: center;
margin-bottom: 3rem;
}
.section-header h2 {
font-size: 2.5rem;
font-weight: 700;
margin-bottom: 1rem;
color: var(--text-dark);
}
.section-header p {
font-size: 1.25rem;
color: var(--text-light);
max-width: 600px;
margin: 0 auto;
}
/* ===================================
Navigation
=================================== */
.navbar {
background: var(--bg-white);
box-shadow: var(--shadow-sm);
position: sticky;
top: 0;
z-index: 1000;
border-bottom: 1px solid var(--border-color);
}
.nav-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 0;
}
.logo {
display: flex;
align-items: center;
gap: 0.75rem;
font-size: 1.5rem;
font-weight: 700;
color: var(--text-dark);
}
.logo img {
height: 40px;
}
.nav-menu {
display: flex;
align-items: center;
gap: 2rem;
}
.nav-menu a {
color: var(--text-light);
font-weight: 500;
transition: var(--transition);
}
.nav-menu a:hover {
color: var(--primary-color);
}
.mobile-menu-toggle {
display: none;
flex-direction: column;
gap: 0.25rem;
background: none;
border: none;
cursor: pointer;
padding: 0.5rem;
}
.mobile-menu-toggle span {
width: 24px;
height: 2px;
background: var(--text-dark);
transition: var(--transition);
}
/* ===================================
Buttons
=================================== */
.btn-primary,
.btn-secondary {
display: inline-block;
padding: 0.75rem 1.5rem;
border-radius: var(--radius-md);
font-weight: 600;
text-align: center;
transition: var(--transition);
cursor: pointer;
border: none;
font-size: 1rem;
}
.btn-primary {
background: var(--primary-color);
color: white;
}
.btn-primary:hover {
background: var(--primary-dark);
transform: translateY(-2px);
box-shadow: var(--shadow-lg);
}
.btn-secondary {
background: transparent;
color: var(--primary-color);
border: 2px solid var(--primary-color);
}
.btn-secondary:hover {
background: var(--primary-color);
color: white;
}
.btn-large {
padding: 1rem 2rem;
font-size: 1.125rem;
}
.btn-block {
width: 100%;
display: block;
}
/* ===================================
Hero Section
=================================== */
.hero {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 6rem 0;
position: relative;
overflow: hidden;
}
.hero::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="100" height="100" patternUnits="userSpaceOnUse"><path d="M 100 0 L 0 0 0 100" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1"/></pattern></defs><rect width="100%" height="100%" fill="url(%23grid)"/></svg>');
opacity: 0.3;
}
.hero-content {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 4rem;
align-items: center;
position: relative;
z-index: 1;
}
.hero h1 {
font-size: 3.5rem;
font-weight: 800;
line-height: 1.2;
margin-bottom: 1.5rem;
}
.hero-subtitle {
font-size: 1.25rem;
margin-bottom: 2rem;
opacity: 0.95;
}
.hero-cta {
display: flex;
gap: 1rem;
margin-bottom: 2rem;
}
.hero-features {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.feature-badge {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.95rem;
opacity: 0.9;
}
.feature-badge svg {
flex-shrink: 0;
}
/* Chatbot Demo */
.chatbot-demo {
background: white;
border-radius: var(--radius-xl);
box-shadow: var(--shadow-xl);
overflow: hidden;
max-width: 400px;
}
.demo-header {
background: var(--primary-color);
color: white;
padding: 1rem;
display: flex;
align-items: center;
gap: 1rem;
}
.demo-dots {
display: flex;
gap: 0.5rem;
}
.demo-dots span {
width: 12px;
height: 12px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.3);
}
.demo-title {
font-weight: 600;
}
.demo-messages {
padding: 1.5rem;
background: #f9fafb;
min-height: 300px;
display: flex;
flex-direction: column;
gap: 1rem;
}
.message {
display: flex;
gap: 0.75rem;
align-items: flex-start;
}
.message.user {
flex-direction: row-reverse;
}
.message .avatar {
width: 36px;
height: 36px;
border-radius: 50%;
background: var(--primary-light);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.message .bubble {
background: white;
padding: 0.75rem 1rem;
border-radius: var(--radius-lg);
box-shadow: var(--shadow-sm);
max-width: 70%;
color: var(--text-dark);
}
.message.user .bubble {
background: var(--primary-color);
color: white;
}
.demo-input {
padding: 1rem;
background: white;
border-top: 1px solid var(--border-color);
display: flex;
gap: 0.5rem;
}
.demo-input input {
flex: 1;
padding: 0.75rem;
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
font-size: 0.95rem;
}
.demo-input button {
padding: 0.75rem 1.5rem;
background: var(--primary-color);
color: white;
border: none;
border-radius: var(--radius-md);
cursor: pointer;
font-size: 1.25rem;
}
/* ===================================
Features Section
=================================== */
.features {
background: var(--bg-light);
}
.features-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
}
.feature-card {
background: white;
padding: 2rem;
border-radius: var(--radius-lg);
box-shadow: var(--shadow-md);
transition: var(--transition);
}
.feature-card:hover {
transform: translateY(-5px);
box-shadow: var(--shadow-xl);
}
.feature-icon {
font-size: 3rem;
margin-bottom: 1rem;
}
.feature-card h3 {
font-size: 1.5rem;
margin-bottom: 1rem;
color: var(--text-dark);
}
.feature-card p {
color: var(--text-light);
line-height: 1.7;
}
/* ===================================
How It Works Section
=================================== */
.steps {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2rem;
margin-top: 3rem;
}
.step {
text-align: center;
position: relative;
}
.step-number {
width: 60px;
height: 60px;
background: var(--primary-color);
color: white;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
font-weight: 700;
margin: 0 auto 1.5rem;
}
.step h3 {
font-size: 1.5rem;
margin-bottom: 1rem;
}
.step p {
color: var(--text-light);
}
/* ===================================
Pricing Section
=================================== */
.pricing {
background: var(--bg-light);
}
.pricing-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
margin-top: 3rem;
}
.pricing-card {
background: white;
border-radius: var(--radius-xl);
padding: 2.5rem;
box-shadow: var(--shadow-md);
transition: var(--transition);
position: relative;
}
.pricing-card:hover {
transform: translateY(-5px);
box-shadow: var(--shadow-xl);
}
.pricing-card.featured {
border: 3px solid var(--primary-color);
transform: scale(1.05);
}
.pricing-card .badge {
position: absolute;
top: -15px;
right: 20px;
background: var(--primary-color);
color: white;
padding: 0.5rem 1rem;
border-radius: var(--radius-md);
font-weight: 600;
font-size: 0.875rem;
}
.pricing-header h3 {
font-size: 1.5rem;
margin-bottom: 1rem;
}
.price {
display: flex;
align-items: baseline;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.price .currency {
font-size: 1.5rem;
font-weight: 600;
}
.price .amount {
font-size: 3.5rem;
font-weight: 800;
color: var(--primary-color);
}
.price .period {
font-size: 1.125rem;
color: var(--text-light);
}
.price-note {
font-size: 0.875rem;
color: var(--success-color);
font-weight: 600;
margin-bottom: 1.5rem;
}
.pricing-features {
margin: 2rem 0;
}
.pricing-features li {
padding: 0.75rem 0;
border-bottom: 1px solid var(--border-color);
color: var(--text-light);
}
.pricing-features li:last-child {
border-bottom: none;
}
/* ===================================
Trial Registration Section
=================================== */
.trial-registration {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.trial-content {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 4rem;
align-items: center;
}
.trial-info h2 {
font-size: 2.5rem;
margin-bottom: 1rem;
}
.trial-info p {
font-size: 1.25rem;
margin-bottom: 2rem;
opacity: 0.95;
}
.trial-benefits {
display: flex;
flex-direction: column;
gap: 1rem;
}
.trial-benefits li {
display: flex;
align-items: center;
gap: 1rem;
font-size: 1.125rem;
}
.trial-benefits svg {
flex-shrink: 0;
color: var(--success-color);
}
.trial-form-wrapper {
background: white;
border-radius: var(--radius-xl);
padding: 2.5rem;
box-shadow: var(--shadow-xl);
}
.trial-form h3 {
color: var(--text-dark);
font-size: 1.75rem;
margin-bottom: 1.5rem;
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
color: var(--text-dark);
font-weight: 500;
}
.form-group input {
width: 100%;
padding: 0.75rem;
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
font-size: 1rem;
transition: var(--transition);
}
.form-group input:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group.checkbox {
display: flex;
align-items: flex-start;
gap: 0.75rem;
}
.form-group.checkbox input {
width: auto;
margin-top: 0.25rem;
}
.form-group.checkbox label {
margin: 0;
font-weight: 400;
font-size: 0.95rem;
}
.form-group.checkbox a {
color: var(--primary-color);
text-decoration: underline;
}
.form-note {
font-size: 0.875rem;
color: var(--text-light);
text-align: center;
margin-top: 1rem;
}
.btn-loading {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
}
.spinner {
animation: spin 1s linear infinite;
}
.spinner circle {
stroke-dasharray: 90, 150;
stroke-dashoffset: 0;
stroke-linecap: round;
}
@keyframes spin {
100% {
transform: rotate(360deg);
}
}
/* Success Message */
.success-message {
text-align: center;
padding: 2rem;
}
.success-icon {
width: 80px;
height: 80px;
background: var(--success-color);
color: white;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 3rem;
margin: 0 auto 1.5rem;
}
.success-message h3 {
color: var(--text-dark);
font-size: 1.75rem;
margin-bottom: 1rem;
}
.success-message p {
color: var(--text-light);
margin-bottom: 1.5rem;
}
.success-details {
background: var(--bg-light);
padding: 1.5rem;
border-radius: var(--radius-md);
text-align: left;
}
.success-details p {
color: var(--text-dark);
font-weight: 600;
margin-bottom: 1rem;
}
.success-details ol {
list-style: decimal;
padding-left: 1.5rem;
color: var(--text-light);
}
.success-details li {
margin-bottom: 0.5rem;
}
/* ===================================
FAQ Section
=================================== */
.faq-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 2rem;
}
.faq-item {
background: white;
padding: 2rem;
border-radius: var(--radius-lg);
box-shadow: var(--shadow-md);
}
.faq-item h3 {
font-size: 1.25rem;
margin-bottom: 1rem;
color: var(--text-dark);
}
.faq-item p {
color: var(--text-light);
line-height: 1.7;
}
/* ===================================
Footer
=================================== */
.footer {
background: var(--text-dark);
color: white;
padding: 3rem 0 1.5rem;
}
.footer-content {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 2rem;
margin-bottom: 2rem;
}
.footer-section h4 {
margin-bottom: 1rem;
font-size: 1.125rem;
}
.footer-section p {
opacity: 0.8;
margin-top: 0.5rem;
}
.footer-section ul {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.footer-section a {
opacity: 0.8;
transition: var(--transition);
}
.footer-section a:hover {
opacity: 1;
color: var(--primary-light);
}
.footer-bottom {
border-top: 1px solid rgba(255, 255, 255, 0.1);
padding-top: 1.5rem;
text-align: center;
opacity: 0.8;
}
/* ===================================
Responsive Design
=================================== */
@media (max-width: 768px) {
.nav-menu {
display: none;
}
.mobile-menu-toggle {
display: flex;
}
.hero-content,
.trial-content {
grid-template-columns: 1fr;
gap: 2rem;
}
.hero h1 {
font-size: 2.5rem;
}
.hero-cta {
flex-direction: column;
}
.section-header h2 {
font-size: 2rem;
}
.steps {
grid-template-columns: 1fr;
}
.pricing-grid {
grid-template-columns: 1fr;
}
.pricing-card.featured {
transform: scale(1);
}
.faq-grid {
grid-template-columns: 1fr;
}
}
@media (max-width: 480px) {
.hero h1 {
font-size: 2rem;
}
.hero-subtitle {
font-size: 1rem;
}
.section-header h2 {
font-size: 1.75rem;
}
.trial-form-wrapper {
padding: 1.5rem;
}
}

View File

@@ -1,417 +0,0 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BotKonzept - KI-Chatbot für Ihre Website in 7 Tagen kostenlos testen</title>
<meta name="description" content="Testen Sie Ihren eigenen KI-Chatbot 7 Tage kostenlos. Einfache Integration, leistungsstarke RAG-Technologie, keine Kreditkarte erforderlich.">
<link rel="stylesheet" href="css/style.css">
<link rel="icon" type="image/svg+xml" href="../20250119_Logo_Botkozept.svg">
</head>
<body>
<!-- Navigation -->
<nav class="navbar">
<div class="container">
<div class="nav-wrapper">
<a href="index.html" class="logo">
<img src="../20250119_Logo_Botkozept.svg" alt="BotKonzept Logo" height="40">
<span>BotKonzept</span>
</a>
<ul class="nav-menu">
<li><a href="#features">Features</a></li>
<li><a href="#how-it-works">So funktioniert's</a></li>
<li><a href="#pricing">Preise</a></li>
<li><a href="#faq">FAQ</a></li>
<li><a href="#trial" class="btn-primary">7 Tage kostenlos testen</a></li>
</ul>
<button class="mobile-menu-toggle" aria-label="Menu">
<span></span>
<span></span>
<span></span>
</button>
</div>
</div>
</nav>
<!-- Hero Section -->
<section class="hero">
<div class="container">
<div class="hero-content">
<div class="hero-text">
<h1>Ihr KI-Chatbot in Minuten einsatzbereit</h1>
<p class="hero-subtitle">
Verwandeln Sie Ihre Dokumente in einen intelligenten Chatbot.
Keine Programmierung erforderlich. 7 Tage kostenlos testen.
</p>
<div class="hero-cta">
<a href="#trial" class="btn-primary btn-large">Jetzt kostenlos starten</a>
<a href="#how-it-works" class="btn-secondary btn-large">Mehr erfahren</a>
</div>
<div class="hero-features">
<div class="feature-badge">
<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
<path d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 111.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" fill="currentColor"/>
</svg>
<span>Keine Kreditkarte erforderlich</span>
</div>
<div class="feature-badge">
<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
<path d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 111.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" fill="currentColor"/>
</svg>
<span>In 5 Minuten eingerichtet</span>
</div>
<div class="feature-badge">
<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
<path d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 111.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" fill="currentColor"/>
</svg>
<span>DSGVO-konform</span>
</div>
</div>
</div>
<div class="hero-image">
<div class="chatbot-demo">
<div class="demo-header">
<div class="demo-dots">
<span></span>
<span></span>
<span></span>
</div>
<span class="demo-title">Ihr Chatbot</span>
</div>
<div class="demo-messages">
<div class="message bot">
<div class="avatar">🤖</div>
<div class="bubble">Hallo! Wie kann ich Ihnen helfen?</div>
</div>
<div class="message user">
<div class="bubble">Was sind Ihre Öffnungszeiten?</div>
<div class="avatar">👤</div>
</div>
<div class="message bot">
<div class="avatar">🤖</div>
<div class="bubble">Wir sind Mo-Fr von 9-18 Uhr für Sie da!</div>
</div>
</div>
<div class="demo-input">
<input type="text" placeholder="Ihre Frage..." disabled>
<button disabled></button>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Features Section -->
<section id="features" class="features">
<div class="container">
<div class="section-header">
<h2>Leistungsstarke Features für Ihren Erfolg</h2>
<p>Alles, was Sie für einen professionellen KI-Chatbot benötigen</p>
</div>
<div class="features-grid">
<div class="feature-card">
<div class="feature-icon">📄</div>
<h3>Dokument-Upload</h3>
<p>Laden Sie PDFs, Word-Dokumente oder Texte hoch. Ihr Chatbot lernt automatisch aus Ihren Inhalten.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🧠</div>
<h3>RAG-Technologie</h3>
<p>Modernste Retrieval-Augmented Generation für präzise und kontextbezogene Antworten.</p>
</div>
<div class="feature-card">
<div class="feature-icon"></div>
<h3>Blitzschnelle Integration</h3>
<p>Ein einfacher Code-Snippet - fertig! Ihr Chatbot ist in Minuten auf Ihrer Website.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🎨</div>
<h3>Anpassbares Design</h3>
<p>Passen Sie Farben, Logo und Texte an Ihre Marke an. Kein Entwickler erforderlich.</p>
</div>
<div class="feature-card">
<div class="feature-icon">📊</div>
<h3>Analytics & Insights</h3>
<p>Verstehen Sie Ihre Kunden besser mit detaillierten Statistiken und Gesprächsverläufen.</p>
</div>
<div class="feature-card">
<div class="feature-icon">🔒</div>
<h3>DSGVO-konform</h3>
<p>Ihre Daten bleiben in Deutschland. Volle DSGVO-Konformität garantiert.</p>
</div>
</div>
</div>
</section>
<!-- How It Works Section -->
<section id="how-it-works" class="how-it-works">
<div class="container">
<div class="section-header">
<h2>So einfach geht's</h2>
<p>In 4 Schritten zu Ihrem eigenen KI-Chatbot</p>
</div>
<div class="steps">
<div class="step">
<div class="step-number">1</div>
<div class="step-content">
<h3>Registrieren</h3>
<p>Erstellen Sie Ihr kostenloses Testkonto in wenigen Sekunden. Keine Kreditkarte erforderlich.</p>
</div>
</div>
<div class="step">
<div class="step-number">2</div>
<div class="step-content">
<h3>Dokumente hochladen</h3>
<p>Laden Sie Ihre PDFs, FAQs oder andere Dokumente hoch. Unser System verarbeitet sie automatisch.</p>
</div>
</div>
<div class="step">
<div class="step-number">3</div>
<div class="step-content">
<h3>Code einbinden</h3>
<p>Kopieren Sie den generierten Code-Snippet und fügen Sie ihn auf Ihrer Website ein.</p>
</div>
</div>
<div class="step">
<div class="step-number">4</div>
<div class="step-content">
<h3>Fertig!</h3>
<p>Ihr KI-Chatbot ist live und beantwortet Kundenanfragen rund um die Uhr.</p>
</div>
</div>
</div>
</div>
</section>
<!-- Pricing Section -->
<section id="pricing" class="pricing">
<div class="container">
<div class="section-header">
<h2>Transparente Preise</h2>
<p>Starten Sie kostenlos, upgraden Sie jederzeit</p>
</div>
<div class="pricing-grid">
<div class="pricing-card">
<div class="pricing-header">
<h3>Trial</h3>
<div class="price">
<span class="currency"></span>
<span class="amount">0</span>
<span class="period">/7 Tage</span>
</div>
</div>
<ul class="pricing-features">
<li>✓ Voller Funktionsumfang</li>
<li>✓ Bis zu 100 Dokumente</li>
<li>✓ 1.000 Nachrichten/Monat</li>
<li>✓ E-Mail-Support</li>
<li>✓ Keine Kreditkarte erforderlich</li>
</ul>
<a href="#trial" class="btn-primary btn-block">Jetzt starten</a>
</div>
<div class="pricing-card featured">
<div class="badge">Beliebt</div>
<div class="pricing-header">
<h3>Starter</h3>
<div class="price">
<span class="currency"></span>
<span class="amount">49</span>
<span class="period">/Monat</span>
</div>
<div class="price-note">Frühbucher-Rabatt: 30% in den ersten 3 Tagen</div>
</div>
<ul class="pricing-features">
<li>✓ Alle Trial-Features</li>
<li>✓ Unbegrenzte Dokumente</li>
<li>✓ 10.000 Nachrichten/Monat</li>
<li>✓ Prioritäts-Support</li>
<li>✓ Custom Branding</li>
<li>✓ Analytics Dashboard</li>
</ul>
<a href="#trial" class="btn-primary btn-block">Jetzt upgraden</a>
</div>
<div class="pricing-card">
<div class="pricing-header">
<h3>Business</h3>
<div class="price">
<span class="currency"></span>
<span class="amount">149</span>
<span class="period">/Monat</span>
</div>
</div>
<ul class="pricing-features">
<li>✓ Alle Starter-Features</li>
<li>✓ 50.000 Nachrichten/Monat</li>
<li>✓ Mehrere Chatbots</li>
<li>✓ API-Zugriff</li>
<li>✓ Dedizierter Support</li>
<li>✓ SLA-Garantie</li>
</ul>
<a href="#trial" class="btn-secondary btn-block">Kontakt aufnehmen</a>
</div>
</div>
</div>
</section>
<!-- Trial Registration Section -->
<section id="trial" class="trial-registration">
<div class="container">
<div class="trial-content">
<div class="trial-info">
<h2>Starten Sie Ihren 7-Tage-Test</h2>
<p>Keine Kreditkarte erforderlich. Voller Funktionsumfang. Jederzeit kündbar.</p>
<ul class="trial-benefits">
<li>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
<path d="M20 6L9 17l-5-5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span>Sofortiger Zugang zu Ihrer Instanz</span>
</li>
<li>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
<path d="M20 6L9 17l-5-5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span>Persönliche Einrichtungs-Hilfe</span>
</li>
<li>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
<path d="M20 6L9 17l-5-5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span>Exklusive Frühbucher-Rabatte</span>
</li>
</ul>
</div>
<div class="trial-form-wrapper">
<form id="trialForm" class="trial-form">
<h3>Kostenlos registrieren</h3>
<div class="form-group">
<label for="firstName">Vorname *</label>
<input type="text" id="firstName" name="firstName" required>
</div>
<div class="form-group">
<label for="lastName">Nachname *</label>
<input type="text" id="lastName" name="lastName" required>
</div>
<div class="form-group">
<label for="email">E-Mail-Adresse *</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="company">Firma (optional)</label>
<input type="text" id="company" name="company">
</div>
<div class="form-group checkbox">
<input type="checkbox" id="terms" name="terms" required>
<label for="terms">
Ich akzeptiere die <a href="terms.html" target="_blank">AGB</a> und <a href="privacy.html" target="_blank">Datenschutzerklärung</a>
</label>
</div>
<button type="submit" class="btn-primary btn-block btn-large">
<span class="btn-text">Jetzt kostenlos starten</span>
<span class="btn-loading" style="display: none;">
<svg class="spinner" width="20" height="20" viewBox="0 0 50 50">
<circle cx="25" cy="25" r="20" fill="none" stroke="currentColor" stroke-width="5"></circle>
</svg>
Wird erstellt...
</span>
</button>
<p class="form-note">Nach der Registrierung erhalten Sie sofort Zugang zu Ihrer persönlichen Instanz.</p>
</form>
<div id="successMessage" class="success-message" style="display: none;">
<div class="success-icon"></div>
<h3>Willkommen bei BotKonzept!</h3>
<p>Ihre Instanz wird gerade erstellt. Sie erhalten in wenigen Minuten eine E-Mail mit allen Zugangsdaten.</p>
<div class="success-details">
<p><strong>Was passiert jetzt?</strong></p>
<ol>
<li>Wir erstellen Ihre persönliche KI-Instanz</li>
<li>Sie erhalten eine E-Mail mit Login-Daten</li>
<li>Sie können sofort loslegen!</li>
</ol>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- FAQ Section -->
<section id="faq" class="faq">
<div class="container">
<div class="section-header">
<h2>Häufig gestellte Fragen</h2>
<p>Alles, was Sie wissen müssen</p>
</div>
<div class="faq-grid">
<div class="faq-item">
<h3>Brauche ich technische Kenntnisse?</h3>
<p>Nein! Sie müssen nur einen Code-Snippet auf Ihrer Website einfügen können. Alles andere übernehmen wir für Sie.</p>
</div>
<div class="faq-item">
<h3>Wie lange dauert die Einrichtung?</h3>
<p>Nach der Registrierung ist Ihre Instanz in ca. 5 Minuten einsatzbereit. Das Hochladen von Dokumenten dauert je nach Menge 1-10 Minuten.</p>
</div>
<div class="faq-item">
<h3>Kann ich jederzeit kündigen?</h3>
<p>Ja, Sie können jederzeit kündigen. Es gibt keine Mindestlaufzeit und keine versteckten Kosten.</p>
</div>
<div class="faq-item">
<h3>Wo werden meine Daten gespeichert?</h3>
<p>Alle Daten werden in Deutschland auf DSGVO-konformen Servern gespeichert. Ihre Daten gehören Ihnen.</p>
</div>
<div class="faq-item">
<h3>Welche Sprachen werden unterstützt?</h3>
<p>Der Chatbot unterstützt Deutsch, Englisch und viele weitere Sprachen. Die KI erkennt die Sprache automatisch.</p>
</div>
<div class="faq-item">
<h3>Was passiert nach dem Trial?</h3>
<p>Sie erhalten am Tag 3, 5 und 7 E-Mails mit Upgrade-Angeboten. Wenn Sie nicht upgraden, wird Ihre Instanz nach 7 Tagen gelöscht.</p>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="footer">
<div class="container">
<div class="footer-content">
<div class="footer-section">
<img src="../20250119_Logo_Botkozept.svg" alt="BotKonzept Logo" height="30">
<p>KI-Chatbots für moderne Unternehmen</p>
</div>
<div class="footer-section">
<h4>Produkt</h4>
<ul>
<li><a href="#features">Features</a></li>
<li><a href="#pricing">Preise</a></li>
<li><a href="#faq">FAQ</a></li>
<li><a href="docs.html">Dokumentation</a></li>
</ul>
</div>
<div class="footer-section">
<h4>Unternehmen</h4>
<ul>
<li><a href="about.html">Über uns</a></li>
<li><a href="contact.html">Kontakt</a></li>
<li><a href="blog.html">Blog</a></li>
</ul>
</div>
<div class="footer-section">
<h4>Rechtliches</h4>
<ul>
<li><a href="terms.html">AGB</a></li>
<li><a href="privacy.html">Datenschutz</a></li>
<li><a href="imprint.html">Impressum</a></li>
</ul>
</div>
</div>
<div class="footer-bottom">
<p>&copy; 2025 BotKonzept. Alle Rechte vorbehalten.</p>
</div>
</div>
</footer>
<script src="js/main.js"></script>
</body>
</html>

View File

@@ -1,388 +0,0 @@
// BotKonzept Website - Main JavaScript
// =====================================
// Configuration
const CONFIG = {
// n8n Webhook URL für Registrierung (wird später konfiguriert)
WEBHOOK_URL: 'https://n8n.userman.de/webhook/botkonzept-registration',
// Supabase URL (lokale Instanz)
SUPABASE_URL: 'http://192.168.45.3:3000',
SUPABASE_ANON_KEY: 'your-anon-key-here'
};
// =====================================
// Mobile Menu Toggle
// =====================================
document.addEventListener('DOMContentLoaded', function() {
const mobileMenuToggle = document.querySelector('.mobile-menu-toggle');
const navMenu = document.querySelector('.nav-menu');
if (mobileMenuToggle) {
mobileMenuToggle.addEventListener('click', function() {
navMenu.classList.toggle('active');
this.classList.toggle('active');
});
}
// Close mobile menu when clicking on a link
const navLinks = document.querySelectorAll('.nav-menu a');
navLinks.forEach(link => {
link.addEventListener('click', function() {
navMenu.classList.remove('active');
mobileMenuToggle.classList.remove('active');
});
});
});
// =====================================
// Smooth Scroll for Anchor Links
// =====================================
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
const offset = 80; // Navbar height
const targetPosition = target.offsetTop - offset;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
});
});
// =====================================
// Trial Registration Form
// =====================================
const trialForm = document.getElementById('trialForm');
const successMessage = document.getElementById('successMessage');
if (trialForm) {
trialForm.addEventListener('submit', async function(e) {
e.preventDefault();
// Get form data
const formData = {
firstName: document.getElementById('firstName').value.trim(),
lastName: document.getElementById('lastName').value.trim(),
email: document.getElementById('email').value.trim().toLowerCase(),
company: document.getElementById('company').value.trim() || null,
terms: document.getElementById('terms').checked,
registeredAt: new Date().toISOString(),
source: 'website',
utmSource: getUrlParameter('utm_source') || null,
utmMedium: getUrlParameter('utm_medium') || null,
utmCampaign: getUrlParameter('utm_campaign') || null
};
// Validate
if (!formData.firstName || !formData.lastName || !formData.email) {
showError('Bitte füllen Sie alle Pflichtfelder aus.');
return;
}
if (!validateEmail(formData.email)) {
showError('Bitte geben Sie eine gültige E-Mail-Adresse ein.');
return;
}
if (!formData.terms) {
showError('Bitte akzeptieren Sie die AGB und Datenschutzerklärung.');
return;
}
// Show loading state
const submitButton = trialForm.querySelector('button[type="submit"]');
const btnText = submitButton.querySelector('.btn-text');
const btnLoading = submitButton.querySelector('.btn-loading');
submitButton.disabled = true;
btnText.style.display = 'none';
btnLoading.style.display = 'flex';
try {
// Send to n8n webhook
const response = await fetch(CONFIG.WEBHOOK_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData)
});
if (!response.ok) {
throw new Error('Registrierung fehlgeschlagen');
}
const result = await response.json();
// Show success message
trialForm.style.display = 'none';
successMessage.style.display = 'block';
// Track conversion (Google Analytics, Facebook Pixel, etc.)
trackConversion('trial_registration', formData);
// Scroll to success message
successMessage.scrollIntoView({ behavior: 'smooth', block: 'center' });
} catch (error) {
console.error('Registration error:', error);
showError('Ein Fehler ist aufgetreten. Bitte versuchen Sie es später erneut oder kontaktieren Sie uns direkt.');
// Reset button state
submitButton.disabled = false;
btnText.style.display = 'inline';
btnLoading.style.display = 'none';
}
});
}
// =====================================
// Helper Functions
// =====================================
function validateEmail(email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(email);
}
function showError(message) {
// Create or update error message
let errorDiv = document.querySelector('.form-error');
if (!errorDiv) {
errorDiv = document.createElement('div');
errorDiv.className = 'form-error';
errorDiv.style.cssText = `
background: #fee2e2;
border: 1px solid #ef4444;
color: #991b1b;
padding: 1rem;
border-radius: 0.5rem;
margin-bottom: 1rem;
font-size: 0.95rem;
`;
trialForm.insertBefore(errorDiv, trialForm.firstChild);
}
errorDiv.textContent = message;
errorDiv.scrollIntoView({ behavior: 'smooth', block: 'center' });
// Remove after 5 seconds
setTimeout(() => {
errorDiv.remove();
}, 5000);
}
function getUrlParameter(name) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(name);
}
function trackConversion(eventName, data) {
// Google Analytics
if (typeof gtag !== 'undefined') {
gtag('event', eventName, {
'event_category': 'registration',
'event_label': 'trial',
'value': 0
});
}
// Facebook Pixel
if (typeof fbq !== 'undefined') {
fbq('track', 'Lead', {
content_name: 'Trial Registration',
content_category: 'Registration'
});
}
// Custom tracking
console.log('Conversion tracked:', eventName, data);
}
// =====================================
// Scroll Animations
// =====================================
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-in');
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe elements for animation
document.addEventListener('DOMContentLoaded', function() {
const animateElements = document.querySelectorAll('.feature-card, .step, .pricing-card, .faq-item');
animateElements.forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(20px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(el);
});
});
// Add CSS for animation
const style = document.createElement('style');
style.textContent = `
.animate-in {
opacity: 1 !important;
transform: translateY(0) !important;
}
`;
document.head.appendChild(style);
// =====================================
// Pricing Calculator (Optional)
// =====================================
function calculatePricing(plan, discount = 0) {
const prices = {
trial: 0,
starter: 49,
business: 149
};
const basePrice = prices[plan] || 0;
const discountedPrice = basePrice * (1 - discount / 100);
return {
basePrice,
discount,
discountedPrice,
savings: basePrice - discountedPrice
};
}
// =====================================
// FAQ Accordion (Optional Enhancement)
// =====================================
document.querySelectorAll('.faq-item').forEach(item => {
item.addEventListener('click', function() {
this.classList.toggle('active');
});
});
// =====================================
// Newsletter Subscription (Optional)
// =====================================
function subscribeNewsletter(email) {
// Integration mit Sendy.co
const sendyUrl = 'https://sendy.userman.de/subscribe';
const formData = new FormData();
formData.append('email', email);
formData.append('list', 'your-list-id');
formData.append('boolean', 'true');
return fetch(sendyUrl, {
method: 'POST',
body: formData
});
}
// =====================================
// Live Chat Widget Integration (Optional)
// =====================================
function initializeChatWidget() {
// Hier kann später der eigene BotKonzept-Chatbot integriert werden
console.log('Chat widget initialized');
}
// =====================================
// A/B Testing Helper (Optional)
// =====================================
function getABTestVariant() {
const variants = ['A', 'B'];
const stored = localStorage.getItem('ab_variant');
if (stored) {
return stored;
}
const variant = variants[Math.floor(Math.random() * variants.length)];
localStorage.setItem('ab_variant', variant);
return variant;
}
// =====================================
// Cookie Consent (DSGVO)
// =====================================
function showCookieConsent() {
const consent = localStorage.getItem('cookie_consent');
if (!consent) {
const banner = document.createElement('div');
banner.className = 'cookie-banner';
banner.innerHTML = `
<div class="cookie-content">
<p>Wir verwenden Cookies, um Ihre Erfahrung zu verbessern.
<a href="privacy.html">Mehr erfahren</a></p>
<button onclick="acceptCookies()" class="btn-primary">Akzeptieren</button>
</div>
`;
banner.style.cssText = `
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #1f2937;
color: white;
padding: 1.5rem;
z-index: 9999;
box-shadow: 0 -4px 6px rgba(0,0,0,0.1);
`;
document.body.appendChild(banner);
}
}
function acceptCookies() {
localStorage.setItem('cookie_consent', 'true');
document.querySelector('.cookie-banner').remove();
}
// Show cookie consent on page load
document.addEventListener('DOMContentLoaded', showCookieConsent);
// =====================================
// Performance Monitoring
// =====================================
if ('PerformanceObserver' in window) {
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
console.log('Performance:', entry.name, entry.duration);
}
});
observer.observe({ entryTypes: ['measure', 'navigation'] });
}
// =====================================
// Error Tracking
// =====================================
window.addEventListener('error', function(e) {
console.error('Global error:', e.error);
// Hier könnte Sentry oder ähnliches integriert werden
});
window.addEventListener('unhandledrejection', function(e) {
console.error('Unhandled promise rejection:', e.reason);
});
// =====================================
// Export for testing
// =====================================
if (typeof module !== 'undefined' && module.exports) {
module.exports = {
validateEmail,
calculatePricing,
getUrlParameter
};
}

View File

@@ -1,69 +0,0 @@
#!/bin/bash
# delete_stopped_lxc.sh - Löscht alle gestoppten LXC Container auf PVE
set -e
# Farben für Output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}=== Gestoppte LXC Container finden ===${NC}\n"
# Array für gestoppte Container
declare -a STOPPED_CTS
# Alle Container durchgehen und gestoppte finden
while read -r line; do
VMID=$(echo "$line" | awk '{print $1}')
STATUS=$(echo "$line" | awk '{print $2}')
NAME=$(echo "$line" | awk '{print $3}')
if [[ "$STATUS" == "stopped" ]]; then
STOPPED_CTS+=("$VMID:$NAME")
echo -e " ${RED}[STOPPED]${NC} CT $VMID - $NAME"
fi
done < <(pct list | tail -n +2)
# Prüfen ob gestoppte Container gefunden wurden
if [[ ${#STOPPED_CTS[@]} -eq 0 ]]; then
echo -e "\n${GREEN}Keine gestoppten Container gefunden.${NC}"
exit 0
fi
echo -e "\n${YELLOW}Gefunden: ${#STOPPED_CTS[@]} gestoppte Container${NC}\n"
# Bestätigung anfordern
read -p "Möchten Sie ALLE gestoppten Container unwiderruflich löschen? (ja/nein): " CONFIRM
if [[ "$CONFIRM" != "ja" ]]; then
echo -e "${GREEN}Abgebrochen. Keine Container wurden gelöscht.${NC}"
exit 0
fi
# Zweite Bestätigung
read -p "Sind Sie WIRKLICH sicher? Tippen Sie 'LÖSCHEN' ein: " CONFIRM2
if [[ "$CONFIRM2" != "LÖSCHEN" ]]; then
echo -e "${GREEN}Abgebrochen. Keine Container wurden gelöscht.${NC}"
exit 0
fi
echo -e "\n${RED}=== Lösche Container ===${NC}\n"
# Container löschen
for CT in "${STOPPED_CTS[@]}"; do
VMID="${CT%%:*}"
NAME="${CT##*:}"
echo -n "Lösche CT $VMID ($NAME)... "
if pct destroy "$VMID" --purge 2>/dev/null; then
echo -e "${GREEN}OK${NC}"
else
echo -e "${RED}FEHLER${NC}"
fi
done
echo -e "\n${GREEN}=== Fertig ===${NC}"

View File

@@ -1,419 +0,0 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# =============================================================================
# Flowise LXC Installer
# =============================================================================
# Erstellt einen LXC-Container mit Docker + Flowise + PostgreSQL
# =============================================================================
SCRIPT_VERSION="1.0.0"
# Debug mode: 0 = nur JSON, 1 = Logs auf stderr
DEBUG="${DEBUG:-0}"
export DEBUG
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Log-Verzeichnis
LOG_DIR="${SCRIPT_DIR}/logs"
mkdir -p "${LOG_DIR}"
# Temporäre Log-Datei (wird später umbenannt nach Container-Hostname)
TEMP_LOG="${LOG_DIR}/install_flowise_$$.log"
FINAL_LOG=""
# Funktion zum Aufräumen bei Exit
cleanup_log() {
# Wenn FINAL_LOG gesetzt ist, umbenennen
if [[ -n "${FINAL_LOG}" && -f "${TEMP_LOG}" ]]; then
mv "${TEMP_LOG}" "${FINAL_LOG}"
fi
}
trap cleanup_log EXIT
# Alle Ausgaben in Log-Datei umleiten
# Bei DEBUG=1: auch auf stderr ausgeben (tee)
# Bei DEBUG=0: nur in Datei
if [[ "$DEBUG" == "1" ]]; then
# Debug-Modus: Ausgabe auf stderr UND in Datei
exec > >(tee -a "${TEMP_LOG}") 2>&1
else
# Normal-Modus: Nur in Datei, stdout bleibt für JSON frei
exec 3>&1 # stdout (fd 3) für JSON reservieren
exec > "${TEMP_LOG}" 2>&1
fi
source "${SCRIPT_DIR}/libsupabase.sh"
setup_traps
usage() {
cat >&2 <<'EOF'
Usage:
bash install_flowise.sh [options]
Core options:
--ctid <id> Force CT ID (optional). If omitted, a customer-safe CTID is generated.
--cores <n> (default: 4)
--memory <mb> (default: 4096)
--swap <mb> (default: 512)
--disk <gb> (default: 50)
--bridge <vmbrX> (default: vmbr0)
--storage <storage> (default: local-zfs)
--ip <dhcp|CIDR> (default: dhcp)
--vlan <id> VLAN tag for net0 (default: 90; set 0 to disable)
--privileged Create privileged CT (default: unprivileged)
--apt-proxy <url> Optional: APT proxy (e.g. http://192.168.45.2:3142) for Apt-Cacher NG
Domain / Flowise options:
--base-domain <domain> (default: userman.de) -> FQDN becomes fw-<unix>.domain
--flowise-user <user> (default: admin)
--flowise-pass <pass> Optional. If omitted, generated (policy compliant).
--debug Enable debug mode (show logs on stderr)
--help Show help
Notes:
- This script creates a Debian 12 LXC and provisions Docker + Flowise stack (Postgres + Flowise).
- At the end it prints a JSON with credentials and URLs.
EOF
}
# Defaults
DOCKER_REGISTRY_MIRROR="http://192.168.45.2:5000"
APT_PROXY=""
CTID=""
CORES="4"
MEMORY="4096"
SWAP="512"
DISK="50"
BRIDGE="vmbr0"
STORAGE="local-zfs"
IPCFG="dhcp"
VLAN="90"
UNPRIV="1"
BASE_DOMAIN="userman.de"
FLOWISE_USER="admin"
FLOWISE_PASS=""
# ---------------------------
# Arg parsing
# ---------------------------
while [[ $# -gt 0 ]]; do
case "$1" in
--ctid) CTID="${2:-}"; shift 2 ;;
--apt-proxy) APT_PROXY="${2:-}"; shift 2 ;;
--cores) CORES="${2:-}"; shift 2 ;;
--memory) MEMORY="${2:-}"; shift 2 ;;
--swap) SWAP="${2:-}"; shift 2 ;;
--disk) DISK="${2:-}"; shift 2 ;;
--bridge) BRIDGE="${2:-}"; shift 2 ;;
--storage) STORAGE="${2:-}"; shift 2 ;;
--ip) IPCFG="${2:-}"; shift 2 ;;
--vlan) VLAN="${2:-}"; shift 2 ;;
--privileged) UNPRIV="0"; shift 1 ;;
--base-domain) BASE_DOMAIN="${2:-}"; shift 2 ;;
--flowise-user) FLOWISE_USER="${2:-}"; shift 2 ;;
--flowise-pass) FLOWISE_PASS="${2:-}"; shift 2 ;;
--debug) DEBUG="1"; export DEBUG; shift 1 ;;
--help|-h) usage; exit 0 ;;
*) die "Unknown option: $1 (use --help)" ;;
esac
done
# ---------------------------
# Validation
# ---------------------------
[[ "$CORES" =~ ^[0-9]+$ ]] || die "--cores must be integer"
[[ "$MEMORY" =~ ^[0-9]+$ ]] || die "--memory must be integer"
[[ "$SWAP" =~ ^[0-9]+$ ]] || die "--swap must be integer"
[[ "$DISK" =~ ^[0-9]+$ ]] || die "--disk must be integer"
[[ "$UNPRIV" == "0" || "$UNPRIV" == "1" ]] || die "internal: UNPRIV invalid"
[[ "$VLAN" =~ ^[0-9]+$ ]] || die "--vlan must be integer (0 disables tagging)"
[[ -n "$BASE_DOMAIN" ]] || die "--base-domain must not be empty"
if [[ "$IPCFG" != "dhcp" ]]; then
[[ "$IPCFG" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$ ]] || die "--ip must be dhcp or CIDR (e.g. 192.168.45.171/24)"
fi
if [[ -n "${APT_PROXY}" ]]; then
[[ "${APT_PROXY}" =~ ^http://[^/]+:[0-9]+$ ]] || die "--apt-proxy must look like http://IP:PORT (example: http://192.168.45.2:3142)"
fi
info "Script Version: ${SCRIPT_VERSION}"
info "Argument-Parsing OK"
if [[ -n "${APT_PROXY}" ]]; then
info "APT proxy enabled: ${APT_PROXY}"
else
info "APT proxy disabled"
fi
# ---------------------------
# Preflight Proxmox
# ---------------------------
need_cmd pct pvesm pveam pvesh grep date awk sed cut tr head
pve_storage_exists "$STORAGE" || die "Storage not found: $STORAGE"
pve_bridge_exists "$BRIDGE" || die "Bridge not found: $BRIDGE"
TEMPLATE="$(pve_template_ensure_debian12 "$STORAGE")"
info "Template OK: ${TEMPLATE}"
# Hostname / FQDN based on unix time (fw- prefix for Flowise)
UNIXTS="$(date +%s)"
CT_HOSTNAME="fw-${UNIXTS}"
FQDN="${CT_HOSTNAME}.${BASE_DOMAIN}"
# Log-Datei nach Container-Hostname benennen
FINAL_LOG="${LOG_DIR}/${CT_HOSTNAME}.log"
# CTID selection
if [[ -n "$CTID" ]]; then
[[ "$CTID" =~ ^[0-9]+$ ]] || die "--ctid must be integer"
if pve_vmid_exists_cluster "$CTID"; then
die "Forced CTID=${CTID} already exists in cluster"
fi
else
# unix time - 1000000000 (safe until 2038)
CTID="$(pve_ctid_from_unixtime "$UNIXTS")"
if pve_vmid_exists_cluster "$CTID"; then
die "Generated CTID=${CTID} already exists in cluster (unexpected). Try again in 1s."
fi
fi
# Flowise credentials defaults
if [[ -z "$FLOWISE_PASS" ]]; then
FLOWISE_PASS="$(gen_password_policy)"
else
password_policy_check "$FLOWISE_PASS" || die "--flowise-pass does not meet policy: 8+ chars, 1 number, 1 uppercase"
fi
info "CTID selected: ${CTID}"
info "SCRIPT_DIR=${SCRIPT_DIR}"
info "CT_HOSTNAME=${CT_HOSTNAME}"
info "FQDN=${FQDN}"
info "cores=${CORES} memory=${MEMORY}MB swap=${SWAP}MB disk=${DISK}GB"
info "bridge=${BRIDGE} storage=${STORAGE} ip=${IPCFG} vlan=${VLAN} unprivileged=${UNPRIV}"
# ---------------------------
# Step 1: Create CT
# ---------------------------
NET0="$(pve_build_net0 "$BRIDGE" "$IPCFG" "$VLAN")"
ROOTFS="${STORAGE}:${DISK}"
FEATURES="nesting=1,keyctl=1,fuse=1"
info "Step 1: Create CT"
info "Creating CT ${CTID} (${CT_HOSTNAME}) from ${TEMPLATE}"
pct create "${CTID}" "${TEMPLATE}" \
--hostname "${CT_HOSTNAME}" \
--cores "${CORES}" \
--memory "${MEMORY}" \
--swap "${SWAP}" \
--net0 "${NET0}" \
--rootfs "${ROOTFS}" \
--unprivileged "${UNPRIV}" \
--features "${FEATURES}" \
--start 0 \
--onboot yes
info "CT created (not started). Next step: start CT + wait for IP"
info "Starting CT ${CTID}"
pct start "${CTID}"
CT_IP="$(pct_wait_for_ip "${CTID}" || true)"
[[ -n "${CT_IP}" ]] || die "Could not determine CT IP after start"
info "Step 1 OK: LXC erstellt + IP ermittelt"
info "CT_HOSTNAME=${CT_HOSTNAME}"
info "CT_IP=${CT_IP}"
# ---------------------------
# Step 2: Provision inside CT (Docker + Locales + Base)
# ---------------------------
info "Step 2: Provisioning im CT (Docker + Locales + Base)"
# Optional: APT proxy (Apt-Cacher NG)
if [[ -n "${APT_PROXY}" ]]; then
pct_exec "${CTID}" "cat > /etc/apt/apt.conf.d/00aptproxy <<'EOF'
Acquire::http::Proxy \"${APT_PROXY}\";
Acquire::https::Proxy \"${APT_PROXY}\";
EOF"
pct_exec "$CTID" "apt-config dump | grep -i proxy || true"
fi
# Minimal base packages
pct_exec "${CTID}" "export DEBIAN_FRONTEND=noninteractive; apt-get update -y"
pct_exec "${CTID}" "export DEBIAN_FRONTEND=noninteractive; apt-get install -y ca-certificates curl gnupg lsb-release"
# Locales (avoid perl warnings + consistent system)
pct_exec "${CTID}" "export DEBIAN_FRONTEND=noninteractive; apt-get install -y locales"
pct_exec "${CTID}" "sed -i 's/^# *de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/; s/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen || true"
pct_exec "${CTID}" "locale-gen >/dev/null || true"
pct_exec "${CTID}" "update-locale LANG=de_DE.UTF-8 LC_ALL=de_DE.UTF-8 || true"
# Docker official repo (Debian 12 / bookworm)
pct_exec "${CTID}" "install -m 0755 -d /etc/apt/keyrings"
pct_exec "${CTID}" "curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg"
pct_exec "${CTID}" "chmod a+r /etc/apt/keyrings/docker.gpg"
pct_exec "${CTID}" "echo \"deb [arch=\$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \$(. /etc/os-release && echo \$VERSION_CODENAME) stable\" > /etc/apt/sources.list.d/docker.list"
pct_exec "${CTID}" "export DEBIAN_FRONTEND=noninteractive; apt-get update -y"
pct_exec "${CTID}" "export DEBIAN_FRONTEND=noninteractive; apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
# Create stack directories
pct_exec "${CTID}" "mkdir -p /opt/flowise-stack/volumes/postgres/data /opt/flowise-stack/volumes/flowise-data /opt/flowise-stack/sql"
info "Step 2 OK: Docker + Compose Plugin installiert, Locales gesetzt, Basis-Verzeichnisse erstellt"
# ---------------------------
# Step 3: Stack finalisieren + Secrets + Up + Checks
# ---------------------------
info "Step 3: Stack finalisieren + Secrets + Up + Checks"
# Secrets
PG_DB="flowise"
PG_USER="flowise"
PG_PASSWORD="$(gen_password_policy)"
FLOWISE_SECRETKEY="$(gen_hex_64)"
# Flowise configuration
FLOWISE_PORT="3000"
FLOWISE_HOST="${CT_IP}"
FLOWISE_EXTERNAL_URL="https://${FQDN}"
# Write .env into CT
pct_push_text "${CTID}" "/opt/flowise-stack/.env" "$(cat <<EOF
# PostgreSQL
PG_DB=${PG_DB}
PG_USER=${PG_USER}
PG_PASSWORD=${PG_PASSWORD}
# Flowise
FLOWISE_PORT=${FLOWISE_PORT}
FLOWISE_USERNAME=${FLOWISE_USER}
FLOWISE_PASSWORD=${FLOWISE_PASS}
FLOWISE_SECRETKEY_OVERWRITE=${FLOWISE_SECRETKEY}
# Database connection
DATABASE_TYPE=postgres
DATABASE_HOST=postgres
DATABASE_PORT=5432
DATABASE_NAME=${PG_DB}
DATABASE_USER=${PG_USER}
DATABASE_PASSWORD=${PG_PASSWORD}
# General
TZ=Europe/Berlin
EOF
)"
# init sql for pgvector (optional but useful for Flowise vector stores)
pct_push_text "${CTID}" "/opt/flowise-stack/sql/init_pgvector.sql" "$(cat <<'SQL'
CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS pg_trgm;
SQL
)"
# docker-compose.yml for Flowise
pct_push_text "${CTID}" "/opt/flowise-stack/docker-compose.yml" "$(cat <<'YML'
services:
postgres:
image: pgvector/pgvector:pg16
container_name: flowise-postgres
restart: unless-stopped
environment:
POSTGRES_DB: ${PG_DB}
POSTGRES_USER: ${PG_USER}
POSTGRES_PASSWORD: ${PG_PASSWORD}
volumes:
- ./volumes/postgres/data:/var/lib/postgresql/data
- ./sql:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${PG_USER} -d ${PG_DB} || exit 1"]
interval: 10s
timeout: 5s
retries: 20
networks:
- flowise-net
flowise:
image: flowiseai/flowise:latest
container_name: flowise
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
ports:
- "${FLOWISE_PORT}:3000"
environment:
# --- Authentication ---
FLOWISE_USERNAME: ${FLOWISE_USERNAME}
FLOWISE_PASSWORD: ${FLOWISE_PASSWORD}
FLOWISE_SECRETKEY_OVERWRITE: ${FLOWISE_SECRETKEY_OVERWRITE}
# --- Database ---
DATABASE_TYPE: ${DATABASE_TYPE}
DATABASE_HOST: ${DATABASE_HOST}
DATABASE_PORT: ${DATABASE_PORT}
DATABASE_NAME: ${DATABASE_NAME}
DATABASE_USER: ${DATABASE_USER}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
# --- General ---
TZ: ${TZ}
# --- Logging ---
LOG_LEVEL: info
DEBUG: "false"
volumes:
- ./volumes/flowise-data:/root/.flowise
networks:
- flowise-net
networks:
flowise-net:
driver: bridge
YML
)"
# Docker Registry Mirror (if APT proxy is set)
if [[ -n "${APT_PROXY}" ]]; then
pct_exec "$CTID" "mkdir -p /etc/docker"
pct_exec "$CTID" "cat > /etc/docker/daemon.json <<EOF
{
\"registry-mirrors\": [\"${DOCKER_REGISTRY_MIRROR}\"]
}
EOF"
pct_exec "$CTID" "systemctl restart docker"
pct_exec "$CTID" "systemctl is-active docker"
pct_exec "$CTID" "docker info | grep -A2 -i 'Registry Mirrors'"
fi
# Pull + up
pct_exec "${CTID}" "cd /opt/flowise-stack && docker compose pull"
pct_exec "${CTID}" "cd /opt/flowise-stack && docker compose up -d"
pct_exec "${CTID}" "cd /opt/flowise-stack && docker compose ps"
# Wait for Flowise to be ready
info "Waiting for Flowise to be ready..."
sleep 10
# Final info
FLOWISE_INTERNAL_URL="http://${CT_IP}:${FLOWISE_PORT}/"
FLOWISE_EXTERNAL_URL="https://${FQDN}"
info "Step 3 OK: Stack deployed"
info "Flowise intern: ${FLOWISE_INTERNAL_URL}"
info "Flowise extern (geplant via OPNsense): ${FLOWISE_EXTERNAL_URL}"
# Machine-readable JSON output
JSON_OUTPUT="{\"ctid\":${CTID},\"hostname\":\"${CT_HOSTNAME}\",\"fqdn\":\"${FQDN}\",\"ip\":\"${CT_IP}\",\"vlan\":${VLAN},\"urls\":{\"flowise_internal\":\"${FLOWISE_INTERNAL_URL}\",\"flowise_external\":\"${FLOWISE_EXTERNAL_URL}\"},\"postgres\":{\"host\":\"postgres\",\"port\":5432,\"db\":\"${PG_DB}\",\"user\":\"${PG_USER}\",\"password\":\"${PG_PASSWORD}\"},\"flowise\":{\"username\":\"${FLOWISE_USER}\",\"password\":\"${FLOWISE_PASS}\",\"secret_key\":\"${FLOWISE_SECRETKEY}\"},\"log_file\":\"${FINAL_LOG}\"}"
if [[ "$DEBUG" == "1" ]]; then
# Debug-Modus: JSON normal ausgeben (formatiert für Lesbarkeit)
echo "$JSON_OUTPUT" | python3 -m json.tool 2>/dev/null || echo "$JSON_OUTPUT"
else
# Normal-Modus: JSON auf ursprüngliches stdout (fd 3) - kompakt
echo "$JSON_OUTPUT" >&3
fi

View File

@@ -1,357 +0,0 @@
#!/bin/bash
#
# n8n Owner Account Setup Script
# Erstellt den Owner-Account bei einer neuen n8n-Instanz
# Oder prüft den Status einer bereits eingerichteten Instanz
# Ausgabe im JSON-Format
#
# NICHT set -e verwenden, da wir Fehler selbst behandeln
# Standardwerte
owner_first_name="Admin"
owner_last_name="User"
timeout=10
# JSON Steps Array
json_steps=()
# Funktion: Step zum JSON hinzufügen
add_step() {
local step_name="$1"
local step_status="$2"
local step_message="$3"
# Escape quotes in message
step_message=$(echo "$step_message" | sed 's/"/\\"/g')
json_steps+=("{\"step\":\"$step_name\",\"status\":\"$step_status\",\"message\":\"$step_message\"}")
}
# Funktion: JSON-Ausgabe generieren
output_json() {
local success="$1"
local message="$2"
local action="$3"
local login_status="$4"
local login_message="$5"
# Escape quotes
message=$(echo "$message" | sed 's/"/\\"/g')
login_message=$(echo "$login_message" | sed 's/"/\\"/g')
# Steps Array zusammenbauen
local steps_json=""
for i in "${!json_steps[@]}"; do
if [[ $i -gt 0 ]]; then
steps_json+=","
fi
steps_json+="${json_steps[$i]}"
done
# Zeitstempel
local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# JSON ausgeben
cat << JSONEOF
{
"success": $success,
"timestamp": "$timestamp",
"message": "$message",
"action": "$action",
"config": {
"n8n_url": "$n8n_internal",
"owner_email": "$owner_email",
"owner_first_name": "$owner_first_name",
"owner_last_name": "$owner_last_name"
},
"login_test": {
"status": "$login_status",
"message": "$login_message"
},
"steps": [$steps_json]
}
JSONEOF
}
# Funktion: Fehler-Exit mit JSON
exit_error() {
local message="$1"
local error="$2"
output_json "false" "$message" "error" "not_tested" "$error"
exit 1
}
# Funktion: Login testen
test_login() {
local url="$1"
local email="$2"
local password="$3"
# Login-Request durchführen
local login_response
login_response=$(curl -s -w "\n%{http_code}" --connect-timeout "$timeout" \
-X POST "${url}/rest/login" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "{\"email\":\"${email}\",\"password\":\"${password}\"}" 2>/dev/null)
local curl_exit=$?
if [[ $curl_exit -ne 0 ]]; then
echo "error|Verbindungsfehler beim Login-Test"
return 1
fi
local http_code=$(echo "$login_response" | tail -n1)
local body=$(echo "$login_response" | sed '$d')
if [[ "$http_code" == "200" ]]; then
if echo "$body" | grep -q '"id"'; then
echo "success|Login erfolgreich - Authentifizierung bestätigt"
return 0
else
echo "success|Login-Endpoint erreichbar (HTTP 200)"
return 0
fi
elif [[ "$http_code" == "401" ]]; then
echo "failed|Authentifizierung fehlgeschlagen - Falsche Zugangsdaten"
return 1
elif [[ "$http_code" == "400" ]]; then
echo "failed|Ungueltige Anfrage"
return 1
else
echo "error|Unerwarteter Status: HTTP $http_code"
return 1
fi
}
# Funktion: Port-Test
test_port() {
local host="$1"
local port="$2"
local timeout_sec="$3"
# Versuche verschiedene Methoden
if command -v nc &> /dev/null; then
nc -z -w "$timeout_sec" "$host" "$port" 2>/dev/null
return $?
elif command -v timeout &> /dev/null; then
timeout "$timeout_sec" bash -c "echo >/dev/tcp/$host/$port" 2>/dev/null
return $?
else
# Fallback: curl
curl -s --connect-timeout "$timeout_sec" "http://$host:$port" &>/dev/null
# Auch wenn curl fehlschlägt, war der Port erreichbar wenn kein Connection refused
return 0
fi
}
# Hilfe anzeigen
show_help() {
cat << EOF
Verwendung: $0 [OPTIONEN]
n8n Owner Account Setup Script (JSON-Ausgabe)
Optionen:
--n8n_internal <url> n8n URL (z.B. http://192.168.1.100:5678)
--owner_email <email> E-Mail-Adresse für den Owner-Account
--owner_password <pass> Passwort für den Owner-Account (min. 8 Zeichen)
--owner_first_name <name> Vorname des Owners (Standard: Admin)
--owner_last_name <name> Nachname des Owners (Standard: User)
--timeout <sekunden> Timeout für Requests (Standard: 10)
-h, --help Diese Hilfe anzeigen
EOF
exit 0
}
# ============================================
# Parameter parsen
# ============================================
while [[ $# -gt 0 ]]; do
case $1 in
--n8n_internal)
n8n_internal="$2"
shift 2
;;
--owner_email)
owner_email="$2"
shift 2
;;
--owner_password)
owner_password="$2"
shift 2
;;
--owner_first_name)
owner_first_name="$2"
shift 2
;;
--owner_last_name)
owner_last_name="$2"
shift 2
;;
--timeout)
timeout="$2"
shift 2
;;
-h|--help)
show_help
;;
*)
exit_error "Unbekannter Parameter" "$1"
;;
esac
done
# ============================================
# Pflichtparameter prüfen
# ============================================
if [[ -z "$n8n_internal" ]]; then
exit_error "Parameter fehlt" "--n8n_internal ist erforderlich"
fi
if [[ -z "$owner_email" ]]; then
exit_error "Parameter fehlt" "--owner_email ist erforderlich"
fi
if [[ -z "$owner_password" ]]; then
exit_error "Parameter fehlt" "--owner_password ist erforderlich"
fi
if [[ ${#owner_password} -lt 8 ]]; then
exit_error "Validierungsfehler" "Passwort muss mindestens 8 Zeichen lang sein"
fi
# URL normalisieren
n8n_internal="${n8n_internal%/}"
# ============================================
# Schritt 1: Server-Erreichbarkeit prüfen
# ============================================
# Host und Port extrahieren
host_port=$(echo "$n8n_internal" | sed -E 's|https?://||' | cut -d'/' -f1)
host=$(echo "$host_port" | cut -d':' -f1)
port=$(echo "$host_port" | grep -oE ':[0-9]+' | tr -d ':')
if [[ -z "$port" ]]; then
if [[ "$n8n_internal" == https://* ]]; then
port=443
else
port=80
fi
fi
# Ping-Test (optional, nicht kritisch)
if ping -c 1 -W 2 "$host" &> /dev/null; then
add_step "ping_test" "success" "Host $host antwortet auf Ping"
else
add_step "ping_test" "warning" "Host antwortet nicht auf Ping (ICMP blockiert)"
fi
# Port-Test
if test_port "$host" "$port" "$timeout"; then
add_step "port_test" "success" "Port $port ist offen"
else
add_step "port_test" "error" "Port $port ist nicht erreichbar"
exit_error "Server nicht erreichbar" "Port $port ist nicht erreichbar auf $host"
fi
# HTTP-Health-Check
http_status=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout "$timeout" "$n8n_internal/healthz" 2>/dev/null || echo "000")
if [[ "$http_status" == "200" ]]; then
add_step "health_check" "success" "n8n Health-Check erfolgreich (HTTP $http_status)"
elif [[ "$http_status" == "000" ]]; then
add_step "health_check" "error" "Keine HTTP-Verbindung moeglich"
exit_error "Health-Check fehlgeschlagen" "Keine HTTP-Verbindung moeglich"
else
add_step "health_check" "warning" "Health-Endpoint antwortet mit HTTP $http_status"
fi
# ============================================
# Schritt 2: Setup-Status prüfen
# ============================================
setup_check=$(curl -s --connect-timeout "$timeout" "$n8n_internal/rest/settings" 2>/dev/null || echo "")
setup_already_done=false
if echo "$setup_check" | grep -q '"showSetupOnFirstLoad":false'; then
setup_already_done=true
add_step "setup_check" "info" "Setup bereits abgeschlossen - Owner existiert"
else
add_step "setup_check" "success" "Setup ist verfuegbar"
fi
# ============================================
# Schritt 3: Owner erstellen ODER Login testen
# ============================================
if [[ "$setup_already_done" == "false" ]]; then
# Setup noch nicht durchgeführt -> Owner erstellen
response=$(curl -s -w "\n%{http_code}" --connect-timeout "$timeout" \
-X POST "${n8n_internal}/rest/owner/setup" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "{\"email\":\"${owner_email}\",\"password\":\"${owner_password}\",\"firstName\":\"${owner_first_name}\",\"lastName\":\"${owner_last_name}\"}" 2>/dev/null || echo -e "\n000")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
if [[ "$http_code" == "200" ]] || [[ "$http_code" == "201" ]]; then
add_step "create_owner" "success" "Owner-Account erfolgreich erstellt"
# Kurz warten
sleep 2
# Login testen nach Erstellung
login_result=$(test_login "$n8n_internal" "$owner_email" "$owner_password")
login_status=$(echo "$login_result" | cut -d'|' -f1)
login_message=$(echo "$login_result" | cut -d'|' -f2)
if [[ "$login_status" == "success" ]]; then
add_step "login_test" "success" "$login_message"
output_json "true" "Owner-Account erfolgreich erstellt und Login verifiziert" "created" "$login_status" "$login_message"
exit 0
else
add_step "login_test" "warning" "$login_message"
output_json "true" "Owner-Account erstellt, Login-Test fehlgeschlagen" "created" "$login_status" "$login_message"
exit 0
fi
else
add_step "create_owner" "error" "Fehler beim Erstellen (HTTP $http_code)"
exit_error "Account-Erstellung fehlgeschlagen" "HTTP Status: $http_code"
fi
else
# Setup bereits abgeschlossen -> Login testen
add_step "action" "info" "Teste Login mit vorhandenen Zugangsdaten"
# Login-Seite prüfen
main_page=$(curl -s -L --connect-timeout "$timeout" "$n8n_internal/" 2>/dev/null || echo "")
if echo "$main_page" | grep -qi "sign.in\|login\|anmelden\|n8n"; then
add_step "login_page" "success" "Login-Seite ist erreichbar"
else
add_step "login_page" "warning" "Login-Seite nicht eindeutig erkannt"
fi
# Login durchführen
login_result=$(test_login "$n8n_internal" "$owner_email" "$owner_password")
login_status=$(echo "$login_result" | cut -d'|' -f1)
login_message=$(echo "$login_result" | cut -d'|' -f2)
if [[ "$login_status" == "success" ]]; then
add_step "login_test" "success" "$login_message"
output_json "true" "n8n-Instanz ist eingerichtet und Login erfolgreich" "existing" "$login_status" "$login_message"
exit 0
else
add_step "login_test" "failed" "$login_message"
output_json "true" "n8n-Instanz ist eingerichtet, Login fehlgeschlagen" "existing" "$login_status" "$login_message"
exit 0
fi
fi

View File

@@ -1,144 +0,0 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# Save Credentials Script
# Extracts and saves credentials from installation JSON to a file
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
usage() {
cat >&2 <<'EOF'
Usage:
bash save_credentials.sh --json <json-string> [options]
bash save_credentials.sh --json-file <path> [options]
Required (one of):
--json <string> JSON string from installation output
--json-file <path> Path to file containing JSON
Options:
--output <path> Output file path (default: credentials/<hostname>.json)
--format Pretty-print JSON output
Examples:
# Save from JSON string
bash save_credentials.sh --json '{"ctid":123,...}'
# Save from file
bash save_credentials.sh --json-file /tmp/install_output.json
# Custom output location
bash save_credentials.sh --json-file output.json --output my-credentials.json
EOF
}
# Parse arguments
JSON_STRING=""
JSON_FILE=""
OUTPUT_FILE=""
FORMAT=0
while [[ $# -gt 0 ]]; do
case "$1" in
--json) JSON_STRING="${2:-}"; shift 2 ;;
--json-file) JSON_FILE="${2:-}"; shift 2 ;;
--output) OUTPUT_FILE="${2:-}"; shift 2 ;;
--format) FORMAT=1; shift 1 ;;
--help|-h) usage; exit 0 ;;
*) echo "Unknown option: $1 (use --help)" >&2; exit 1 ;;
esac
done
# Get JSON content
if [[ -n "$JSON_FILE" ]]; then
[[ -f "$JSON_FILE" ]] || { echo "File not found: $JSON_FILE" >&2; exit 1; }
JSON_STRING=$(cat "$JSON_FILE")
elif [[ -z "$JSON_STRING" ]]; then
echo "Error: Either --json or --json-file is required" >&2
usage
exit 1
fi
# Validate JSON
if ! echo "$JSON_STRING" | python3 -m json.tool >/dev/null 2>&1; then
echo "Error: Invalid JSON" >&2
exit 1
fi
# Extract hostname
HOSTNAME=$(echo "$JSON_STRING" | grep -oP '"hostname"\s*:\s*"\K[^"]+' || echo "")
[[ -n "$HOSTNAME" ]] || { echo "Error: Could not extract hostname from JSON" >&2; exit 1; }
# Set output file if not specified
if [[ -z "$OUTPUT_FILE" ]]; then
OUTPUT_FILE="${SCRIPT_DIR}/credentials/${HOSTNAME}.json"
fi
# Create credentials directory if needed
mkdir -p "$(dirname "$OUTPUT_FILE")"
# Create credentials JSON with updateable fields
cat > "$OUTPUT_FILE" <<EOF
{
"container": {
"ctid": $(echo "$JSON_STRING" | grep -oP '"ctid"\s*:\s*\K[0-9]+'),
"hostname": "$(echo "$JSON_STRING" | grep -oP '"hostname"\s*:\s*"\K[^"]+')",
"fqdn": "$(echo "$JSON_STRING" | grep -oP '"fqdn"\s*:\s*"\K[^"]+')",
"ip": "$(echo "$JSON_STRING" | grep -oP '"ip"\s*:\s*"\K[^"]+')",
"vlan": $(echo "$JSON_STRING" | grep -oP '"vlan"\s*:\s*\K[0-9]+')
},
"urls": {
"n8n_internal": "$(echo "$JSON_STRING" | grep -oP '"n8n_internal"\s*:\s*"\K[^"]+')",
"n8n_external": "$(echo "$JSON_STRING" | grep -oP '"n8n_external"\s*:\s*"\K[^"]+')",
"postgrest": "$(echo "$JSON_STRING" | grep -oP '"postgrest"\s*:\s*"\K[^"]+')",
"chat_webhook": "$(echo "$JSON_STRING" | grep -oP '"chat_webhook"\s*:\s*"\K[^"]+')",
"chat_internal": "$(echo "$JSON_STRING" | grep -oP '"chat_internal"\s*:\s*"\K[^"]+')",
"upload_form": "$(echo "$JSON_STRING" | grep -oP '"upload_form"\s*:\s*"\K[^"]+')",
"upload_form_internal": "$(echo "$JSON_STRING" | grep -oP '"upload_form_internal"\s*:\s*"\K[^"]+')"
},
"postgres": {
"host": "$(echo "$JSON_STRING" | grep -oP '"postgres"[^}]*"host"\s*:\s*"\K[^"]+')",
"port": $(echo "$JSON_STRING" | grep -oP '"postgres"[^}]*"port"\s*:\s*\K[0-9]+'),
"db": "$(echo "$JSON_STRING" | grep -oP '"postgres"[^}]*"db"\s*:\s*"\K[^"]+')",
"user": "$(echo "$JSON_STRING" | grep -oP '"postgres"[^}]*"user"\s*:\s*"\K[^"]+')",
"password": "$(echo "$JSON_STRING" | grep -oP '"postgres"[^}]*"password"\s*:\s*"\K[^"]+')"
},
"supabase": {
"url": "$(echo "$JSON_STRING" | grep -oP '"supabase"[^}]*"url"\s*:\s*"\K[^"]+' | head -1)",
"url_external": "$(echo "$JSON_STRING" | grep -oP '"url_external"\s*:\s*"\K[^"]+')",
"anon_key": "$(echo "$JSON_STRING" | grep -oP '"anon_key"\s*:\s*"\K[^"]+')",
"service_role_key": "$(echo "$JSON_STRING" | grep -oP '"service_role_key"\s*:\s*"\K[^"]+')",
"jwt_secret": "$(echo "$JSON_STRING" | grep -oP '"jwt_secret"\s*:\s*"\K[^"]+')"
},
"ollama": {
"url": "$(echo "$JSON_STRING" | grep -oP '"ollama"[^}]*"url"\s*:\s*"\K[^"]+')",
"model": "$(echo "$JSON_STRING" | grep -oP '"ollama"[^}]*"model"\s*:\s*"\K[^"]+')",
"embedding_model": "$(echo "$JSON_STRING" | grep -oP '"embedding_model"\s*:\s*"\K[^"]+')"
},
"n8n": {
"encryption_key": "$(echo "$JSON_STRING" | grep -oP '"n8n"[^}]*"encryption_key"\s*:\s*"\K[^"]+')",
"owner_email": "$(echo "$JSON_STRING" | grep -oP '"owner_email"\s*:\s*"\K[^"]+')",
"owner_password": "$(echo "$JSON_STRING" | grep -oP '"owner_password"\s*:\s*"\K[^"]+')",
"secure_cookie": $(echo "$JSON_STRING" | grep -oP '"secure_cookie"\s*:\s*\K(true|false)')
},
"log_file": "$(echo "$JSON_STRING" | grep -oP '"log_file"\s*:\s*"\K[^"]+')",
"created_at": "$(date -Iseconds)",
"updateable_fields": {
"ollama_url": "Can be updated to use hostname instead of IP",
"ollama_model": "Can be changed to different model",
"embedding_model": "Can be changed to different embedding model",
"postgres_password": "Can be updated (requires container restart)",
"n8n_owner_password": "Can be updated (requires container restart)"
}
}
EOF
# Format if requested
if [[ "$FORMAT" == "1" ]]; then
python3 -m json.tool "$OUTPUT_FILE" > "${OUTPUT_FILE}.tmp" && mv "${OUTPUT_FILE}.tmp" "$OUTPUT_FILE"
fi
echo "Credentials saved to: $OUTPUT_FILE"
echo ""
echo "To update credentials, use:"
echo " bash update_credentials.sh --ctid $(echo "$JSON_STRING" | grep -oP '"ctid"\s*:\s*\K[0-9]+') --credentials-file $OUTPUT_FILE"

View File

@@ -1,298 +0,0 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# =====================================================
# BotKonzept Setup Script
# =====================================================
# This script sets up the complete BotKonzept platform
# including database, n8n workflows, and website
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
SUPABASE_HOST="${SUPABASE_HOST:-192.168.45.3}"
SUPABASE_PORT="${SUPABASE_PORT:-5432}"
SUPABASE_DB="${SUPABASE_DB:-customer}"
SUPABASE_USER="${SUPABASE_USER:-customer}"
SUPABASE_PASSWORD="${SUPABASE_PASSWORD:-}"
N8N_HOST="${N8N_HOST:-n8n.userman.de}"
WEBSITE_DIR="${WEBSITE_DIR:-/var/www/botkonzept}"
print_header() {
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
}
print_success() {
echo -e "${GREEN}${NC} $1"
}
print_error() {
echo -e "${RED}${NC} $1"
}
print_info() {
echo -e "${BLUE}${NC} $1"
}
print_warning() {
echo -e "${YELLOW}${NC} $1"
}
# Check prerequisites
check_prerequisites() {
print_header "Checking Prerequisites"
local missing=0
# Check psql
if command -v psql >/dev/null 2>&1; then
print_success "PostgreSQL client installed"
else
print_error "PostgreSQL client not found"
missing=1
fi
# Check curl
if command -v curl >/dev/null 2>&1; then
print_success "curl installed"
else
print_error "curl not found"
missing=1
fi
# Check jq
if command -v jq >/dev/null 2>&1; then
print_success "jq installed"
else
print_warning "jq not found (optional, but recommended)"
fi
if [[ $missing -eq 1 ]]; then
print_error "Missing required dependencies. Please install them first."
exit 1
fi
echo ""
}
# Setup database
setup_database() {
print_header "Setting up Database"
if [[ -z "$SUPABASE_PASSWORD" ]]; then
print_error "SUPABASE_PASSWORD not set"
echo "Please set the password:"
echo " export SUPABASE_PASSWORD='your-password'"
exit 1
fi
print_info "Connecting to PostgreSQL at ${SUPABASE_HOST}:${SUPABASE_PORT}"
# Test connection
if PGPASSWORD="$SUPABASE_PASSWORD" psql -h "$SUPABASE_HOST" -p "$SUPABASE_PORT" -U "$SUPABASE_USER" -d "$SUPABASE_DB" -c "SELECT 1" >/dev/null 2>&1; then
print_success "Database connection successful"
else
print_error "Cannot connect to database"
exit 1
fi
# Create schema
print_info "Creating BotKonzept schema..."
if PGPASSWORD="$SUPABASE_PASSWORD" psql -h "$SUPABASE_HOST" -p "$SUPABASE_PORT" -U "$SUPABASE_USER" -d "$SUPABASE_DB" -f "${SCRIPT_DIR}/sql/botkonzept_schema.sql" >/dev/null 2>&1; then
print_success "Schema created successfully"
else
print_error "Failed to create schema"
exit 1
fi
# Verify tables
print_info "Verifying tables..."
local tables=$(PGPASSWORD="$SUPABASE_PASSWORD" psql -h "$SUPABASE_HOST" -p "$SUPABASE_PORT" -U "$SUPABASE_USER" -d "$SUPABASE_DB" -tAc "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='public' AND table_name IN ('customers', 'instances', 'subscriptions', 'payments', 'emails_sent')")
if [[ "$tables" -eq 5 ]]; then
print_success "All tables created successfully"
else
print_warning "Expected 5 tables, found $tables"
fi
echo ""
}
# Setup n8n workflows
setup_n8n_workflows() {
print_header "Setting up n8n Workflows"
print_info "n8n workflows need to be imported manually:"
echo ""
echo "1. Open n8n: https://${N8N_HOST}"
echo "2. Go to Workflows → Import from File"
echo "3. Import these files:"
echo " - ${SCRIPT_DIR}/BotKonzept-Customer-Registration-Workflow.json"
echo " - ${SCRIPT_DIR}/BotKonzept-Trial-Management-Workflow.json"
echo ""
echo "4. Configure credentials:"
echo " - SSH (PVE20): Private key for Proxmox"
echo " - PostgreSQL (Supabase): Host=${SUPABASE_HOST}, DB=${SUPABASE_DB}"
echo " - SMTP (Postfix/SES): Your email server"
echo ""
read -p "Press Enter when workflows are imported and configured..."
print_success "n8n workflows configured"
echo ""
}
# Setup website
setup_website() {
print_header "Setting up Website"
if [[ ! -d "${SCRIPT_DIR}/botkonzept-website" ]]; then
print_error "Website directory not found: ${SCRIPT_DIR}/botkonzept-website"
exit 1
fi
print_info "Website files location: ${SCRIPT_DIR}/botkonzept-website"
print_info "Target directory: ${WEBSITE_DIR}"
echo ""
# Update webhook URL in JavaScript
print_info "Updating webhook URL in JavaScript..."
local webhook_url="https://${N8N_HOST}/webhook/botkonzept-registration"
if [[ -f "${SCRIPT_DIR}/botkonzept-website/js/main.js" ]]; then
sed -i.bak "s|WEBHOOK_URL:.*|WEBHOOK_URL: '${webhook_url}',|" "${SCRIPT_DIR}/botkonzept-website/js/main.js"
print_success "Webhook URL updated to: ${webhook_url}"
fi
echo ""
print_info "To deploy the website, run:"
echo " sudo mkdir -p ${WEBSITE_DIR}"
echo " sudo cp -r ${SCRIPT_DIR}/botkonzept-website/* ${WEBSITE_DIR}/"
echo " sudo chown -R www-data:www-data ${WEBSITE_DIR}"
echo ""
read -p "Deploy website now? (y/N): " deploy
if [[ "$deploy" =~ ^[Yy]$ ]]; then
sudo mkdir -p "${WEBSITE_DIR}"
sudo cp -r "${SCRIPT_DIR}/botkonzept-website/"* "${WEBSITE_DIR}/"
sudo chown -R www-data:www-data "${WEBSITE_DIR}"
print_success "Website deployed to ${WEBSITE_DIR}"
else
print_info "Skipping website deployment"
fi
echo ""
}
# Test setup
test_setup() {
print_header "Testing Setup"
# Test database
print_info "Testing database connection..."
if PGPASSWORD="$SUPABASE_PASSWORD" psql -h "$SUPABASE_HOST" -p "$SUPABASE_PORT" -U "$SUPABASE_USER" -d "$SUPABASE_DB" -c "SELECT COUNT(*) FROM customers" >/dev/null 2>&1; then
print_success "Database accessible"
else
print_error "Database not accessible"
fi
# Test n8n webhook
print_info "Testing n8n webhook..."
local webhook_url="https://${N8N_HOST}/webhook/botkonzept-registration"
local response=$(curl -s -o /dev/null -w "%{http_code}" -X POST "$webhook_url" \
-H "Content-Type: application/json" \
-d '{"test": true}' 2>/dev/null || echo "000")
if [[ "$response" == "200" ]] || [[ "$response" == "400" ]]; then
print_success "n8n webhook accessible (HTTP $response)"
else
print_warning "n8n webhook returned HTTP $response"
fi
# Test website
if [[ -d "$WEBSITE_DIR" ]]; then
print_success "Website directory exists"
else
print_warning "Website not deployed yet"
fi
echo ""
}
# Generate summary
generate_summary() {
print_header "Setup Summary"
echo -e "${GREEN}✓ BotKonzept setup completed!${NC}"
echo ""
echo "Next steps:"
echo ""
echo "1. Configure DNS:"
echo " - Point botkonzept.de to your web server"
echo " - Configure SSL certificate (Let's Encrypt)"
echo ""
echo "2. Test registration:"
echo " - Visit https://botkonzept.de"
echo " - Fill out registration form"
echo " - Check email for welcome message"
echo ""
echo "3. Monitor workflows:"
echo " - n8n: https://${N8N_HOST}"
echo " - Check executions for errors"
echo ""
echo "4. Database access:"
echo " - Host: ${SUPABASE_HOST}"
echo " - Database: ${SUPABASE_DB}"
echo " - User: ${SUPABASE_USER}"
echo ""
echo "5. Useful queries:"
echo " - View customers: SELECT * FROM customer_overview;"
echo " - View trials: SELECT * FROM trials_expiring_soon;"
echo " - View emails: SELECT * FROM emails_sent ORDER BY sent_at DESC LIMIT 10;"
echo ""
echo "Documentation: ${SCRIPT_DIR}/BOTKONZEPT_README.md"
echo ""
}
# Main execution
main() {
clear
print_header "BotKonzept Setup"
echo "This script will set up the complete BotKonzept platform."
echo ""
echo "Components:"
echo " - PostgreSQL database schema"
echo " - n8n workflows (manual import)"
echo " - Website files"
echo ""
read -p "Continue? (y/N): " confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
echo "Setup cancelled."
exit 0
fi
echo ""
check_prerequisites
setup_database
setup_n8n_workflows
setup_website
test_setup
generate_summary
}
# Run main function
main "$@"

View File

@@ -1,269 +0,0 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# =============================================================================
# Flowise Account Setup Script
# =============================================================================
# Erstellt den Administrator-Account für eine neue Flowise-Instanz
# über die Flowise API (/api/v1/organization/setup)
# =============================================================================
SCRIPT_VERSION="1.0.1"
# Debug mode: 0 = nur JSON, 1 = Logs auf stderr
DEBUG="${DEBUG:-0}"
export DEBUG
# Logging functions
log_ts() { date "+[%F %T]"; }
info() { [[ "$DEBUG" == "1" ]] && echo "$(log_ts) INFO: $*" >&2; return 0; }
warn() { [[ "$DEBUG" == "1" ]] && echo "$(log_ts) WARN: $*" >&2; return 0; }
die() {
if [[ "$DEBUG" == "1" ]]; then
echo "$(log_ts) ERROR: $*" >&2
else
echo "{\"error\": \"$*\"}"
fi
exit 1
}
# =============================================================================
# Usage
# =============================================================================
usage() {
cat >&2 <<'EOF'
Usage:
bash setup_flowise_account.sh [options]
Required options:
--url <url> Flowise base URL (e.g., https://fw-1768829679.userman.de)
--name <name> Administrator display name
--email <email> Administrator email (used as login)
--password <password> Administrator password (8+ chars, upper, lower, digit, special)
Optional:
--basic-user <user> Basic Auth username (if Flowise has FLOWISE_USERNAME set)
--basic-pass <pass> Basic Auth password (if Flowise has FLOWISE_PASSWORD set)
--debug Enable debug mode (show logs on stderr)
--help Show this help
Password requirements:
- At least 8 characters
- At least one lowercase letter
- At least one uppercase letter
- At least one digit
- At least one special character
Examples:
# Setup account:
bash setup_flowise_account.sh \
--url https://fw-1768829679.userman.de \
--name "Admin User" \
--email admin@example.com \
--password "SecurePass1!"
# With debug output:
bash setup_flowise_account.sh --debug \
--url https://fw-1768829679.userman.de \
--name "Admin User" \
--email admin@example.com \
--password "SecurePass1!"
EOF
}
# =============================================================================
# Default values
# =============================================================================
FLOWISE_URL=""
ADMIN_NAME=""
ADMIN_EMAIL=""
ADMIN_PASSWORD=""
BASIC_USER=""
BASIC_PASS=""
# =============================================================================
# Argument parsing
# =============================================================================
while [[ $# -gt 0 ]]; do
case "$1" in
--url) FLOWISE_URL="${2:-}"; shift 2 ;;
--name) ADMIN_NAME="${2:-}"; shift 2 ;;
--email) ADMIN_EMAIL="${2:-}"; shift 2 ;;
--password) ADMIN_PASSWORD="${2:-}"; shift 2 ;;
--basic-user) BASIC_USER="${2:-}"; shift 2 ;;
--basic-pass) BASIC_PASS="${2:-}"; shift 2 ;;
--debug) DEBUG="1"; export DEBUG; shift 1 ;;
--help|-h) usage; exit 0 ;;
*) die "Unknown option: $1 (use --help)" ;;
esac
done
# =============================================================================
# Validation
# =============================================================================
[[ -n "$FLOWISE_URL" ]] || die "--url is required"
[[ -n "$ADMIN_NAME" ]] || die "--name is required"
[[ -n "$ADMIN_EMAIL" ]] || die "--email is required"
[[ -n "$ADMIN_PASSWORD" ]] || die "--password is required"
# Validate email format
[[ "$ADMIN_EMAIL" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ ]] || die "Invalid email format: $ADMIN_EMAIL"
# Validate password policy (Flowise requirements)
validate_password() {
local p="$1"
[[ ${#p} -ge 8 ]] || return 1
[[ "$p" =~ [a-z] ]] || return 1
[[ "$p" =~ [A-Z] ]] || return 1
[[ "$p" =~ [0-9] ]] || return 1
[[ "$p" =~ [^a-zA-Z0-9] ]] || return 1
return 0
}
validate_password "$ADMIN_PASSWORD" || die "Password does not meet requirements: 8+ chars, lowercase, uppercase, digit, special character"
# Remove trailing slash from URL
FLOWISE_URL="${FLOWISE_URL%/}"
info "Script Version: ${SCRIPT_VERSION}"
info "Configuration:"
info " URL: ${FLOWISE_URL}"
info " Name: ${ADMIN_NAME}"
info " Email: ${ADMIN_EMAIL}"
info " Password: ********"
if [[ -n "$BASIC_USER" ]]; then
info " Basic Auth: ${BASIC_USER}:********"
fi
# Build curl auth options
CURL_AUTH=""
if [[ -n "$BASIC_USER" && -n "$BASIC_PASS" ]]; then
CURL_AUTH="-u ${BASIC_USER}:${BASIC_PASS}"
fi
# =============================================================================
# Check if Flowise is reachable
# =============================================================================
info "Checking if Flowise is reachable..."
# Try to reach the organization-setup page
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -k ${CURL_AUTH} "${FLOWISE_URL}/organization-setup" 2>/dev/null || echo "000")
if [[ "$HTTP_CODE" == "000" ]]; then
die "Cannot connect to Flowise at ${FLOWISE_URL}"
elif [[ "$HTTP_CODE" == "404" ]]; then
warn "Organization setup page not found (404). Account may already exist."
fi
info "Flowise is reachable (HTTP ${HTTP_CODE})"
# =============================================================================
# Create Account via API
# =============================================================================
info "Creating administrator account..."
# Prepare JSON payload
# Note: Flowise expects specific field names
JSON_PAYLOAD=$(cat <<EOF
{
"name": "${ADMIN_NAME}",
"email": "${ADMIN_EMAIL}",
"password": "${ADMIN_PASSWORD}"
}
EOF
)
info "Sending request to ${FLOWISE_URL}/api/v1/organization/setup"
# Make API request
RESPONSE=$(curl -s -k ${CURL_AUTH} -X POST \
-H "Content-Type: application/json" \
-d "${JSON_PAYLOAD}" \
-w "\n%{http_code}" \
"${FLOWISE_URL}/api/v1/organization/setup" 2>&1)
# Extract HTTP code from last line
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
RESPONSE_BODY=$(echo "$RESPONSE" | sed '$d')
info "HTTP Response Code: ${HTTP_CODE}"
info "Response Body: ${RESPONSE_BODY}"
# =============================================================================
# Handle Response
# =============================================================================
if [[ "$HTTP_CODE" == "200" || "$HTTP_CODE" == "201" ]]; then
info "Account created successfully!"
# Output result as JSON
if [[ "$DEBUG" == "1" ]]; then
cat <<EOF
{
"success": true,
"url": "${FLOWISE_URL}",
"email": "${ADMIN_EMAIL}",
"name": "${ADMIN_NAME}",
"message": "Account created successfully"
}
EOF
else
echo "{\"success\":true,\"url\":\"${FLOWISE_URL}\",\"email\":\"${ADMIN_EMAIL}\",\"name\":\"${ADMIN_NAME}\",\"message\":\"Account created successfully\"}"
fi
elif [[ "$HTTP_CODE" == "400" ]]; then
# Check if account already exists
if echo "$RESPONSE_BODY" | grep -qi "already exists\|already setup\|already registered"; then
warn "Account may already exist"
if [[ "$DEBUG" == "1" ]]; then
cat <<EOF
{
"success": false,
"url": "${FLOWISE_URL}",
"email": "${ADMIN_EMAIL}",
"error": "Account already exists",
"response": ${RESPONSE_BODY}
}
EOF
else
echo "{\"success\":false,\"url\":\"${FLOWISE_URL}\",\"email\":\"${ADMIN_EMAIL}\",\"error\":\"Account already exists\"}"
fi
exit 1
else
die "Bad request (400): ${RESPONSE_BODY}"
fi
elif [[ "$HTTP_CODE" == "404" ]]; then
# Try alternative endpoints
info "Trying alternative endpoint /api/v1/signup..."
RESPONSE=$(curl -s -k ${CURL_AUTH} -X POST \
-H "Content-Type: application/json" \
-d "${JSON_PAYLOAD}" \
-w "\n%{http_code}" \
"${FLOWISE_URL}/api/v1/signup" 2>&1)
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
RESPONSE_BODY=$(echo "$RESPONSE" | sed '$d')
if [[ "$HTTP_CODE" == "200" || "$HTTP_CODE" == "201" ]]; then
info "Account created successfully via /api/v1/signup!"
if [[ "$DEBUG" == "1" ]]; then
cat <<EOF
{
"success": true,
"url": "${FLOWISE_URL}",
"email": "${ADMIN_EMAIL}",
"name": "${ADMIN_NAME}",
"message": "Account created successfully"
}
EOF
else
echo "{\"success\":true,\"url\":\"${FLOWISE_URL}\",\"email\":\"${ADMIN_EMAIL}\",\"name\":\"${ADMIN_NAME}\",\"message\":\"Account created successfully\"}"
fi
else
die "API endpoint not found. Tried /api/v1/organization/setup and /api/v1/signup. Response: ${RESPONSE_BODY}"
fi
else
die "Unexpected response (HTTP ${HTTP_CODE}): ${RESPONSE_BODY}"
fi

View File

@@ -1,14 +0,0 @@
CTID=768165834
ADMIN_EMAIL="metzw@metz.tech"
ADMIN_PASS="#Start!123"
pct exec "$CTID" -- bash -lc '
apt-get update -y >/dev/null
apt-get install -y curl >/dev/null
curl -sS -X POST "http://127.0.0.1:5678/rest/owner/setup" \
-H "Content-Type: application/json" \
-d "{\"email\":\"'"$ADMIN_EMAIL"'\",\"firstName\":\"Owner\",\"lastName\":\"Admin\",\"password\":\"'"$ADMIN_PASS"'\"}"
echo
'

View File

@@ -1,377 +0,0 @@
#!/bin/bash
#
# n8n Workflow Auto-Reload Script
# Wird beim LXC-Start ausgeführt, um den Workflow neu zu laden
#
set -euo pipefail
# Konfiguration
SCRIPT_DIR="/opt/customer-stack"
LOG_DIR="${SCRIPT_DIR}/logs"
LOG_FILE="${LOG_DIR}/workflow-reload.log"
ENV_FILE="${SCRIPT_DIR}/.env"
WORKFLOW_TEMPLATE="${SCRIPT_DIR}/workflow-template.json"
WORKFLOW_NAME="RAG KI-Bot (PGVector)"
# API-Konfiguration
API_URL="http://127.0.0.1:5678"
COOKIE_FILE="/tmp/n8n_reload_cookies.txt"
MAX_WAIT=60 # Maximale Wartezeit in Sekunden
# Logging-Funktion
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "${LOG_FILE}"
}
log_error() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $*" | tee -a "${LOG_FILE}" >&2
}
# Funktion: Warten bis n8n bereit ist
wait_for_n8n() {
log "Warte auf n8n API..."
local count=0
while [ $count -lt $MAX_WAIT ]; do
if curl -sS -o /dev/null -w "%{http_code}" "${API_URL}/rest/settings" 2>/dev/null | grep -q "200"; then
log "n8n API ist bereit"
return 0
fi
sleep 1
count=$((count + 1))
done
log_error "n8n API nicht erreichbar nach ${MAX_WAIT} Sekunden"
return 1
}
# Funktion: .env-Datei laden
load_env() {
if [ ! -f "${ENV_FILE}" ]; then
log_error ".env-Datei nicht gefunden: ${ENV_FILE}"
return 1
fi
# Exportiere alle Variablen aus .env
set -a
source "${ENV_FILE}"
set +a
log "Konfiguration geladen aus ${ENV_FILE}"
return 0
}
# Funktion: Login bei n8n
n8n_login() {
log "Login bei n8n als ${N8N_OWNER_EMAIL}..."
# Escape special characters in password for JSON
local escaped_password
escaped_password=$(echo "${N8N_OWNER_PASS}" | sed 's/\\/\\\\/g; s/"/\\"/g')
local response
response=$(curl -sS -X POST "${API_URL}/rest/login" \
-H "Content-Type: application/json" \
-c "${COOKIE_FILE}" \
-d "{\"emailOrLdapLoginId\":\"${N8N_OWNER_EMAIL}\",\"password\":\"${escaped_password}\"}" 2>&1)
if echo "$response" | grep -q '"code":\|"status":"error"'; then
log_error "Login fehlgeschlagen: ${response}"
return 1
fi
log "Login erfolgreich"
return 0
}
# Funktion: Workflow nach Name suchen
find_workflow() {
local workflow_name="$1"
log "Suche nach Workflow '${workflow_name}'..."
local response
response=$(curl -sS -X GET "${API_URL}/rest/workflows" \
-H "Content-Type: application/json" \
-b "${COOKIE_FILE}" 2>&1)
# Extract workflow ID by name
local workflow_id
workflow_id=$(echo "$response" | grep -oP "\"name\":\s*\"${workflow_name}\".*?\"id\":\s*\"\K[^\"]+|\"id\":\s*\"\K[^\"]+(?=.*?\"name\":\s*\"${workflow_name}\")" | head -1 || echo "")
if [ -n "$workflow_id" ]; then
log "Workflow gefunden: ID=${workflow_id}"
echo "$workflow_id"
return 0
else
log "Workflow '${workflow_name}' nicht gefunden"
echo ""
return 1
fi
}
# Funktion: Workflow löschen
delete_workflow() {
local workflow_id="$1"
log "Lösche Workflow ${workflow_id}..."
local response
response=$(curl -sS -X DELETE "${API_URL}/rest/workflows/${workflow_id}" \
-H "Content-Type: application/json" \
-b "${COOKIE_FILE}" 2>&1)
log "Workflow ${workflow_id} gelöscht"
return 0
}
# Funktion: Credential nach Name und Typ suchen
find_credential() {
local cred_name="$1"
local cred_type="$2"
log "Suche nach Credential '${cred_name}' (Typ: ${cred_type})..."
local response
response=$(curl -sS -X GET "${API_URL}/rest/credentials" \
-H "Content-Type: application/json" \
-b "${COOKIE_FILE}" 2>&1)
# Extract credential ID by name and type
local cred_id
cred_id=$(echo "$response" | grep -oP "\"name\":\s*\"${cred_name}\".*?\"type\":\s*\"${cred_type}\".*?\"id\":\s*\"\K[^\"]+|\"id\":\s*\"\K[^\"]+(?=.*?\"name\":\s*\"${cred_name}\".*?\"type\":\s*\"${cred_type}\")" | head -1 || echo "")
if [ -n "$cred_id" ]; then
log "Credential gefunden: ID=${cred_id}"
echo "$cred_id"
return 0
else
log_error "Credential '${cred_name}' nicht gefunden"
echo ""
return 1
fi
}
# Funktion: Workflow-Template verarbeiten
process_workflow_template() {
local pg_cred_id="$1"
local ollama_cred_id="$2"
local output_file="/tmp/workflow_processed.json"
log "Verarbeite Workflow-Template..."
# Python-Script zum Verarbeiten des Workflows
python3 - "$pg_cred_id" "$ollama_cred_id" <<'PYTHON_SCRIPT'
import json
import sys
# Read the workflow template
with open('/opt/customer-stack/workflow-template.json', 'r') as f:
workflow = json.load(f)
# Get credential IDs from arguments
pg_cred_id = sys.argv[1]
ollama_cred_id = sys.argv[2]
# Remove fields that should not be in the import
fields_to_remove = ['id', 'versionId', 'meta', 'tags', 'active', 'pinData']
for field in fields_to_remove:
workflow.pop(field, None)
# Process all nodes and replace credential IDs
for node in workflow.get('nodes', []):
credentials = node.get('credentials', {})
# Replace PostgreSQL credential
if 'postgres' in credentials:
credentials['postgres'] = {
'id': pg_cred_id,
'name': 'PostgreSQL (local)'
}
# Replace Ollama credential
if 'ollamaApi' in credentials:
credentials['ollamaApi'] = {
'id': ollama_cred_id,
'name': 'Ollama (local)'
}
# Write the processed workflow
with open('/tmp/workflow_processed.json', 'w') as f:
json.dump(workflow, f)
print("Workflow processed successfully")
PYTHON_SCRIPT
if [ $? -eq 0 ]; then
log "Workflow-Template erfolgreich verarbeitet"
echo "$output_file"
return 0
else
log_error "Fehler beim Verarbeiten des Workflow-Templates"
return 1
fi
}
# Funktion: Workflow importieren
import_workflow() {
local workflow_file="$1"
log "Importiere Workflow aus ${workflow_file}..."
local response
response=$(curl -sS -X POST "${API_URL}/rest/workflows" \
-H "Content-Type: application/json" \
-b "${COOKIE_FILE}" \
-d @"${workflow_file}" 2>&1)
# Extract workflow ID and version ID
local workflow_id
local version_id
workflow_id=$(echo "$response" | grep -oP '"id"\s*:\s*"\K[^"]+' | head -1)
version_id=$(echo "$response" | grep -oP '"versionId"\s*:\s*"\K[^"]+' | head -1)
if [ -z "$workflow_id" ]; then
log_error "Workflow-Import fehlgeschlagen: ${response}"
return 1
fi
log "Workflow importiert: ID=${workflow_id}, Version=${version_id}"
echo "${workflow_id}:${version_id}"
return 0
}
# Funktion: Workflow aktivieren
activate_workflow() {
local workflow_id="$1"
local version_id="$2"
log "Aktiviere Workflow ${workflow_id}..."
local response
response=$(curl -sS -X POST "${API_URL}/rest/workflows/${workflow_id}/activate" \
-H "Content-Type: application/json" \
-b "${COOKIE_FILE}" \
-d "{\"versionId\":\"${version_id}\"}" 2>&1)
if echo "$response" | grep -q '"active":true\|"active": true'; then
log "Workflow ${workflow_id} erfolgreich aktiviert"
return 0
else
log_error "Workflow-Aktivierung fehlgeschlagen: ${response}"
return 1
fi
}
# Funktion: Cleanup
cleanup() {
rm -f "${COOKIE_FILE}" /tmp/workflow_processed.json 2>/dev/null || true
}
# Hauptfunktion
main() {
log "========================================="
log "n8n Workflow Auto-Reload gestartet"
log "========================================="
# Erstelle Log-Verzeichnis falls nicht vorhanden
mkdir -p "${LOG_DIR}"
# Lade Konfiguration
if ! load_env; then
log_error "Fehler beim Laden der Konfiguration"
exit 1
fi
# Prüfe ob Workflow-Template existiert
if [ ! -f "${WORKFLOW_TEMPLATE}" ]; then
log_error "Workflow-Template nicht gefunden: ${WORKFLOW_TEMPLATE}"
exit 1
fi
# Warte auf n8n
if ! wait_for_n8n; then
log_error "n8n nicht erreichbar"
exit 1
fi
# Login
if ! n8n_login; then
log_error "Login fehlgeschlagen"
cleanup
exit 1
fi
# Suche nach bestehendem Workflow
local existing_workflow_id
existing_workflow_id=$(find_workflow "${WORKFLOW_NAME}" || echo "")
if [ -n "$existing_workflow_id" ]; then
log "Bestehender Workflow gefunden, wird gelöscht..."
delete_workflow "$existing_workflow_id"
fi
# Suche nach Credentials
log "Suche nach bestehenden Credentials..."
local pg_cred_id
local ollama_cred_id
pg_cred_id=$(find_credential "PostgreSQL (local)" "postgres" || echo "")
ollama_cred_id=$(find_credential "Ollama (local)" "ollamaApi" || echo "")
if [ -z "$pg_cred_id" ] || [ -z "$ollama_cred_id" ]; then
log_error "Credentials nicht gefunden (PostgreSQL: ${pg_cred_id}, Ollama: ${ollama_cred_id})"
cleanup
exit 1
fi
# Verarbeite Workflow-Template
local processed_workflow
processed_workflow=$(process_workflow_template "$pg_cred_id" "$ollama_cred_id")
if [ -z "$processed_workflow" ]; then
log_error "Fehler beim Verarbeiten des Workflow-Templates"
cleanup
exit 1
fi
# Importiere Workflow
local import_result
import_result=$(import_workflow "$processed_workflow")
if [ -z "$import_result" ]; then
log_error "Workflow-Import fehlgeschlagen"
cleanup
exit 1
fi
# Extrahiere IDs
local new_workflow_id
local new_version_id
new_workflow_id=$(echo "$import_result" | cut -d: -f1)
new_version_id=$(echo "$import_result" | cut -d: -f2)
# Aktiviere Workflow
if ! activate_workflow "$new_workflow_id" "$new_version_id"; then
log_error "Workflow-Aktivierung fehlgeschlagen"
cleanup
exit 1
fi
# Cleanup
cleanup
log "========================================="
log "Workflow-Reload erfolgreich abgeschlossen"
log "Workflow-ID: ${new_workflow_id}"
log "========================================="
exit 0
}
# Trap für Cleanup bei Fehler
trap cleanup EXIT
# Hauptfunktion ausführen
main "$@"

View File

@@ -1,276 +0,0 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# Complete System Integration Test
# Tests the entire RAG stack end-to-end
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
# Configuration from JSON output
CTID="${1:-769276659}"
CT_IP="${2:-192.168.45.45}"
CT_HOSTNAME="${3:-sb-1769276659}"
echo -e "${CYAN}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${CYAN}║ ║${NC}"
echo -e "${CYAN}║ Customer Installer - Complete System Test ║${NC}"
echo -e "${CYAN}║ ║${NC}"
echo -e "${CYAN}╚════════════════════════════════════════════════════════════╝${NC}"
echo ""
print_header() {
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} $1${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
}
print_test() { echo -e "${CYAN}[TEST]${NC} $1"; }
print_pass() { echo -e "${GREEN}[✓]${NC} $1"; }
print_fail() { echo -e "${RED}[✗]${NC} $1"; }
print_info() { echo -e "${BLUE}[]${NC} $1"; }
print_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
TOTAL_TESTS=0
PASSED_TESTS=0
FAILED_TESTS=0
run_test() {
((TOTAL_TESTS++))
if eval "$2"; then
print_pass "$1"
((PASSED_TESTS++))
return 0
else
print_fail "$1"
((FAILED_TESTS++))
return 1
fi
}
# ============================================================================
# SECTION 1: Container & Infrastructure
# ============================================================================
print_header "1. Container & Infrastructure"
run_test "Container is running" \
"pct status ${CTID} 2>/dev/null | grep -q 'running'"
run_test "Container has correct IP (${CT_IP})" \
"[[ \$(pct exec ${CTID} -- bash -lc \"ip -4 -o addr show scope global | awk '{print \\\$4}' | cut -d/ -f1 | head -n1\" 2>/dev/null) == '${CT_IP}' ]]"
run_test "Docker service is active" \
"pct exec ${CTID} -- bash -lc 'systemctl is-active docker' 2>/dev/null | grep -q 'active'"
run_test "Stack directory exists" \
"pct exec ${CTID} -- bash -lc 'test -d /opt/customer-stack' 2>/dev/null"
# ============================================================================
# SECTION 2: Docker Containers
# ============================================================================
print_header "2. Docker Containers Status"
run_test "PostgreSQL container is running" \
"pct exec ${CTID} -- bash -lc 'cd /opt/customer-stack && docker compose ps postgres --format \"{{.State}}\"' 2>/dev/null | grep -q 'running'"
run_test "PostgREST container is running" \
"pct exec ${CTID} -- bash -lc 'cd /opt/customer-stack && docker compose ps postgrest --format \"{{.State}}\"' 2>/dev/null | grep -q 'running'"
run_test "n8n container is running" \
"pct exec ${CTID} -- bash -lc 'cd /opt/customer-stack && docker compose ps n8n --format \"{{.State}}\"' 2>/dev/null | grep -q 'running'"
# ============================================================================
# SECTION 3: Database & Extensions
# ============================================================================
print_header "3. Database & Extensions"
run_test "PostgreSQL accepts connections" \
"pct exec ${CTID} -- bash -lc 'docker exec customer-postgres pg_isready -U customer -d customer' 2>/dev/null | grep -q 'accepting connections'"
run_test "pgvector extension is installed" \
"[[ \$(pct exec ${CTID} -- bash -lc \"docker exec customer-postgres psql -U customer -d customer -tAc \\\"SELECT extname FROM pg_extension WHERE extname='vector';\\\"\" 2>/dev/null) == 'vector' ]]"
run_test "pg_trgm extension is installed" \
"[[ \$(pct exec ${CTID} -- bash -lc \"docker exec customer-postgres psql -U customer -d customer -tAc \\\"SELECT extname FROM pg_extension WHERE extname='pg_trgm';\\\"\" 2>/dev/null) == 'pg_trgm' ]]"
run_test "Documents table exists" \
"[[ \$(pct exec ${CTID} -- bash -lc \"docker exec customer-postgres psql -U customer -d customer -tAc \\\"SELECT tablename FROM pg_tables WHERE schemaname='public' AND tablename='documents';\\\"\" 2>/dev/null) == 'documents' ]]"
run_test "match_documents function exists" \
"pct exec ${CTID} -- bash -lc \"docker exec customer-postgres psql -U customer -d customer -tAc \\\"SELECT proname FROM pg_proc WHERE proname='match_documents';\\\"\" 2>/dev/null | grep -q 'match_documents'"
run_test "Vector index exists on documents table" \
"pct exec ${CTID} -- bash -lc \"docker exec customer-postgres psql -U customer -d customer -tAc \\\"SELECT indexname FROM pg_indexes WHERE tablename='documents' AND indexname='documents_embedding_idx';\\\"\" 2>/dev/null | grep -q 'documents_embedding_idx'"
# ============================================================================
# SECTION 4: PostgREST API
# ============================================================================
print_header "4. PostgREST API"
run_test "PostgREST root endpoint (internal)" \
"[[ \$(pct exec ${CTID} -- bash -lc \"curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/\" 2>/dev/null) == '200' ]]"
run_test "PostgREST root endpoint (external)" \
"[[ \$(curl -s -o /dev/null -w '%{http_code}' http://${CT_IP}:3000/ 2>/dev/null) == '200' ]]"
run_test "Documents table accessible via API" \
"curl -s http://${CT_IP}:3000/documents 2>/dev/null | grep -q '\['"
run_test "PostgREST accessible from n8n container" \
"[[ \$(pct exec ${CTID} -- bash -lc \"docker exec n8n curl -s -o /dev/null -w '%{http_code}' http://postgrest:3000/\" 2>/dev/null) == '200' ]]"
# ============================================================================
# SECTION 5: n8n Service
# ============================================================================
print_header "5. n8n Service"
run_test "n8n web interface (internal)" \
"[[ \$(pct exec ${CTID} -- bash -lc \"curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:5678/\" 2>/dev/null) == '200' ]]"
run_test "n8n web interface (external)" \
"[[ \$(curl -s -o /dev/null -w '%{http_code}' http://${CT_IP}:5678/ 2>/dev/null) == '200' ]]"
run_test "n8n health endpoint" \
"pct exec ${CTID} -- bash -lc \"curl -s http://127.0.0.1:5678/healthz\" 2>/dev/null | grep -q 'ok'"
run_test "n8n uses PostgreSQL database" \
"[[ \$(pct exec ${CTID} -- bash -lc \"docker exec n8n printenv DB_TYPE\" 2>/dev/null) == 'postgresdb' ]]"
run_test "n8n encryption key is configured" \
"[[ \$(pct exec ${CTID} -- bash -lc \"docker exec n8n printenv N8N_ENCRYPTION_KEY | wc -c\" 2>/dev/null) -gt 10 ]]"
run_test "n8n can connect to PostgreSQL" \
"pct exec ${CTID} -- bash -lc \"docker exec n8n nc -zv postgres 5432 2>&1\" 2>/dev/null | grep -q 'succeeded\\|open'"
run_test "n8n can connect to PostgREST" \
"pct exec ${CTID} -- bash -lc \"docker exec n8n nc -zv postgrest 3000 2>&1\" 2>/dev/null | grep -q 'succeeded\\|open'"
# ============================================================================
# SECTION 6: Workflow Auto-Reload
# ============================================================================
print_header "6. Workflow Auto-Reload System"
run_test "Workflow reload service is enabled" \
"[[ \$(pct exec ${CTID} -- bash -lc \"systemctl is-enabled n8n-workflow-reload.service\" 2>/dev/null) == 'enabled' ]]"
run_test "Workflow template file exists" \
"pct exec ${CTID} -- bash -lc 'test -f /opt/customer-stack/workflow-template.json' 2>/dev/null"
run_test "Reload script exists and is executable" \
"pct exec ${CTID} -- bash -lc 'test -x /opt/customer-stack/reload-workflow.sh' 2>/dev/null"
# ============================================================================
# SECTION 7: Network & Connectivity
# ============================================================================
print_header "7. Network & Connectivity"
run_test "Docker network exists" \
"[[ \$(pct exec ${CTID} -- bash -lc \"docker network ls --format '{{.Name}}' | grep -c 'customer-stack_customer-net'\" 2>/dev/null) -gt 0 ]]"
run_test "Container can reach internet" \
"pct exec ${CTID} -- bash -lc 'ping -c 1 -W 2 8.8.8.8 >/dev/null 2>&1'"
run_test "Container can resolve DNS" \
"pct exec ${CTID} -- bash -lc 'ping -c 1 -W 2 google.com >/dev/null 2>&1'"
# ============================================================================
# SECTION 8: Permissions & Security
# ============================================================================
print_header "8. Permissions & Security"
run_test "n8n volume has correct ownership (uid 1000)" \
"[[ \$(pct exec ${CTID} -- bash -lc \"stat -c '%u' /opt/customer-stack/volumes/n8n-data\" 2>/dev/null) == '1000' ]]"
run_test "Environment file exists" \
"pct exec ${CTID} -- bash -lc 'test -f /opt/customer-stack/.env' 2>/dev/null"
run_test "Environment file has restricted permissions" \
"pct exec ${CTID} -- bash -lc 'test \$(stat -c %a /opt/customer-stack/.env) -le 644' 2>/dev/null"
# ============================================================================
# SECTION 9: External Dependencies
# ============================================================================
print_header "9. External Dependencies"
OLLAMA_STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://192.168.45.3:11434/api/tags 2>/dev/null || echo "000")
if [[ "$OLLAMA_STATUS" == "200" ]]; then
print_pass "Ollama API is accessible (HTTP ${OLLAMA_STATUS})"
((PASSED_TESTS++))
else
print_warn "Ollama API not accessible (HTTP ${OLLAMA_STATUS}) - External service"
fi
((TOTAL_TESTS++))
# ============================================================================
# SECTION 10: Log Files
# ============================================================================
print_header "10. Log Files & Documentation"
run_test "Installation log exists" \
"test -f logs/${CT_HOSTNAME}.log"
if [[ -f "logs/${CT_HOSTNAME}.log" ]]; then
LOG_SIZE=$(du -h "logs/${CT_HOSTNAME}.log" 2>/dev/null | cut -f1)
print_info "Log file size: ${LOG_SIZE}"
fi
# ============================================================================
# SUMMARY
# ============================================================================
echo ""
echo -e "${CYAN}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${CYAN}║ TEST SUMMARY ║${NC}"
echo -e "${CYAN}╚════════════════════════════════════════════════════════════╝${NC}"
echo ""
PASS_RATE=$((PASSED_TESTS * 100 / TOTAL_TESTS))
echo -e " Total Tests: ${TOTAL_TESTS}"
echo -e " ${GREEN}Passed: ${PASSED_TESTS}${NC}"
echo -e " ${RED}Failed: ${FAILED_TESTS}${NC}"
echo -e " Pass Rate: ${PASS_RATE}%"
echo ""
if [[ $FAILED_TESTS -eq 0 ]]; then
echo -e "${GREEN}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ ║${NC}"
echo -e "${GREEN}║ ✓ ALL TESTS PASSED SUCCESSFULLY! ║${NC}"
echo -e "${GREEN}║ ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${BLUE}System Information:${NC}"
echo -e " Container ID: ${CTID}"
echo -e " Hostname: ${CT_HOSTNAME}"
echo -e " IP Address: ${CT_IP}"
echo -e " VLAN: 90"
echo ""
echo -e "${BLUE}Access URLs:${NC}"
echo -e " n8n (internal): http://${CT_IP}:5678/"
echo -e " n8n (external): https://${CT_HOSTNAME}.userman.de"
echo -e " PostgREST API: http://${CT_IP}:3000/"
echo ""
echo -e "${BLUE}Next Steps:${NC}"
echo -e " 1. Configure NGINX reverse proxy on OPNsense"
echo -e " 2. Test RAG workflow with document upload"
echo -e " 3. Verify Ollama connectivity for AI features"
echo ""
exit 0
else
echo -e "${RED}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${RED}║ ║${NC}"
echo -e "${RED}║ ✗ SOME TESTS FAILED ║${NC}"
echo -e "${RED}║ ║${NC}"
echo -e "${RED}╚════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${YELLOW}Please review the failed tests above and check:${NC}"
echo -e " - Container logs: pct exec ${CTID} -- bash -lc 'cd /opt/customer-stack && docker compose logs'"
echo -e " - Installation log: cat logs/${CT_HOSTNAME}.log"
echo ""
exit 1
fi

View File

@@ -1,332 +0,0 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# Test script for customer-installer deployment
# This script verifies all components of the deployed LXC container
# Color codes for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Test results tracking
TESTS_PASSED=0
TESTS_FAILED=0
TESTS_TOTAL=0
# Parse JSON from installation output or use provided values
CTID="${1:-769276659}"
CT_IP="${2:-192.168.45.45}"
CT_HOSTNAME="${3:-sb-1769276659}"
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}Customer Installer - Test Suite${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
echo -e "Testing Container: ${GREEN}${CTID}${NC}"
echo -e "IP Address: ${GREEN}${CT_IP}${NC}"
echo -e "Hostname: ${GREEN}${CT_HOSTNAME}${NC}"
echo ""
# Helper functions
print_test() {
echo -e "${BLUE}[TEST]${NC} $1"
}
print_pass() {
echo -e "${GREEN}[PASS]${NC} $1"
((TESTS_PASSED++))
((TESTS_TOTAL++))
}
print_fail() {
echo -e "${RED}[FAIL]${NC} $1"
((TESTS_FAILED++))
((TESTS_TOTAL++))
}
print_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
# Test 1: Container exists and is running
print_test "Checking if container ${CTID} exists and is running..."
if pct status "${CTID}" 2>/dev/null | grep -q "running"; then
print_pass "Container ${CTID} is running"
else
print_fail "Container ${CTID} is not running"
exit 1
fi
# Test 2: Container has correct IP
print_test "Verifying container IP address..."
ACTUAL_IP=$(pct exec "${CTID}" -- bash -lc "ip -4 -o addr show scope global | awk '{print \$4}' | cut -d/ -f1 | head -n1" 2>/dev/null || echo "")
if [[ "${ACTUAL_IP}" == "${CT_IP}" ]]; then
print_pass "Container has correct IP: ${CT_IP}"
else
print_fail "Container IP mismatch. Expected: ${CT_IP}, Got: ${ACTUAL_IP}"
fi
# Test 3: Docker is installed and running
print_test "Checking Docker installation..."
if pct exec "${CTID}" -- bash -lc "systemctl is-active docker" 2>/dev/null | grep -q "active"; then
print_pass "Docker is installed and running"
else
print_fail "Docker is not running"
fi
# Test 4: Docker Compose is available
print_test "Checking Docker Compose plugin..."
if pct exec "${CTID}" -- bash -lc "docker compose version" >/dev/null 2>&1; then
COMPOSE_VERSION=$(pct exec "${CTID}" -- bash -lc "docker compose version" 2>/dev/null | head -1)
print_pass "Docker Compose is available: ${COMPOSE_VERSION}"
else
print_fail "Docker Compose plugin not found"
fi
# Test 5: Stack directory exists
print_test "Checking stack directory structure..."
if pct exec "${CTID}" -- bash -lc "test -d /opt/customer-stack" 2>/dev/null; then
print_pass "Stack directory exists: /opt/customer-stack"
else
print_fail "Stack directory not found"
fi
# Test 6: Docker containers are running
print_test "Checking Docker containers status..."
CONTAINERS=$(pct exec "${CTID}" -- bash -lc "cd /opt/customer-stack && docker compose ps --format json" 2>/dev/null || echo "[]")
# Check PostgreSQL
if echo "$CONTAINERS" | grep -q "customer-postgres"; then
PG_STATUS=$(pct exec "${CTID}" -- bash -lc "cd /opt/customer-stack && docker compose ps postgres --format '{{.State}}'" 2>/dev/null || echo "")
if [[ "$PG_STATUS" == "running" ]]; then
print_pass "PostgreSQL container is running"
else
print_fail "PostgreSQL container is not running (status: ${PG_STATUS})"
fi
else
print_fail "PostgreSQL container not found"
fi
# Check PostgREST
if echo "$CONTAINERS" | grep -q "customer-postgrest"; then
POSTGREST_STATUS=$(pct exec "${CTID}" -- bash -lc "cd /opt/customer-stack && docker compose ps postgrest --format '{{.State}}'" 2>/dev/null || echo "")
if [[ "$POSTGREST_STATUS" == "running" ]]; then
print_pass "PostgREST container is running"
else
print_fail "PostgREST container is not running (status: ${POSTGREST_STATUS})"
fi
else
print_fail "PostgREST container not found"
fi
# Check n8n
if echo "$CONTAINERS" | grep -q "n8n"; then
N8N_STATUS=$(pct exec "${CTID}" -- bash -lc "cd /opt/customer-stack && docker compose ps n8n --format '{{.State}}'" 2>/dev/null || echo "")
if [[ "$N8N_STATUS" == "running" ]]; then
print_pass "n8n container is running"
else
print_fail "n8n container is not running (status: ${N8N_STATUS})"
fi
else
print_fail "n8n container not found"
fi
# Test 7: PostgreSQL health check
print_test "Testing PostgreSQL database connectivity..."
PG_HEALTH=$(pct exec "${CTID}" -- bash -lc "docker exec customer-postgres pg_isready -U customer -d customer" 2>/dev/null || echo "failed")
if echo "$PG_HEALTH" | grep -q "accepting connections"; then
print_pass "PostgreSQL is accepting connections"
else
print_fail "PostgreSQL health check failed: ${PG_HEALTH}"
fi
# Test 8: pgvector extension
print_test "Checking pgvector extension..."
PGVECTOR_CHECK=$(pct exec "${CTID}" -- bash -lc "docker exec customer-postgres psql -U customer -d customer -tAc \"SELECT extname FROM pg_extension WHERE extname='vector';\"" 2>/dev/null || echo "")
if [[ "$PGVECTOR_CHECK" == "vector" ]]; then
print_pass "pgvector extension is installed"
else
print_fail "pgvector extension not found"
fi
# Test 9: Documents table exists
print_test "Checking documents table for vector storage..."
DOCS_TABLE=$(pct exec "${CTID}" -- bash -lc "docker exec customer-postgres psql -U customer -d customer -tAc \"SELECT tablename FROM pg_tables WHERE schemaname='public' AND tablename='documents';\"" 2>/dev/null || echo "")
if [[ "$DOCS_TABLE" == "documents" ]]; then
print_pass "Documents table exists"
else
print_fail "Documents table not found"
fi
# Test 10: PostgREST API accessibility
print_test "Testing PostgREST API endpoint..."
POSTGREST_RESPONSE=$(pct exec "${CTID}" -- bash -lc "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/" 2>/dev/null || echo "000")
if [[ "$POSTGREST_RESPONSE" == "200" ]]; then
print_pass "PostgREST API is accessible (HTTP ${POSTGREST_RESPONSE})"
else
print_fail "PostgREST API not accessible (HTTP ${POSTGREST_RESPONSE})"
fi
# Test 11: PostgREST external accessibility
print_test "Testing PostgREST external accessibility..."
POSTGREST_EXT=$(curl -s -o /dev/null -w '%{http_code}' "http://${CT_IP}:3000/" 2>/dev/null || echo "000")
if [[ "$POSTGREST_EXT" == "200" ]]; then
print_pass "PostgREST is externally accessible (HTTP ${POSTGREST_EXT})"
else
print_fail "PostgREST not externally accessible (HTTP ${POSTGREST_EXT})"
fi
# Test 12: n8n web interface
print_test "Testing n8n web interface..."
N8N_RESPONSE=$(pct exec "${CTID}" -- bash -lc "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:5678/" 2>/dev/null || echo "000")
if [[ "$N8N_RESPONSE" == "200" ]]; then
print_pass "n8n web interface is accessible (HTTP ${N8N_RESPONSE})"
else
print_fail "n8n web interface not accessible (HTTP ${N8N_RESPONSE})"
fi
# Test 13: n8n external accessibility
print_test "Testing n8n external accessibility..."
N8N_EXT=$(curl -s -o /dev/null -w '%{http_code}' "http://${CT_IP}:5678/" 2>/dev/null || echo "000")
if [[ "$N8N_EXT" == "200" ]]; then
print_pass "n8n is externally accessible (HTTP ${N8N_EXT})"
else
print_fail "n8n not externally accessible (HTTP ${N8N_EXT})"
fi
# Test 14: n8n API health
print_test "Testing n8n API health endpoint..."
N8N_HEALTH=$(pct exec "${CTID}" -- bash -lc "curl -s http://127.0.0.1:5678/healthz" 2>/dev/null || echo "")
if echo "$N8N_HEALTH" | grep -q "ok"; then
print_pass "n8n health check passed"
else
print_warn "n8n health endpoint returned: ${N8N_HEALTH}"
fi
# Test 15: Check n8n database connection
print_test "Checking n8n database configuration..."
N8N_DB_TYPE=$(pct exec "${CTID}" -- bash -lc "docker exec n8n printenv DB_TYPE" 2>/dev/null || echo "")
if [[ "$N8N_DB_TYPE" == "postgresdb" ]]; then
print_pass "n8n is configured to use PostgreSQL"
else
print_fail "n8n database type incorrect: ${N8N_DB_TYPE}"
fi
# Test 16: Workflow auto-reload service
print_test "Checking workflow auto-reload systemd service..."
RELOAD_SERVICE=$(pct exec "${CTID}" -- bash -lc "systemctl is-enabled n8n-workflow-reload.service" 2>/dev/null || echo "disabled")
if [[ "$RELOAD_SERVICE" == "enabled" ]]; then
print_pass "Workflow auto-reload service is enabled"
else
print_fail "Workflow auto-reload service not enabled: ${RELOAD_SERVICE}"
fi
# Test 17: Workflow template file exists
print_test "Checking workflow template file..."
if pct exec "${CTID}" -- bash -lc "test -f /opt/customer-stack/workflow-template.json" 2>/dev/null; then
print_pass "Workflow template file exists"
else
print_fail "Workflow template file not found"
fi
# Test 18: Reload script exists and is executable
print_test "Checking reload script..."
if pct exec "${CTID}" -- bash -lc "test -x /opt/customer-stack/reload-workflow.sh" 2>/dev/null; then
print_pass "Reload script exists and is executable"
else
print_fail "Reload script not found or not executable"
fi
# Test 19: Environment file exists
print_test "Checking environment configuration..."
if pct exec "${CTID}" -- bash -lc "test -f /opt/customer-stack/.env" 2>/dev/null; then
print_pass "Environment file exists"
else
print_fail "Environment file not found"
fi
# Test 20: Docker network exists
print_test "Checking Docker network..."
NETWORK_EXISTS=$(pct exec "${CTID}" -- bash -lc "docker network ls --format '{{.Name}}' | grep -c 'customer-stack_customer-net'" 2>/dev/null || echo "0")
if [[ "$NETWORK_EXISTS" -gt 0 ]]; then
print_pass "Docker network 'customer-stack_customer-net' exists"
else
print_fail "Docker network not found"
fi
# Test 21: Volume permissions (n8n runs as uid 1000)
print_test "Checking n8n volume permissions..."
N8N_VOLUME_OWNER=$(pct exec "${CTID}" -- bash -lc "stat -c '%u' /opt/customer-stack/volumes/n8n-data" 2>/dev/null || echo "")
if [[ "$N8N_VOLUME_OWNER" == "1000" ]]; then
print_pass "n8n volume has correct ownership (uid 1000)"
else
print_fail "n8n volume ownership incorrect: ${N8N_VOLUME_OWNER}"
fi
# Test 22: Check for running workflows
print_test "Checking n8n workflows..."
WORKFLOW_COUNT=$(pct exec "${CTID}" -- bash -lc "curl -s http://127.0.0.1:5678/rest/workflows 2>/dev/null | grep -o '\"id\"' | wc -l" 2>/dev/null || echo "0")
if [[ "$WORKFLOW_COUNT" -gt 0 ]]; then
print_pass "Found ${WORKFLOW_COUNT} workflow(s) in n8n"
else
print_warn "No workflows found in n8n (this may be expected if setup is still in progress)"
fi
# Test 23: Check Ollama connectivity (external service)
print_test "Testing Ollama API connectivity..."
OLLAMA_RESPONSE=$(curl -s -o /dev/null -w '%{http_code}' "http://192.168.45.3:11434/api/tags" 2>/dev/null || echo "000")
if [[ "$OLLAMA_RESPONSE" == "200" ]]; then
print_pass "Ollama API is accessible (HTTP ${OLLAMA_RESPONSE})"
else
print_warn "Ollama API not accessible (HTTP ${OLLAMA_RESPONSE}) - this is an external dependency"
fi
# Test 24: Container resource usage
print_test "Checking container resource usage..."
MEMORY_USAGE=$(pct exec "${CTID}" -- bash -lc "free -m | awk 'NR==2{printf \"%.0f\", \$3}'" 2>/dev/null || echo "0")
if [[ "$MEMORY_USAGE" -gt 0 ]]; then
print_pass "Container memory usage: ${MEMORY_USAGE}MB"
else
print_warn "Could not determine memory usage"
fi
# Test 25: Log file exists
print_test "Checking installation log file..."
if [[ -f "logs/${CT_HOSTNAME}.log" ]]; then
LOG_SIZE=$(du -h "logs/${CT_HOSTNAME}.log" | cut -f1)
print_pass "Installation log exists: logs/${CT_HOSTNAME}.log (${LOG_SIZE})"
else
print_fail "Installation log not found"
fi
# Summary
echo ""
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}Test Summary${NC}"
echo -e "${BLUE}========================================${NC}"
echo -e "Total Tests: ${TESTS_TOTAL}"
echo -e "${GREEN}Passed: ${TESTS_PASSED}${NC}"
echo -e "${RED}Failed: ${TESTS_FAILED}${NC}"
echo ""
if [[ $TESTS_FAILED -eq 0 ]]; then
echo -e "${GREEN}✓ All tests passed!${NC}"
echo ""
echo -e "${BLUE}Access Information:${NC}"
echo -e " n8n (internal): http://${CT_IP}:5678/"
echo -e " n8n (external): https://${CT_HOSTNAME}.userman.de"
echo -e " PostgREST API: http://${CT_IP}:3000/"
echo ""
exit 0
else
echo -e "${RED}✗ Some tests failed. Please review the output above.${NC}"
echo ""
exit 1
fi

View File

@@ -1,234 +0,0 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# Advanced n8n Workflow Testing Script
# Tests n8n API, credentials, workflows, and RAG functionality
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Configuration
CTID="${1:-769276659}"
CT_IP="${2:-192.168.45.45}"
N8N_EMAIL="${3:-admin@userman.de}"
N8N_PASSWORD="${4:-FAmeVE7t9d1iMIXWA1}" # From JSON output
TESTS_PASSED=0
TESTS_FAILED=0
print_test() { echo -e "${BLUE}[TEST]${NC} $1"; }
print_pass() { echo -e "${GREEN}[PASS]${NC} $1"; ((TESTS_PASSED++)); }
print_fail() { echo -e "${RED}[FAIL]${NC} $1"; ((TESTS_FAILED++)); }
print_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}n8n Workflow & API Test Suite${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# Test 1: n8n API Login
print_test "Testing n8n API login..."
LOGIN_RESPONSE=$(pct exec "${CTID}" -- bash -lc "curl -s -X POST 'http://127.0.0.1:5678/rest/login' \
-H 'Content-Type: application/json' \
-c /tmp/n8n_test_cookies.txt \
-d '{\"emailOrLdapLoginId\":\"${N8N_EMAIL}\",\"password\":\"${N8N_PASSWORD}\"}'" 2>/dev/null || echo '{"error":"failed"}')
if echo "$LOGIN_RESPONSE" | grep -q '"id"'; then
print_pass "Successfully logged into n8n API"
USER_ID=$(echo "$LOGIN_RESPONSE" | grep -oP '"id"\s*:\s*"\K[^"]+' | head -1)
print_info "User ID: ${USER_ID}"
else
print_fail "n8n API login failed: ${LOGIN_RESPONSE}"
fi
# Test 2: List credentials
print_test "Listing n8n credentials..."
CREDS_RESPONSE=$(pct exec "${CTID}" -- bash -lc "curl -s -X GET 'http://127.0.0.1:5678/rest/credentials' \
-H 'Content-Type: application/json' \
-b /tmp/n8n_test_cookies.txt" 2>/dev/null || echo '[]')
POSTGRES_CRED=$(echo "$CREDS_RESPONSE" | grep -oP '"type"\s*:\s*"postgres".*?"name"\s*:\s*"\K[^"]+' | head -1 || echo "")
OLLAMA_CRED=$(echo "$CREDS_RESPONSE" | grep -oP '"type"\s*:\s*"ollamaApi".*?"name"\s*:\s*"\K[^"]+' | head -1 || echo "")
if [[ -n "$POSTGRES_CRED" ]]; then
print_pass "PostgreSQL credential found: ${POSTGRES_CRED}"
else
print_fail "PostgreSQL credential not found"
fi
if [[ -n "$OLLAMA_CRED" ]]; then
print_pass "Ollama credential found: ${OLLAMA_CRED}"
else
print_fail "Ollama credential not found"
fi
# Test 3: List workflows
print_test "Listing n8n workflows..."
WORKFLOWS_RESPONSE=$(pct exec "${CTID}" -- bash -lc "curl -s -X GET 'http://127.0.0.1:5678/rest/workflows' \
-H 'Content-Type: application/json' \
-b /tmp/n8n_test_cookies.txt" 2>/dev/null || echo '{"data":[]}')
WORKFLOW_COUNT=$(echo "$WORKFLOWS_RESPONSE" | grep -o '"id"' | wc -l || echo "0")
if [[ "$WORKFLOW_COUNT" -gt 0 ]]; then
print_pass "Found ${WORKFLOW_COUNT} workflow(s)"
# Extract workflow details
WORKFLOW_NAMES=$(echo "$WORKFLOWS_RESPONSE" | grep -oP '"name"\s*:\s*"\K[^"]+' || echo "")
if [[ -n "$WORKFLOW_NAMES" ]]; then
print_info "Workflows:"
echo "$WORKFLOW_NAMES" | while read -r name; do
print_info " - ${name}"
done
fi
# Check for RAG workflow
if echo "$WORKFLOWS_RESPONSE" | grep -q "RAG KI-Bot"; then
print_pass "RAG KI-Bot workflow found"
# Check if workflow is active
RAG_ACTIVE=$(echo "$WORKFLOWS_RESPONSE" | grep -A 10 "RAG KI-Bot" | grep -oP '"active"\s*:\s*\K(true|false)' | head -1 || echo "false")
if [[ "$RAG_ACTIVE" == "true" ]]; then
print_pass "RAG workflow is active"
else
print_fail "RAG workflow is not active"
fi
else
print_fail "RAG KI-Bot workflow not found"
fi
else
print_fail "No workflows found in n8n"
fi
# Test 4: Check webhook endpoints
print_test "Checking webhook endpoints..."
WEBHOOK_RESPONSE=$(pct exec "${CTID}" -- bash -lc "curl -s -o /dev/null -w '%{http_code}' 'http://127.0.0.1:5678/webhook/rag-chat-webhook/chat'" 2>/dev/null || echo "000")
if [[ "$WEBHOOK_RESPONSE" == "200" ]] || [[ "$WEBHOOK_RESPONSE" == "404" ]]; then
# 404 is acceptable if workflow isn't triggered yet
print_pass "Chat webhook endpoint is accessible (HTTP ${WEBHOOK_RESPONSE})"
else
print_fail "Chat webhook endpoint not accessible (HTTP ${WEBHOOK_RESPONSE})"
fi
# Test 5: Test n8n settings endpoint
print_test "Checking n8n settings..."
SETTINGS_RESPONSE=$(pct exec "${CTID}" -- bash -lc "curl -s 'http://127.0.0.1:5678/rest/settings'" 2>/dev/null || echo '{}')
if echo "$SETTINGS_RESPONSE" | grep -q '"data"'; then
print_pass "n8n settings endpoint accessible"
# Check telemetry settings
DIAGNOSTICS=$(echo "$SETTINGS_RESPONSE" | grep -oP '"diagnosticsEnabled"\s*:\s*\K(true|false)' || echo "unknown")
if [[ "$DIAGNOSTICS" == "false" ]]; then
print_pass "Telemetry/diagnostics disabled as configured"
else
print_info "Diagnostics setting: ${DIAGNOSTICS}"
fi
else
print_fail "n8n settings endpoint not accessible"
fi
# Test 6: Check n8n execution history
print_test "Checking workflow execution history..."
EXECUTIONS_RESPONSE=$(pct exec "${CTID}" -- bash -lc "curl -s -X GET 'http://127.0.0.1:5678/rest/executions?limit=10' \
-H 'Content-Type: application/json' \
-b /tmp/n8n_test_cookies.txt" 2>/dev/null || echo '{"data":[]}')
EXECUTION_COUNT=$(echo "$EXECUTIONS_RESPONSE" | grep -o '"id"' | wc -l || echo "0")
print_info "Found ${EXECUTION_COUNT} workflow execution(s)"
# Test 7: Verify PostgreSQL connection from n8n
print_test "Testing PostgreSQL connectivity from n8n container..."
PG_TEST=$(pct exec "${CTID}" -- bash -lc "docker exec n8n nc -zv postgres 5432 2>&1" || echo "failed")
if echo "$PG_TEST" | grep -q "succeeded\|open"; then
print_pass "n8n can connect to PostgreSQL"
else
print_fail "n8n cannot connect to PostgreSQL: ${PG_TEST}"
fi
# Test 8: Verify PostgREST connection from n8n
print_test "Testing PostgREST connectivity from n8n container..."
POSTGREST_TEST=$(pct exec "${CTID}" -- bash -lc "docker exec n8n nc -zv postgrest 3000 2>&1" || echo "failed")
if echo "$POSTGREST_TEST" | grep -q "succeeded\|open"; then
print_pass "n8n can connect to PostgREST"
else
print_fail "n8n cannot connect to PostgREST: ${POSTGREST_TEST}"
fi
# Test 9: Check n8n environment variables
print_test "Verifying n8n environment configuration..."
N8N_ENCRYPTION=$(pct exec "${CTID}" -- bash -lc "docker exec n8n printenv N8N_ENCRYPTION_KEY | wc -c" 2>/dev/null || echo "0")
if [[ "$N8N_ENCRYPTION" -gt 10 ]]; then
print_pass "n8n encryption key is configured"
else
print_fail "n8n encryption key not properly configured"
fi
WEBHOOK_URL=$(pct exec "${CTID}" -- bash -lc "docker exec n8n printenv WEBHOOK_URL" 2>/dev/null || echo "")
if [[ -n "$WEBHOOK_URL" ]]; then
print_pass "Webhook URL configured: ${WEBHOOK_URL}"
else
print_fail "Webhook URL not configured"
fi
# Test 10: Test document upload form endpoint
print_test "Checking document upload form endpoint..."
FORM_RESPONSE=$(pct exec "${CTID}" -- bash -lc "curl -s -o /dev/null -w '%{http_code}' 'http://127.0.0.1:5678/form/rag-upload-form'" 2>/dev/null || echo "000")
if [[ "$FORM_RESPONSE" == "200" ]] || [[ "$FORM_RESPONSE" == "404" ]]; then
print_pass "Document upload form endpoint accessible (HTTP ${FORM_RESPONSE})"
else
print_fail "Document upload form endpoint not accessible (HTTP ${FORM_RESPONSE})"
fi
# Test 11: Check n8n logs for errors
print_test "Checking n8n container logs for errors..."
N8N_ERRORS=$(pct exec "${CTID}" -- bash -lc "docker logs n8n 2>&1 | grep -i 'error' | grep -v 'ErrorReporter' | tail -5" || echo "")
if [[ -z "$N8N_ERRORS" ]]; then
print_pass "No critical errors in n8n logs"
else
print_info "Recent log entries (may include non-critical errors):"
echo "$N8N_ERRORS" | while read -r line; do
print_info " ${line}"
done
fi
# Test 12: Verify n8n data persistence
print_test "Checking n8n data volume..."
N8N_DATA_SIZE=$(pct exec "${CTID}" -- bash -lc "du -sh /opt/customer-stack/volumes/n8n-data 2>/dev/null | cut -f1" || echo "0")
if [[ "$N8N_DATA_SIZE" != "0" ]]; then
print_pass "n8n data volume exists: ${N8N_DATA_SIZE}"
else
print_fail "n8n data volume issue"
fi
# Test 13: Check workflow reload service status
print_test "Checking workflow auto-reload service..."
RELOAD_STATUS=$(pct exec "${CTID}" -- bash -lc "systemctl status n8n-workflow-reload.service | grep -oP 'Active: \K[^(]+'" 2>/dev/null || echo "unknown")
print_info "Workflow reload service status: ${RELOAD_STATUS}"
# Cleanup
pct exec "${CTID}" -- bash -lc "rm -f /tmp/n8n_test_cookies.txt" 2>/dev/null || true
# Summary
echo ""
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}n8n Test Summary${NC}"
echo -e "${BLUE}========================================${NC}"
TOTAL=$((TESTS_PASSED + TESTS_FAILED))
echo -e "Total Tests: ${TOTAL}"
echo -e "${GREEN}Passed: ${TESTS_PASSED}${NC}"
echo -e "${RED}Failed: ${TESTS_FAILED}${NC}"
echo ""
if [[ $TESTS_FAILED -eq 0 ]]; then
echo -e "${GREEN}✓ All n8n tests passed!${NC}"
exit 0
else
echo -e "${YELLOW}⚠ Some tests failed. Review output above.${NC}"
exit 1
fi

View File

@@ -1,207 +0,0 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# PostgREST API Testing Script
# Tests the Supabase-compatible REST API for vector storage
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Configuration
CTID="${1:-769276659}"
CT_IP="${2:-192.168.45.45}"
JWT_SECRET="${3:-IM9/HRQR9mw63lU/1G7vXPMe7q0n3oLcr35dryv0ToU=}"
ANON_KEY="${4:-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzAwMDAwMDAwLCJleHAiOjIwMDAwMDAwMDB9.6eAdv5-GWC35tHju8V_7is02G3HaoQfVk2UCDC1Tf5o}"
SERVICE_KEY="${5:-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic2VydmljZV9yb2xlIiwiaXNzIjoic3VwYWJhc2UiLCJpYXQiOjE3MDAwMDAwMDAsImV4cCI6MjAwMDAwMDAwMH0.jBMTvYi7DxgwtxEmUzsDfKd66LJoFlmPAYiGCTXYKmc}"
TESTS_PASSED=0
TESTS_FAILED=0
print_test() { echo -e "${BLUE}[TEST]${NC} $1"; }
print_pass() { echo -e "${GREEN}[PASS]${NC} $1"; ((TESTS_PASSED++)); }
print_fail() { echo -e "${RED}[FAIL]${NC} $1"; ((TESTS_FAILED++)); }
print_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}PostgREST API Test Suite${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# Test 1: PostgREST root endpoint
print_test "Testing PostgREST root endpoint..."
ROOT_RESPONSE=$(curl -s -o /dev/null -w '%{http_code}' "http://${CT_IP}:3000/" 2>/dev/null || echo "000")
if [[ "$ROOT_RESPONSE" == "200" ]]; then
print_pass "PostgREST root endpoint accessible (HTTP ${ROOT_RESPONSE})"
else
print_fail "PostgREST root endpoint not accessible (HTTP ${ROOT_RESPONSE})"
fi
# Test 2: List tables via PostgREST
print_test "Listing available tables via PostgREST..."
TABLES_RESPONSE=$(curl -s "http://${CT_IP}:3000/" \
-H "apikey: ${ANON_KEY}" \
-H "Authorization: Bearer ${ANON_KEY}" 2>/dev/null || echo "")
if echo "$TABLES_RESPONSE" | grep -q "documents"; then
print_pass "Documents table is exposed via PostgREST"
else
print_fail "Documents table not found in PostgREST response"
fi
# Test 3: Query documents table (should be empty initially)
print_test "Querying documents table..."
DOCS_RESPONSE=$(curl -s "http://${CT_IP}:3000/documents?select=*" \
-H "apikey: ${ANON_KEY}" \
-H "Authorization: Bearer ${ANON_KEY}" \
-H "Content-Type: application/json" 2>/dev/null || echo "[]")
if [[ "$DOCS_RESPONSE" == "[]" ]] || echo "$DOCS_RESPONSE" | grep -q '\['; then
DOC_COUNT=$(echo "$DOCS_RESPONSE" | grep -o '"id"' | wc -l || echo "0")
print_pass "Documents table accessible (${DOC_COUNT} documents)"
else
print_fail "Failed to query documents table: ${DOCS_RESPONSE}"
fi
# Test 4: Test with service role key (higher privileges)
print_test "Testing with service role key..."
SERVICE_RESPONSE=$(curl -s "http://${CT_IP}:3000/documents?select=count" \
-H "apikey: ${SERVICE_KEY}" \
-H "Authorization: Bearer ${SERVICE_KEY}" \
-H "Content-Type: application/json" 2>/dev/null || echo "error")
if [[ "$SERVICE_RESPONSE" != "error" ]]; then
print_pass "Service role key authentication successful"
else
print_fail "Service role key authentication failed"
fi
# Test 5: Test CORS headers
print_test "Checking CORS headers..."
CORS_RESPONSE=$(curl -s -I "http://${CT_IP}:3000/documents" \
-H "Origin: http://example.com" \
-H "apikey: ${ANON_KEY}" 2>/dev/null || echo "")
if echo "$CORS_RESPONSE" | grep -qi "access-control-allow-origin"; then
print_pass "CORS headers present"
else
print_info "CORS headers not found (may be expected depending on configuration)"
fi
# Test 6: Test RPC function (match_documents)
print_test "Testing match_documents RPC function..."
RPC_RESPONSE=$(curl -s -X POST "http://${CT_IP}:3000/rpc/match_documents" \
-H "apikey: ${SERVICE_KEY}" \
-H "Authorization: Bearer ${SERVICE_KEY}" \
-H "Content-Type: application/json" \
-d '{"query_embedding":"[0.1,0.2,0.3]","match_count":5}' 2>/dev/null || echo "error")
# This will fail if no documents exist, but we're testing if the function is accessible
if echo "$RPC_RESPONSE" | grep -q "error\|code" && ! echo "$RPC_RESPONSE" | grep -q "PGRST"; then
print_info "match_documents function exists (no documents to match yet)"
elif [[ "$RPC_RESPONSE" == "[]" ]]; then
print_pass "match_documents function accessible (empty result)"
else
print_info "RPC response: ${RPC_RESPONSE:0:100}"
fi
# Test 7: Check PostgREST schema cache
print_test "Checking PostgREST schema introspection..."
SCHEMA_RESPONSE=$(curl -s "http://${CT_IP}:3000/" \
-H "apikey: ${ANON_KEY}" \
-H "Accept: application/openapi+json" 2>/dev/null || echo "{}")
if echo "$SCHEMA_RESPONSE" | grep -q "openapi\|swagger"; then
print_pass "PostgREST OpenAPI schema available"
else
print_info "OpenAPI schema not available (may require specific configuration)"
fi
# Test 8: Test PostgreSQL connection from PostgREST
print_test "Verifying PostgREST database connection..."
PG_CONN=$(pct exec "${CTID}" -- bash -lc "docker logs customer-postgrest 2>&1 | grep -i 'listening\|connection\|ready' | tail -3" || echo "")
if [[ -n "$PG_CONN" ]]; then
print_pass "PostgREST has database connection logs"
print_info "Recent logs: ${PG_CONN:0:100}"
else
print_info "No connection logs found (may be normal)"
fi
# Test 9: Test invalid authentication
print_test "Testing authentication rejection with invalid key..."
INVALID_RESPONSE=$(curl -s -o /dev/null -w '%{http_code}' "http://${CT_IP}:3000/documents" \
-H "apikey: invalid_key_12345" \
-H "Authorization: Bearer invalid_key_12345" 2>/dev/null || echo "000")
if [[ "$INVALID_RESPONSE" == "401" ]] || [[ "$INVALID_RESPONSE" == "403" ]]; then
print_pass "Invalid authentication properly rejected (HTTP ${INVALID_RESPONSE})"
else
print_info "Authentication response: HTTP ${INVALID_RESPONSE}"
fi
# Test 10: Check PostgREST container health
print_test "Checking PostgREST container health..."
POSTGREST_HEALTH=$(pct exec "${CTID}" -- bash -lc "docker inspect customer-postgrest --format='{{.State.Health.Status}}'" 2>/dev/null || echo "unknown")
if [[ "$POSTGREST_HEALTH" == "healthy" ]] || [[ "$POSTGREST_HEALTH" == "unknown" ]]; then
print_pass "PostgREST container is healthy"
else
print_fail "PostgREST container health: ${POSTGREST_HEALTH}"
fi
# Test 11: Test content negotiation
print_test "Testing content negotiation (JSON)..."
JSON_RESPONSE=$(curl -s "http://${CT_IP}:3000/documents?limit=1" \
-H "apikey: ${ANON_KEY}" \
-H "Accept: application/json" 2>/dev/null || echo "")
if echo "$JSON_RESPONSE" | grep -q '\[' || [[ "$JSON_RESPONSE" == "[]" ]]; then
print_pass "JSON content type supported"
else
print_fail "JSON content negotiation failed"
fi
# Test 12: Check PostgREST version
print_test "Checking PostgREST version..."
VERSION=$(pct exec "${CTID}" -- bash -lc "docker exec customer-postgrest postgrest --version 2>/dev/null" || echo "unknown")
if [[ "$VERSION" != "unknown" ]]; then
print_pass "PostgREST version: ${VERSION}"
else
print_info "Could not determine PostgREST version"
fi
# Test 13: Test from inside n8n container (internal network)
print_test "Testing PostgREST from n8n container (internal network)..."
INTERNAL_TEST=$(pct exec "${CTID}" -- bash -lc "docker exec n8n curl -s -o /dev/null -w '%{http_code}' 'http://postgrest:3000/'" 2>/dev/null || echo "000")
if [[ "$INTERNAL_TEST" == "200" ]]; then
print_pass "PostgREST accessible from n8n container (HTTP ${INTERNAL_TEST})"
else
print_fail "PostgREST not accessible from n8n container (HTTP ${INTERNAL_TEST})"
fi
# Summary
echo ""
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}PostgREST Test Summary${NC}"
echo -e "${BLUE}========================================${NC}"
TOTAL=$((TESTS_PASSED + TESTS_FAILED))
echo -e "Total Tests: ${TOTAL}"
echo -e "${GREEN}Passed: ${TESTS_PASSED}${NC}"
echo -e "${RED}Failed: ${TESTS_FAILED}${NC}"
echo ""
if [[ $TESTS_FAILED -eq 0 ]]; then
echo -e "${GREEN}✓ All PostgREST tests passed!${NC}"
echo ""
echo -e "${BLUE}API Endpoints:${NC}"
echo -e " Base URL: http://${CT_IP}:3000"
echo -e " Documents: http://${CT_IP}:3000/documents"
echo -e " RPC: http://${CT_IP}:3000/rpc/match_documents"
echo ""
exit 0
else
echo -e "${YELLOW}⚠ Some tests failed. Review output above.${NC}"
exit 1
fi

View File

@@ -1,164 +0,0 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# Credentials Update Script
# Updates credentials in an existing LXC container
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/libsupabase.sh"
usage() {
cat >&2 <<'EOF'
Usage:
bash update_credentials.sh --ctid <id> [options]
Required:
--ctid <id> Container ID
Credential Options:
--credentials-file <path> Path to credentials JSON file (default: credentials/<hostname>.json)
--ollama-url <url> Update Ollama URL (e.g., http://ollama.local:11434)
--ollama-model <model> Update Ollama chat model
--embedding-model <model> Update embedding model
--pg-password <pass> Update PostgreSQL password
--n8n-password <pass> Update n8n owner password
Examples:
# Update from credentials file
bash update_credentials.sh --ctid 769276659 --credentials-file credentials/sb-1769276659.json
# Update specific credentials
bash update_credentials.sh --ctid 769276659 --ollama-url http://ollama.local:11434
# Update multiple credentials
bash update_credentials.sh --ctid 769276659 \
--ollama-url http://ollama.local:11434 \
--ollama-model llama3.2:3b
EOF
}
# Parse arguments
CTID=""
CREDENTIALS_FILE=""
OLLAMA_URL=""
OLLAMA_MODEL=""
EMBEDDING_MODEL=""
PG_PASSWORD=""
N8N_PASSWORD=""
while [[ $# -gt 0 ]]; do
case "$1" in
--ctid) CTID="${2:-}"; shift 2 ;;
--credentials-file) CREDENTIALS_FILE="${2:-}"; shift 2 ;;
--ollama-url) OLLAMA_URL="${2:-}"; shift 2 ;;
--ollama-model) OLLAMA_MODEL="${2:-}"; shift 2 ;;
--embedding-model) EMBEDDING_MODEL="${2:-}"; shift 2 ;;
--pg-password) PG_PASSWORD="${2:-}"; shift 2 ;;
--n8n-password) N8N_PASSWORD="${2:-}"; shift 2 ;;
--help|-h) usage; exit 0 ;;
*) die "Unknown option: $1 (use --help)" ;;
esac
done
[[ -n "$CTID" ]] || die "Missing required parameter: --ctid"
# Check if container exists
pct status "$CTID" >/dev/null 2>&1 || die "Container $CTID not found"
info "Updating credentials for container $CTID"
# Get container hostname
CT_HOSTNAME=$(pct exec "$CTID" -- hostname 2>/dev/null || echo "")
[[ -n "$CT_HOSTNAME" ]] || die "Could not determine container hostname"
info "Container hostname: $CT_HOSTNAME"
# If credentials file specified, load it
if [[ -n "$CREDENTIALS_FILE" ]]; then
[[ -f "$CREDENTIALS_FILE" ]] || die "Credentials file not found: $CREDENTIALS_FILE"
info "Loading credentials from: $CREDENTIALS_FILE"
# Parse JSON file
OLLAMA_URL=$(grep -oP '"ollama_url"\s*:\s*"\K[^"]+' "$CREDENTIALS_FILE" 2>/dev/null || echo "$OLLAMA_URL")
OLLAMA_MODEL=$(grep -oP '"ollama_model"\s*:\s*"\K[^"]+' "$CREDENTIALS_FILE" 2>/dev/null || echo "$OLLAMA_MODEL")
EMBEDDING_MODEL=$(grep -oP '"embedding_model"\s*:\s*"\K[^"]+' "$CREDENTIALS_FILE" 2>/dev/null || echo "$EMBEDDING_MODEL")
fi
# Read current .env file from container
info "Reading current configuration..."
CURRENT_ENV=$(pct exec "$CTID" -- cat /opt/customer-stack/.env 2>/dev/null || echo "")
[[ -n "$CURRENT_ENV" ]] || die "Could not read .env file from container"
# Get n8n owner email
N8N_EMAIL=$(echo "$CURRENT_ENV" | grep -oP 'N8N_OWNER_EMAIL=\K.*' || echo "admin@userman.de")
# Update credentials in n8n
if [[ -n "$OLLAMA_URL" ]] || [[ -n "$OLLAMA_MODEL" ]] || [[ -n "$EMBEDDING_MODEL" ]]; then
info "Updating n8n credentials..."
# Get current values if not specified
[[ -z "$OLLAMA_URL" ]] && OLLAMA_URL=$(echo "$CURRENT_ENV" | grep -oP 'OLLAMA_URL=\K.*' || echo "http://192.168.45.3:11434")
[[ -z "$OLLAMA_MODEL" ]] && OLLAMA_MODEL="ministral-3:3b"
[[ -z "$EMBEDDING_MODEL" ]] && EMBEDDING_MODEL="nomic-embed-text:latest"
info "New Ollama URL: $OLLAMA_URL"
info "New Ollama Model: $OLLAMA_MODEL"
info "New Embedding Model: $EMBEDDING_MODEL"
# Login to n8n
N8N_PASS=$(echo "$CURRENT_ENV" | grep -oP 'N8N_OWNER_PASSWORD=\K.*' || echo "")
[[ -n "$N8N_PASS" ]] || die "Could not determine n8n password"
# Update Ollama credential via API
pct exec "$CTID" -- bash -c "
# Login
curl -sS -X POST 'http://127.0.0.1:5678/rest/login' \
-H 'Content-Type: application/json' \
-c /tmp/n8n_update_cookies.txt \
-d '{\"emailOrLdapLoginId\":\"${N8N_EMAIL}\",\"password\":\"${N8N_PASS}\"}' >/dev/null
# Get Ollama credential ID
CRED_ID=\$(curl -sS -X GET 'http://127.0.0.1:5678/rest/credentials' \
-H 'Content-Type: application/json' \
-b /tmp/n8n_update_cookies.txt | grep -oP '\"type\"\\s*:\\s*\"ollamaApi\".*?\"id\"\\s*:\\s*\"\\K[^\"]+' | head -1)
if [[ -n \"\$CRED_ID\" ]]; then
# Update credential
curl -sS -X PATCH \"http://127.0.0.1:5678/rest/credentials/\$CRED_ID\" \
-H 'Content-Type: application/json' \
-b /tmp/n8n_update_cookies.txt \
-d '{\"data\":{\"baseUrl\":\"${OLLAMA_URL}\"}}' >/dev/null
echo \"Ollama credential updated: \$CRED_ID\"
else
echo \"Ollama credential not found\"
fi
# Cleanup
rm -f /tmp/n8n_update_cookies.txt
" || warn "Failed to update Ollama credential in n8n"
info "Credentials updated in n8n"
fi
# Update .env file if needed
if [[ -n "$PG_PASSWORD" ]] || [[ -n "$N8N_PASSWORD" ]]; then
info "Updating .env file..."
# This would require restarting containers, so we'll just update the file
# and inform the user to restart
if [[ -n "$PG_PASSWORD" ]]; then
pct exec "$CTID" -- bash -c "sed -i 's/^PG_PASSWORD=.*/PG_PASSWORD=${PG_PASSWORD}/' /opt/customer-stack/.env"
info "PostgreSQL password updated in .env (restart required)"
fi
if [[ -n "$N8N_PASSWORD" ]]; then
pct exec "$CTID" -- bash -c "sed -i 's/^N8N_OWNER_PASSWORD=.*/N8N_OWNER_PASSWORD=${N8N_PASSWORD}/' /opt/customer-stack/.env"
info "n8n password updated in .env (restart required)"
fi
warn "Container restart required for password changes to take effect:"
warn " pct exec $CTID -- bash -c 'cd /opt/customer-stack && docker compose restart'"
fi
info "Credential update completed successfully"