Files
musadaq-saas/sync-to-server.sh

50 lines
2.7 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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 --no-dev --optimize-autoloader --no-interaction
echo "♻️ إعادة تشغيل PHP-FPM..."
# Update this to match your specific PHP version on CloudPanel
systemctl reload php8.4-fpm 2>/dev/null || systemctl reload php8.3-fpm 2>/dev/null
echo "🔄 إعادة تشغيل عامل الطابور (Supervisor)..."
supervisorctl restart musadaq-worker:* 2>/dev/null || true
ENDSSH
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ [3/3] اكتملت عملية المزامنة بنجاح!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"