#!/bin/bash # 🔄 YouTube Metadata Extractor - Update Script # This script updates the project on a remote server echo "🔄 Updating YouTube Metadata Extractor..." # Configuration PROJECT_DIR="$HOME/YouTube" # Colors for output GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # No Color # Function to print colored output print_status() { echo -e "${GREEN}✅ $1${NC}" } print_warning() { echo -e "${YELLOW}⚠️ $1${NC}" } print_error() { echo -e "${RED}❌ $1${NC}" } # Check if project directory exists if [ ! -d "$PROJECT_DIR" ]; then print_error "Project directory not found: $PROJECT_DIR" print_error "Please run deploy.sh first to set up the project" exit 1 fi cd "$PROJECT_DIR" # Stop services print_status "Stopping services..." sudo systemctl stop youtube-api.service youtube-bot.service # Pull latest changes print_status "Pulling latest changes from repository..." git pull origin main # Activate virtual environment and update dependencies print_status "Updating Python dependencies..." source .venv/bin/activate pip install --upgrade pip pip install -r requirements.txt pip install -r telegram_requirements.txt # Start services print_status "Starting services..." sudo systemctl start youtube-api.service youtube-bot.service # Check service status print_status "Checking service status..." sleep 5 if systemctl is-active --quiet youtube-api.service; then print_status "YouTube API Server is running" else print_error "YouTube API Server failed to start" sudo systemctl status youtube-api.service fi if systemctl is-active --quiet youtube-bot.service; then print_status "YouTube Telegram Bot is running" else print_error "YouTube Telegram Bot failed to start" sudo systemctl status youtube-bot.service fi print_status "Update completed!" echo "" echo "📋 Useful commands:" echo "- Check logs: sudo journalctl -f -u youtube-api -u youtube-bot" echo "- Service status: sudo systemctl status youtube-api youtube-bot" echo "- Restart services: sudo systemctl restart youtube-api youtube-bot"