Spaces:
Running
Running
| # HuggingFace Startup Script - Bot + API Only | |
| # Dashboard is deployed separately on Vercel | |
| set -e # Exit on error | |
| echo "🚀 Ultroid HuggingFace Startup (Bot + API Only)" | |
| echo "================================================" | |
| echo "ℹ️ Dashboard should be deployed to Vercel separately" | |
| echo "================================================" | |
| # Get secrets from environment and STRIP any newlines/whitespace | |
| GITHUB_USERNAME=$(echo "${GITHUB_USERNAME:-}" | tr -d '\n\r' | xargs) | |
| GITHUB_TOKEN=$(echo "${GITHUB_TOKEN:-}" | tr -d '\n\r' | xargs) | |
| REPO_NAME=$(echo "${REPO_NAME:-Ultroid}" | tr -d '\n\r' | xargs) | |
| # Debug (remove sensitive info) | |
| echo "Username: ${GITHUB_USERNAME}" | |
| echo "Repo: ${REPO_NAME}" | |
| echo "Token length: ${#GITHUB_TOKEN}" | |
| # Check if secrets are provided | |
| if [ -z "$GITHUB_USERNAME" ] || [ -z "$GITHUB_TOKEN" ]; then | |
| echo "❌ ERROR: GITHUB_USERNAME and GITHUB_TOKEN must be set as secrets" | |
| exit 1 | |
| fi | |
| # Clone repository if not exists | |
| if [ ! -d "/app/repo" ]; then | |
| echo "📥 Cloning repository from GitHub..." | |
| git clone "https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${GITHUB_USERNAME}/${REPO_NAME}.git" /app/repo | |
| cd /app/repo | |
| # Keep .git folder - bot needs it for branch detection | |
| echo "✅ Repository cloned successfully" | |
| else | |
| echo "✅ Repository already exists" | |
| cd /app/repo | |
| fi | |
| # Install Python dependencies | |
| echo "📦 Installing Python dependencies..." | |
| pip install --no-cache-dir -r requirements.txt | |
| echo "✅ Python dependencies installed" | |
| # Skip dashboard build - it's on Vercel | |
| echo "⏭️ Skipping dashboard build (deployed to Vercel)" | |
| # Create required directories | |
| mkdir -p /app/repo/sessions /app/repo/resources/auth /app/repo/tmp /app/repo/pdf /app/repo/addons | |
| chmod -R 777 /app/repo/sessions /app/repo/resources /app/repo/tmp /app/repo/pdf /app/repo/addons | |
| # Fix relative imports | |
| touch /app/repo/__init__.py /app/repo/addons/__init__.py /app/repo/pyUltroid/__init__.py | |
| # Fix DNS | |
| if [ -w /etc/resolv.conf ]; then | |
| echo "nameserver 1.1.1.1" > /etc/resolv.conf | |
| echo "nameserver 1.0.0.1" >> /etc/resolv.conf | |
| fi | |
| # Load environment variables if .env exists | |
| if [ -f .env ]; then | |
| set -o allexport | |
| source .env | |
| set +o allexport | |
| fi | |
| echo "================================" | |
| echo "✅ Repository setup complete!" | |
| echo "================================" | |
| # Start the bot (it will start the API server itself via __main__.py) | |
| echo "🚀 Launching bot + API server..." | |
| cd /app/repo | |
| if [ "$SESSION1" ]; then | |
| echo "🤖 Starting multi_client.py..." | |
| exec python3 multi_client.py | |
| else | |
| echo "🤖 Starting pyUltroid..." | |
| exec python3 -m pyUltroid | |
| fi | |