Files
Chatwoot/chatwoot_quick_install.sh
2026-02-04 01:42:45 -08:00

147 lines
4.4 KiB
Bash

#!/bin/bash
################################################################################
# Chatwoot Quick Installation Script
# Supports: Ubuntu 20.04, 22.04, 24.04 LTS
# Simple method using official Chatwoot installation script
# Usage: sudo bash chatwoot_quick_install.sh
################################################################################
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Error: This script must be run as root${NC}"
echo "Run: sudo bash chatwoot_quick_install.sh"
exit 1
fi
echo -e "${GREEN}╔════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Chatwoot Installation - Ubuntu 20.04+ ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════════╝${NC}"
echo ""
# Check Ubuntu version
if [ ! -f /etc/os-release ]; then
echo -e "${RED}Error: Cannot detect Ubuntu version${NC}"
exit 1
fi
. /etc/os-release
echo -e "${GREEN}[✓]${NC} Ubuntu $VERSION_ID detected"
# Validate Ubuntu version
case $VERSION_ID in
20.04|22.04|24.04)
echo -e "${GREEN}[✓]${NC} Supported Ubuntu version"
;;
*)
echo -e "${YELLOW}[!]${NC} Ubuntu $VERSION_ID is not officially supported"
echo " Supported versions: 20.04, 22.04, 24.04"
read -p "Continue anyway? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
;;
esac
echo ""
read -p "Install Postgres and Redis? (yes/no): " install_postgres_redis
install_postgres_redis=${install_postgres_redis:-yes}
echo ""
read -p "Configure domain and SSL? (yes/no): " configure_domain
configure_domain=${configure_domain:-no}
domain=""
email=""
if [ "$configure_domain" = "yes" ]; then
echo ""
echo "Make sure you have created an A record for your domain"
read -p "Enter your domain (e.g., chatwoot.example.com): " domain
read -p "Enter email for Let's Encrypt: " email
if [ -z "$domain" ] || [ -z "$email" ]; then
echo -e "${RED}Error: Domain and email are required for SSL${NC}"
configure_domain="no"
fi
fi
echo ""
echo -e "${YELLOW}Starting installation...${NC}"
echo ""
# Update system
echo -e "${GREEN}[1/6]${NC} Updating system..."
apt-get update -qq
apt-get upgrade -y -qq
# Download official Chatwoot installation script
echo -e "${GREEN}[2/6]${NC} Downloading Chatwoot installation script..."
cd /tmp
wget -q https://raw.githubusercontent.com/chatwoot/chatwoot/develop/deployment/setup_20.04.sh -O chatwoot_setup.sh
chmod +x chatwoot_setup.sh
# Run installation
echo -e "${GREEN}[3/6]${NC} Running Chatwoot installation..."
echo ""
# Prepare script arguments
install_args="--install"
if [ "$install_postgres_redis" != "yes" ]; then
install_args="$install_args --web-only"
fi
# Run the official script with automatic answers
bash ./chatwoot_setup.sh $install_args <<EOF
$install_postgres_redis
$configure_domain
$domain
$email
EOF
echo ""
echo -e "${GREEN}[4/6]${NC} Installation completed"
# Display access information
echo ""
echo -e "${GREEN}╔════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Installation Successful! ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════════╝${NC}"
echo ""
if [ "$configure_domain" = "yes" ]; then
echo "Access Chatwoot at:"
echo -e "${YELLOW} https://${domain}${NC}"
else
echo "Access Chatwoot at:"
echo -e "${YELLOW} http://$(hostname -I | awk '{print $1}'):3000${NC}"
fi
echo ""
echo "Next steps:"
echo "1. Open Chatwoot in your browser"
echo "2. Create your first admin account"
echo "3. Configure email and communication channels"
echo "4. Customize agent names and account details"
echo ""
echo "Useful commands:"
echo " View logs: journalctl -u chatwoot-web.1.service -f"
echo " Restart services: systemctl restart chatwoot-web.target"
echo " Check status: systemctl status chatwoot-web.target"
echo " Upgrade Chatwoot: cwctl --upgrade"
echo ""
echo -e "${GREEN}[✓]${NC} Installation log: /var/log/chatwoot-setup.log"
echo ""