#!/bin/bash set -euo pipefail # ════════════════════════════════════════════════════════════ # مُصادَق — Production Sync Script (Mac to CloudPanel) # ════════════════════════════════════════════════════════════ COMMIT_MSG="${1:-🚀 مُصادَق: تحديث وتطوير النظام $(date '+%Y-%m-%d %H:%M')}" SERVER_USER="root" SERVER_IP="194.163.173.157" # From previous context PROJECT_DIR="/home/intaleqapp-musadaq/htdocs/musadaq.intaleqapp.com/Application" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "📦 [1/3] الرفع إلى Git (Local to Repo)..." echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" git add . git commit -m "$COMMIT_MSG" || echo "ℹ️ لا توجد تغييرات جديدة للرفع." git push origin main echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "🌐 [2/3] السحب على الخادم (Repo to Server)..." echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" ssh $SERVER_USER@$SERVER_IP << ENDSSH set -e cd "$PROJECT_DIR" # Ensure git is initialized on server if not already if [ ! -d ".git" ]; then git init git remote add origin https://git.intaleqapp.com/Hamza/musadaq-saas.git fi git fetch origin git reset --hard origin/main echo "📦 تثبيت التبعيات (Composer)..." composer install --optimize-autoloader --no-interaction echo "♻️ إعادة تشغيل PHP-FPM..." systemctl reload php8.4-fpm 2>/dev/null || systemctl reload php8.3-fpm 2>/dev/null echo "🔄 تحديث وإعادة تشغيل عامل الطابور (Supervisor)..." if [ -f "supervisor.conf" ]; then cp supervisor.conf /etc/supervisor/conf.d/musadaq.conf 2>/dev/null || true fi supervisorctl reread 2>/dev/null || true supervisorctl update 2>/dev/null || true supervisorctl restart musadaq-worker:* 2>/dev/null || true ENDSSH echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "✅ [3/3] اكتملت عملية المزامنة بنجاح!" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"