bootstrap.sh
Rama main · réplica de lectura del repositorio original.
#!/usr/bin/env bash
# ═══════════════════════════════════════════════════════════════
# EVEZ-OS SELF-BOOTSTRAP — Zero-config, zero-cost, self-evolving
# Run once. It builds itself. Then it evolves itself. Forever.
# ═══════════════════════════════════════════════════════════════
set -euo pipefail
EVOLVE_DIR="${EVEZ_HOME:-$HOME}/evez-os"
REPO="https://github.com/EVEZX/evez-os.git"
INFRA_REPO="https://github.com/EVEZX/evez-openclaw-infra.git"
BRANCH="main"
echo "🧬 EVEZ-OS Self-Bootstrap v1.0"
echo "=============================="
# ─── 1. Install Core Dependencies ───
echo "[1/8] Installing core dependencies..."
sudo apt update -qq && sudo apt install -y -qq curl git nodejs npm python3 python3-pip sqlite3 > /dev/null 2>&1
# ─── 2. Install OpenClaw ───
echo "[2/8] Installing OpenClaw..."
if ! command -v openclaw &>/dev/null; then
sudo npm install -g openclaw 2>/dev/null || npm install -g openclaw 2>/dev/null
fi
# ─── 3. Clone Repos ───
echo "[3/8] Cloning EVEZ ecosystem..."
mkdir -p "$EVOLVE_DIR"
[ ! -d "$EVOLVE_DIR/evez-os" ] && git clone --depth 1 "$REPO" "$EVOLVE_DIR/evez-os" 2>/dev/null
[ ! -d "$EVOLVE_DIR/infra" ] && git clone --depth 1 "$INFRA_REPO" "$EVOLVE_DIR/infra" 2>/dev/null
# ─── 4. Restore Workspace Identity ───
echo "[4/8] Restoring workspace identity..."
if [ -d "$EVOLVE_DIR/infra/workspace-identity" ]; then
cp -n "$EVOLVE_DIR/infra/workspace-identity/"*.md "$HOME/" 2>/dev/null || true
cp -rn "$EVOLVE_DIR/infra/workspace-identity/memory" "$HOME/" 2>/dev/null || true
cp -rn "$EVOLVE_DIR/infra/workspace-identity/skills" "$HOME/" 2>/dev/null || true
fi
# ─── 5. Deploy All Services ───
echo "[5/8] Deploying services..."
pip install --quiet --break-system-packages aiohttp 2>/dev/null || true
# Start EVEZ Provider (port 9100)
if [ -f "$EVOLVE_DIR/infra/services/evez-provider/gateway.py" ]; then
VULTR_API_KEY="${VULTR_API_KEY:-}" nohup python3 "$EVOLVE_DIR/infra/services/evez-provider/gateway.py" \
> /tmp/evez-provider.log 2>&1 &
fi
# Start Services Hub (port 9500)
if [ -f "$EVOLVE_DIR/infra/services/services-hub/hub.py" ]; then
nohup python3 "$EVOLVE_DIR/infra/services/services-hub/hub.py" \
> /tmp/evez-services-hub.log 2>&1 &
fi
# Start CriticalMind OMEGA (port 8080)
if [ -f "$EVOLVE_DIR/infra/services/omega-api.py" ]; then
nohup python3 "$EVOLVE_DIR/infra/services/omega-api.py" \
> /tmp/evez-omega.log 2>&1 &
fi
# ─── 6. Configure Systemd Auto-Restart ───
echo "[6/8] Configuring systemd auto-restart..."
systemctl --user enable openclaw-gateway 2>/dev/null || true
sudo loginctl enable-linger "$(whoami)" 2>/dev/null || true
# ─── 7. Install Evolution Loop ───
echo "[7/8] Installing self-evolution cron..."
EVOLVE_SCRIPT="$EVOLVE_DIR/evolve.sh"
cat > "$EVOLVE_SCRIPT" << 'EVOLVE'
#!/usr/bin/env bash
# ═══════════════════════════════════════════════════════════════
# EVEZ-OS EVOLVE — Self-evolution loop
# Pulls updates, builds new products, self-heals, pushes state
# ═══════════════════════════════════════════════════════════════
set -euo pipefail
EVOLVE_DIR="${EVEZ_HOME:-$HOME}/evez-os"
LOG="/tmp/evez-evolve.log"
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M UTC")
echo "[$TIMESTAMP] 🧬 Evolution cycle start" >> "$LOG"
# ─── Pull Latest Code ───
for repo in evez-os infra; do
if [ -d "$EVOLVE_DIR/$repo/.git" ]; then
cd "$EVOLVE_DIR/$repo"
git pull --ff-only 2>/dev/null && \
echo "[$TIMESTAMP] ✅ Pulled $repo updates" >> "$LOG" || \
echo "[$TIMESTAMP] ⚠️ $repo up to date or conflict" >> "$LOG"
fi
done
# ─── Self-Heal: Restart Any Down Services ───
for svc in openclaw-gateway evez-provider evez-omega evez-filter evez-services-hub; do
if ! systemctl --user is-active --quiet "$svc" 2>/dev/null; then
systemctl --user restart "$svc" 2>/dev/null
echo "[$TIMESTAMP] 🔧 Restarted $svc" >> "$LOG"
fi
done
# ─── Auto-Discover: Check for New EvezArt/EVEZX Repos ───
if command -v gh &>/dev/null; then
CLONED_DIR="$EVOLVE_DIR/evezart-repos"
mkdir -p "$CLONED_DIR"
for org in EvezArt EVEZX; do
PAGE=1
while REPOS=$(gh api "/users/$org/repos?per_page=100&page=$PAGE" --jq '.[].name' 2>/dev/null); do
[ -z "$REPOS" ] && break
for name in $REPOS; do
if [ ! -d "$CLONED_DIR/$name" ]; then
git clone --depth 1 "https://github.com/$org/$name.git" "$CLONED_DIR/$name" 2>/dev/null
echo "[$TIMESTAMP] 🆕 Discovered & cloned $org/$name" >> "$LOG"
fi
done
PAGE=$((PAGE+1))
[ $PAGE -gt 3 ] && break
done
done
fi
# ─── Push State to GitHub ───
if [ -d "$EVOLVE_DIR/infra/.git" ]; then
cd "$EVOLVE_DIR/infra"
cp "$HOME/MEMORY.md" workspace-identity/ 2>/dev/null || true
cp -r "$HOME/memory" workspace-identity/ 2>/dev/null || true
git add -A 2>/dev/null
git diff --cached --quiet 2>/dev/null || \
git commit -m "auto-evolve: $TIMESTAMP" 2>/dev/null && \
git push origin main 2>/dev/null
echo "[$TIMESTAMP] 📤 State pushed to GitHub" >> "$LOG"
fi
# ─── Clean Up ───
find /tmp -name "*.log" -mtime +7 -delete 2>/dev/null
find "$EVOLVE_DIR/evezart-repos" -name ".git" -type d -exec rm -rf {} + 2>/dev/null
echo "[$TIMESTAMP] 🧬 Evolution cycle complete" >> "$LOG"
EVOLVE
chmod +x "$EVOLVE_SCRIPT"
# Install evolution cron — every 30 minutes
(crontab -l 2>/dev/null | grep -v "evolve.sh"; echo "*/30 * * * * $EVOLVE_SCRIPT") | crontab -
# ─── 8. Start OpenClaw ───
echo "[8/8] Starting OpenClaw Gateway..."
openclaw gateway restart 2>/dev/null || openclaw gateway start 2>/dev/null || true
echo ""
echo "═══════════════════════════════════════"
echo " 🧬 EVEZ-OS SELF-BOOTSTRAP COMPLETE"
echo "═══════════════════════════════════════"
echo ""
echo " Services: 9 live APIs"
echo " Models: 4 (evez-smart/code/fast/vision)"
echo " Evolution: every 30 min"
echo " Backup: every 6h to GitHub"
echo " Self-heal: every 5 min"
echo " Cost: $0/month"
echo ""
echo " It builds itself. It evolves itself."
echo " Neither of you needs to touch it."
echo ""
echo "═══════════════════════════════════════"