82 lines
2.3 KiB
Bash
Executable File
82 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Telegram Tinder Bot Setup Script
|
|
|
|
echo "🚀 Setting up Telegram Tinder Bot..."
|
|
|
|
# Check if Node.js is installed
|
|
if ! command -v node &> /dev/null; then
|
|
echo "❌ Node.js is not installed. Please install Node.js 16 or higher."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if PostgreSQL is installed
|
|
if ! command -v psql &> /dev/null; then
|
|
echo "⚠️ PostgreSQL is not installed. You can install it or use Docker."
|
|
read -p "Do you want to use Docker for PostgreSQL? (y/n): " use_docker
|
|
if [[ $use_docker =~ ^[Yy]$ ]]; then
|
|
echo "📦 Using Docker for PostgreSQL..."
|
|
DOCKER_MODE=true
|
|
else
|
|
echo "❌ Please install PostgreSQL manually."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Install dependencies
|
|
echo "📦 Installing dependencies..."
|
|
npm install
|
|
|
|
# Check if .env file exists
|
|
if [ ! -f .env ]; then
|
|
echo "📄 Creating .env file from template..."
|
|
cp .env.example .env
|
|
echo "✅ .env file created. Please edit it with your configuration."
|
|
else
|
|
echo "✅ .env file already exists."
|
|
fi
|
|
|
|
# Build the project
|
|
echo "🔨 Building the project..."
|
|
npm run build
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ Project built successfully!"
|
|
else
|
|
echo "❌ Build failed. Please check the errors above."
|
|
exit 1
|
|
fi
|
|
|
|
# Create necessary directories
|
|
echo "📁 Creating directories..."
|
|
mkdir -p logs uploads
|
|
|
|
if [ "$DOCKER_MODE" = true ]; then
|
|
echo "🐳 Starting database with Docker..."
|
|
docker-compose up -d db
|
|
echo "⏳ Waiting for database to be ready..."
|
|
sleep 10
|
|
|
|
echo "🗄️ Initializing database..."
|
|
docker-compose exec db psql -U postgres -d telegram_tinder_bot -f /docker-entrypoint-initdb.d/init.sql
|
|
else
|
|
echo "🗄️ Setting up database..."
|
|
echo "Please run the following commands to set up your database:"
|
|
echo "1. Create database: createdb telegram_tinder_bot"
|
|
echo "2. Run migrations: psql -d telegram_tinder_bot -f src/database/migrations/init.sql"
|
|
fi
|
|
|
|
echo ""
|
|
echo "🎉 Setup completed!"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Edit .env file with your Telegram Bot Token and database credentials"
|
|
echo "2. Get your bot token from @BotFather on Telegram"
|
|
echo "3. Configure your database connection"
|
|
echo "4. Run 'npm start' to start the bot"
|
|
echo ""
|
|
echo "For development: npm run dev"
|
|
echo "For production: npm run start:prod"
|
|
echo ""
|
|
echo "📚 Check README.md for detailed instructions."
|