diff --git a/setup_openclaw_dev.sh b/setup_openclaw_dev.sh index 0801ab8..ebd01d9 100644 --- a/setup_openclaw_dev.sh +++ b/setup_openclaw_dev.sh @@ -20,30 +20,52 @@ info() { echo -e "${CYAN}[Info]${NC} $1"; } log "🚀 Starting DevMatrix Environment Setup..." # ============================================ -# SYSTEM UPDATE +# SYSTEM UPDATE (Skip if recent) # ============================================ -log "📦 Updating system..." -sudo apt update && sudo apt upgrade -y +log "📦 Checking system update..." +if [ -f /var/lib/apt/periodic/update-success-stamp ] && [ $(($(date +%s) - $(stat -c %Y /var/lib/apt/periodic/update-success-stamp))) -lt 86400 ]; then + log "✓ System recently updated, skipping" +else + sudo apt update && sudo apt upgrade -y + log "✓ System updated" +fi # ============================================ -# BASE PACKAGES +# BASE PACKAGES (Skip if installed) # ============================================ -log "📦 Installing base packages..." -sudo apt install -y \ - curl wget git git-lfs \ - build-essential software-properties-common \ - apt-transport-https ca-certificates gnupg lsb-release \ - unzip zip jq htop tree vim nano tmux \ - sshpass +log "📦 Checking base packages..." + +PACKAGES="curl wget git git-lfs build-essential software-properties-common apt-transport-https ca-certificates gnupg lsb-release unzip zip jq htop tree vim nano tmux sshpass" + +missing_packages="" +for pkg in $PACKAGES; do + if ! dpkg -l | grep -q "^ii $pkg "; then + missing_packages="$missing_packages $pkg" + fi +done + +if [ -n "$missing_packages" ]; then + sudo apt install -y $missing_packages + log "✓ Installed missing packages" +else + log "✓ All base packages already installed" +fi # ============================================ -# INSTALL OPENCLAW +# INSTALL OPENCLAW (Skip if installed) # ============================================ -log "🦞 Installing OpenClaw..." -curl -fsSL https://openclaw.dev/install.sh | bash +log "🦞 Checking OpenClaw..." +if command -v openclaw &> /dev/null; then + log "✓ OpenClaw already installed" +else + curl -fsSL https://openclaw.dev/install.sh | bash + log "✓ OpenClaw installed" +fi -# Add to PATH -echo 'export PATH="$HOME/.openclaw/bin:$PATH"' >> ~/.bashrc +# Add to PATH if not already +if ! grep -q ".openclaw/bin" ~/.bashrc; then + echo 'export PATH="$HOME/.openclaw/bin:$PATH"' >> ~/.bashrc +fi export PATH="$HOME/.openclaw/bin:$PATH" # ============================================