2025-08-25 09:41:16 -06:00

95 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# SMS Campaign Manager - Quick Start Script
set -e
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${GREEN}🚀 SMS Campaign Manager${NC}"
echo "========================="
echo
# Check if running from project root
if [[ ! -f "PROJECT_STRUCTURE.md" ]]; then
echo -e "${RED}❌ Please run this script from the project root directory${NC}"
exit 1
fi
# Check environment file
if [[ ! -f ".env" ]]; then
echo -e "${YELLOW}⚠️ Creating .env from template...${NC}"
cp config/.env.example .env
echo -e "${BLUE}📝 Please edit .env with your settings before continuing${NC}"
exit 1
fi
# Check Docker
if ! command -v docker &> /dev/null; then
echo -e "${RED}❌ Docker not found. Please install Docker first.${NC}"
exit 1
fi
if ! command -v docker compose &> /dev/null; then
echo -e "${RED}❌ Docker Compose not found. Please install Docker Compose first.${NC}"
exit 1
fi
# Show current configuration
echo -e "${BLUE}📋 Current Configuration:${NC}"
echo " Phone IP: $(grep PHONE_IP .env | cut -d= -f2)"
echo " ADB Port: $(grep ADB_PORT .env | cut -d= -f2)"
echo " Termux Port: $(grep TERMUX_API_PORT .env | cut -d= -f2)"
echo
# Deployment options
case "${1:-help}" in
"start"|"up")
echo -e "${GREEN}🔧 Starting SMS Campaign Manager...${NC}"
docker compose up -d
echo -e "${GREEN}✅ Started! Access at: http://localhost:5000${NC}"
;;
"stop"|"down")
echo -e "${YELLOW}🛑 Stopping SMS Campaign Manager...${NC}"
docker compose down
;;
"logs")
docker compose logs -f
;;
"status")
docker compose ps
;;
"rebuild")
echo -e "${YELLOW}🔨 Rebuilding containers...${NC}"
docker compose down
docker compose build --no-cache
docker compose up -d
;;
"dev")
echo -e "${BLUE}👨‍💻 Starting in development mode...${NC}"
cd src
python app.py
;;
"test")
echo -e "${GREEN}🧪 Running tests...${NC}"
./tests/test-docker-setup.sh
;;
*)
echo -e "${BLUE}Usage: ./run.sh [command]${NC}"
echo
echo "Commands:"
echo " start - Start the application (Docker)"
echo " stop - Stop the application"
echo " logs - View application logs"
echo " status - Show container status"
echo " rebuild - Rebuild and restart containers"
echo " dev - Run in development mode"
echo " test - Run tests"
echo
echo -e "${GREEN}Quick start: ./run.sh start${NC}"
;;
esac