feat: Make setup_openclaw_dev.sh idempotent - check before install

This commit is contained in:
devmatrix 2026-02-16 14:06:09 +00:00
parent 1785fab2a1
commit fffc670f1c
1 changed files with 38 additions and 16 deletions

View File

@ -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..."
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..."
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
# 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"
# ============================================