Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
320 changes: 320 additions & 0 deletions deploy_chat_automation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
#!/bin/bash

##############################################################################
# Maxun Chat Automation Quick Deploy Script
##############################################################################
#
# This script helps you quickly deploy Maxun for chat automation use cases.
#
# Usage:
# ./deploy_chat_automation.sh
#
##############################################################################

set -e

# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

# Print banner
print_banner() {
echo -e "${BLUE}"
cat << "EOF"
╔═══════════════════════════════════════════════════════════╗
β•‘ β•‘
β•‘ __ __ β•‘
β•‘ | \/ | __ ___ ___ _ _ __ β•‘
β•‘ | |\/| |/ _` \ \/ / | | | '_ \ β•‘
β•‘ | | | | (_| |> <| |_| | | | | β•‘
β•‘ |_| |_|\__,_/_/\_\\__,_|_| |_| β•‘
β•‘ β•‘
β•‘ Chat Automation Quick Deploy β•‘
β•‘ β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
EOF
echo -e "${NC}"
}

# Check dependencies
check_dependencies() {
echo -e "${BLUE}Checking dependencies...${NC}"

if ! command -v docker &> /dev/null; then
echo -e "${RED}βœ— Docker is not installed${NC}"
echo "Please install Docker: https://docs.docker.com/get-docker/"
exit 1
fi
echo -e "${GREEN}βœ“ Docker found${NC}"

if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo -e "${RED}βœ— Docker Compose is not installed${NC}"
echo "Please install Docker Compose: https://docs.docker.com/compose/install/"
exit 1
fi
echo -e "${GREEN}βœ“ Docker Compose found${NC}"

if ! command -v openssl &> /dev/null; then
echo -e "${YELLOW}⚠ OpenSSL not found (optional but recommended)${NC}"
else
echo -e "${GREEN}βœ“ OpenSSL found${NC}"
fi

echo ""
}

# Generate secure random string
generate_secret() {
if command -v openssl &> /dev/null; then
openssl rand -hex 32
else
# Fallback if openssl not available
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1
fi
}

# Setup environment file
setup_env() {
echo -e "${BLUE}Setting up environment configuration...${NC}"

if [ -f .env ]; then
echo -e "${YELLOW}⚠ .env file already exists${NC}"
read -p "Overwrite? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "${YELLOW}Using existing .env file${NC}"
return
fi
fi

echo -e "${BLUE}Generating secure secrets...${NC}"

JWT_SECRET=$(generate_secret)
ENCRYPTION_KEY=$(generate_secret)
SESSION_SECRET=$(generate_secret)
MINIO_ACCESS=$(generate_secret | cut -c1-20)
MINIO_SECRET=$(generate_secret)

cat > .env << EOF
# Maxun Configuration - Auto-generated by deploy_chat_automation.sh
# Generated on: $(date)

# App Setup
NODE_ENV=production
JWT_SECRET=${JWT_SECRET}
ENCRYPTION_KEY=${ENCRYPTION_KEY}
SESSION_SECRET=${SESSION_SECRET}

# Database Configuration
DB_NAME=maxun
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=postgres
DB_PORT=5432

# MinIO Object Storage
MINIO_ENDPOINT=minio
MINIO_PORT=9000
MINIO_CONSOLE_PORT=9001
MINIO_ACCESS_KEY=${MINIO_ACCESS}
MINIO_SECRET_KEY=${MINIO_SECRET}

# Redis Configuration
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=

# Backend and Frontend URLs and Ports
BACKEND_PORT=8080
FRONTEND_PORT=5173
BACKEND_URL=http://localhost:8080
PUBLIC_URL=http://localhost:5173
VITE_BACKEND_URL=http://localhost:8080
VITE_PUBLIC_URL=http://localhost:5173

# Optional: Google OAuth (for Google Sheets integration)
# GOOGLE_CLIENT_ID=
# GOOGLE_CLIENT_SECRET=
# GOOGLE_REDIRECT_URI=

# Optional: Airtable OAuth
# AIRTABLE_CLIENT_ID=
# AIRTABLE_REDIRECT_URI=

# Telemetry (helps improve Maxun)
MAXUN_TELEMETRY=true
EOF

echo -e "${GREEN}βœ“ Environment file created${NC}"
echo -e "${YELLOW}Note: Review .env file to customize settings if needed${NC}"
echo ""
}

# Pull and start services
start_services() {
echo -e "${BLUE}Starting Maxun services...${NC}"

echo -e "${YELLOW}Pulling latest Docker images...${NC}"
docker-compose pull
Copy link

@cubic-dev-ai cubic-dev-ai bot Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script validates environments that only have the Docker Compose plugin, but later calls docker-compose pull, which will fail when the plugin is the only available option. Please use a command that works for both cases (e.g., detect once and set a variable) before invoking pull/up.

Prompt for AI agents
Address the following comment on deploy_chat_automation.sh at line 161:

<comment>The script validates environments that only have the Docker Compose plugin, but later calls `docker-compose pull`, which will fail when the plugin is the only available option. Please use a command that works for both cases (e.g., detect once and set a variable) before invoking pull/up.</comment>

<file context>
@@ -0,0 +1,320 @@
+    echo -e &quot;${BLUE}Starting Maxun services...${NC}&quot;
+    
+    echo -e &quot;${YELLOW}Pulling latest Docker images...${NC}&quot;
+    docker-compose pull
+    
+    echo -e &quot;${YELLOW}Starting containers...${NC}&quot;
</file context>
Fix with Cubic


echo -e "${YELLOW}Starting containers...${NC}"
docker-compose up -d

echo -e "${GREEN}βœ“ Services started${NC}"
echo ""
}

# Wait for services to be ready
wait_for_services() {
echo -e "${BLUE}Waiting for services to be ready...${NC}"

local max_attempts=30
local attempt=0

while [ $attempt -lt $max_attempts ]; do
if curl -sf http://localhost:8080/health > /dev/null 2>&1; then
Copy link

@cubic-dev-ai cubic-dev-ai bot Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait_for_services relies on curl, but the dependency check never verifies that curl exists. If curl is missing, the health probe fails and the script exits with a backend error. Please add a curl dependency check (or guard) before using it.

Prompt for AI agents
Address the following comment on deploy_chat_automation.sh at line 178:

<comment>`wait_for_services` relies on `curl`, but the dependency check never verifies that `curl` exists. If curl is missing, the health probe fails and the script exits with a backend error. Please add a curl dependency check (or guard) before using it.</comment>

<file context>
@@ -0,0 +1,320 @@
+    local attempt=0
+    
+    while [ $attempt -lt $max_attempts ]; do
+        if curl -sf http://localhost:8080/health &gt; /dev/null 2&gt;&amp;1; then
+            echo -e &quot;${GREEN}βœ“ Backend is ready${NC}&quot;
+            break
</file context>
Fix with Cubic

echo -e "${GREEN}βœ“ Backend is ready${NC}"
break
fi

echo -e "${YELLOW}Waiting for backend... (attempt $((attempt + 1))/${max_attempts})${NC}"
sleep 2
((attempt++))
done

if [ $attempt -eq $max_attempts ]; then
echo -e "${RED}βœ— Backend failed to start${NC}"
echo -e "${YELLOW}Check logs with: docker-compose logs backend${NC}"
return 1
fi

echo ""
}

# Print access information
print_access_info() {
echo -e "${GREEN}"
cat << "EOF"
╔═══════════════════════════════════════════════════════════╗
β•‘ Deployment Complete! β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
EOF
echo -e "${NC}"

echo -e "${BLUE}Access URLs:${NC}"
echo -e " β€’ Frontend: ${GREEN}http://localhost:5173${NC}"
echo -e " β€’ Backend API: ${GREEN}http://localhost:8080${NC}"
echo -e " β€’ MinIO Console: ${GREEN}http://localhost:9001${NC}"
echo ""

echo -e "${BLUE}Next Steps:${NC}"
echo -e " 1. Open ${GREEN}http://localhost:5173${NC} in your browser"
echo -e " 2. Create an account"
echo -e " 3. Generate an API key in Settings β†’ API Keys"
echo -e " 4. Create your first robot by recording a workflow"
echo -e " 5. Use the examples in ${GREEN}./examples/${NC} directory"
echo ""

echo -e "${BLUE}Quick Start Commands:${NC}"
echo -e " ${YELLOW}# View logs${NC}"
echo -e " docker-compose logs -f"
echo ""
echo -e " ${YELLOW}# Stop services${NC}"
echo -e " docker-compose down"
echo ""
echo -e " ${YELLOW}# Restart services${NC}"
echo -e " docker-compose restart"
echo ""
echo -e " ${YELLOW}# Run Python example${NC}"
echo -e " cd examples && python chat_automation_python.py"
echo ""
echo -e " ${YELLOW}# Run Node.js example${NC}"
echo -e " cd examples && node chat_automation_node.js"
echo ""

echo -e "${BLUE}Documentation:${NC}"
echo -e " β€’ Full Guide: ${GREEN}./docs/BROWSER_AUTOMATION_CHAT.md${NC}"
echo -e " β€’ Examples: ${GREEN}./examples/README.md${NC}"
echo -e " β€’ Official Docs: ${GREEN}https://docs.maxun.dev${NC}"
echo ""

echo -e "${BLUE}Support:${NC}"
echo -e " β€’ Discord: ${GREEN}https://discord.gg/5GbPjBUkws${NC}"
echo -e " β€’ GitHub: ${GREEN}https://github.com/getmaxun/maxun${NC}"
echo ""
}

# Setup example environment
setup_examples() {
echo -e "${BLUE}Setting up examples...${NC}"

if [ ! -d examples ]; then
echo -e "${YELLOW}Examples directory not found${NC}"
return
fi

cd examples

if [ ! -f .env ]; then
cat > .env << 'EOF'
# Maxun API Configuration
MAXUN_API_URL=http://localhost:8080/api
MAXUN_API_KEY=
MAXUN_ROBOT_ID=

# Chat Interface Credentials
CHAT_USERNAME=
CHAT_PASSWORD=
EOF
echo -e "${GREEN}βœ“ Created examples/.env template${NC}"
echo -e "${YELLOW} Please edit examples/.env with your credentials${NC}"
else
echo -e "${YELLOW}examples/.env already exists${NC}"
fi

# Make bash script executable
if [ -f chat_automation_bash.sh ]; then
chmod +x chat_automation_bash.sh
echo -e "${GREEN}βœ“ Made bash script executable${NC}"
fi

cd ..
echo ""
}

# Main deployment function
main() {
print_banner

echo -e "${BLUE}This script will:${NC}"
echo " 1. Check for Docker and Docker Compose"
echo " 2. Generate secure configuration"
echo " 3. Start Maxun services"
echo " 4. Set up example scripts"
echo ""

read -p "Continue? (Y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo -e "${YELLOW}Deployment cancelled${NC}"
exit 0
fi

check_dependencies
setup_env
start_services
wait_for_services || exit 1
setup_examples
print_access_info

echo -e "${GREEN}╔═══════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}β•‘ Happy Automating with Maxun! πŸš€ β•‘${NC}"
echo -e "${GREEN}β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•${NC}"
}

# Run main function
main "$@"

Loading