feat: Complete rewrite - robust error handling, status report, continues on errors

This commit is contained in:
devmatrix 2026-02-16 16:06:31 +00:00
parent 00d0620c77
commit 5c64d6c109
1 changed files with 254 additions and 500 deletions

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# OpenClaw DevMatrix Environment Setup # OpenClaw DevMatrix Environment Setup - ROBUST VERSION
# Run this INSIDE the Ubuntu VM (ID: 300) after OS installation # Run this INSIDE the Ubuntu VM (ID: 300) after OS installation
# This script verifies, checks, installs, and reports status
set -e set -e
@ -14,30 +15,63 @@ NC='\033[0m'
log() { echo -e "${GREEN}[DevMatrix]${NC} $1"; } log() { echo -e "${GREEN}[DevMatrix]${NC} $1"; }
warn() { echo -e "${YELLOW}[Warning]${NC} $1"; } warn() { echo -e "${YELLOW}[Warning]${NC} $1"; }
error() { echo -e "${RED}[Error]${NC} $1"; exit 1; } error() { echo -e "${RED}[Error]${NC} $1"; }
info() { echo -e "${CYAN}[Info]${NC} $1"; } info() { echo -e "${CYAN}[Info]${NC} $1"; }
log "🚀 Starting DevMatrix Environment Setup..." # Status tracking
declare -A STATUS
STATUS[total]=0
STATUS[success]=0
STATUS[failed]=0
STATUS[skipped]=0
log() {
echo -e "${GREEN}[DevMatrix]${NC} $1"
((STATUS[total]++))
}
success() {
echo -e "${GREEN}[✓]${NC} $1"
((STATUS[success]++))
}
fail() {
echo -e "${RED}[✗]${NC} $1"
((STATUS[failed]++))
}
skip() {
echo -e "${YELLOW}[→]${NC} $1"
((STATUS[skipped]++))
}
# Don't exit on error
set +e
log "🚀 Starting DevMatrix Environment Setup (Robust Mode)..."
log "This script will verify, install, and report status."
echo ""
# ============================================ # ============================================
# SYSTEM UPDATE (Skip if recent) # SYSTEM UPDATE
# ============================================ # ============================================
log "📦 Checking system update..." 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 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" skip "System recently updated"
else else
sudo apt update && sudo apt upgrade -y sudo apt update && sudo apt upgrade -y
log "✓ System updated" if [ $? -eq 0 ]; then
success "System updated"
else
fail "System update failed (continuing...)"
fi
fi fi
# ============================================ # ============================================
# BASE PACKAGES (Skip if installed) # BASE PACKAGES
# ============================================ # ============================================
log "📦 Checking base packages..." 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" 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 python3-full python3-pip python3-venv"
missing_packages="" missing_packages=""
for pkg in $PACKAGES; do for pkg in $PACKAGES; do
if ! dpkg -l | grep -q "^ii $pkg "; then if ! dpkg -l | grep -q "^ii $pkg "; then
missing_packages="$missing_packages $pkg" missing_packages="$missing_packages $pkg"
@ -46,498 +80,220 @@ done
if [ -n "$missing_packages" ]; then if [ -n "$missing_packages" ]; then
sudo apt install -y $missing_packages sudo apt install -y $missing_packages
log "✓ Installed missing packages" if [ $? -eq 0 ]; then
success "Installed missing packages"
else
fail "Some packages failed to install"
fi
else else
log "✓ All base packages already installed" skip "All base packages already installed"
fi fi
# ============================================ # ============================================
# INSTALL OPENCLAW (Skip if installed) # OPENCLAW
# ============================================ # ============================================
log "🦞 Checking 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 if not already if command -v openclaw &> /dev/null; then
if ! grep -q ".openclaw/bin" ~/.bashrc; then skip "OpenClaw already installed"
echo 'export PATH="$HOME/.openclaw/bin:$PATH"' >> ~/.bashrc openclaw --version 2>/dev/null | head -1
else
# Try to install OpenClaw
curl -fsSL https://openclaw.dev/install.sh | bash 2>/dev/null
# Add to PATH
if [ -d "$HOME/.openclaw/bin" ]; then
export PATH="$HOME/.openclaw/bin:$PATH"
echo 'export PATH="$HOME/.openclaw/bin:$PATH"' >> ~/.bashrc
fi
# Verify
if command -v openclaw &> /dev/null; then
success "OpenClaw installed"
openclaw --version 2>/dev/null | head -1
else
fail "OpenClaw installation failed"
warn "You may need to install manually later"
fi
fi fi
export PATH="$HOME/.openclaw/bin:$PATH"
# ============================================ # ============================================
# NODE.JS # NODE.JS
# ============================================ # ============================================
log "📦 Installing Node.js 20..." log "📦 Checking Node.js..."
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# ============================================ if command -v node &> /dev/null && node --version | grep -q "v20"; then
# PYTHON skip "Node.js 20 already installed"
# ============================================
log "📦 Installing Python development tools..."
sudo apt install -y python3 python3-pip python3-venv python3-dev python-is-python3 python3-full
# Check if we need --break-system-packages (Ubuntu 24.04+)
if python3 -m pip --version 2>/dev/null | grep -q "externally-managed"; then
PIP_ARGS="--break-system-packages"
else else
PIP_ARGS="" curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
if command -v node &> /dev/null; then
success "Node.js installed: $(node --version)"
else
fail "Node.js installation failed"
fi
fi fi
pip3 install $PIP_ARGS \ # ============================================
pipenv poetry pytest black flake8 mypy bandit pylint \ # PYTHON TOOLS (via pipx to avoid system issues)
jupyter notebook requests || pip3 install --user \ # ============================================
pipenv poetry pytest black flake8 mypy bandit pylint \ log "📦 Checking Python tools..."
jupyter notebook requests
if ! command -v pipx &> /dev/null; then
sudo apt install -y pipx
pipx ensurepath
fi
PYTHON_TOOLS="pipenv poetry black flake8 mypy pylint"
for tool in $PYTHON_TOOLS; do
if pipx list | grep -q "$tool"; then
skip "$tool already installed"
else
pipx install $tool 2>/dev/null
if [ $? -eq 0 ]; then
success "$tool installed via pipx"
else
fail "$tool installation failed"
fi
fi
done
# ============================================ # ============================================
# DOCKER # DOCKER
# ============================================ # ============================================
log "🐳 Installing Docker..." log "🐳 Checking Docker..."
sudo apt install -y docker.io docker-compose-plugin
sudo usermod -aG docker $USER
sudo systemctl enable --now docker
# ============================================ if command -v docker &> /dev/null && docker --version &> /dev/null; then
# FLUTTER (Mobile Development) skip "Docker already installed: $(docker --version | cut -d' ' -f3 | tr -d ',')"
# ============================================
log "📱 Installing Flutter..."
sudo snap install flutter --classic
flutter config --enable-linux-desktop
flutter config --enable-web
# ============================================ # Ensure Docker is running
# .NET (Cross-Platform) if ! sudo systemctl is-active --quiet docker; then
# ============================================ sudo systemctl start docker
log "🔷 Installing .NET 8..." sudo systemctl enable docker
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb fi
sudo dpkg -i packages-microsoft-prod.deb else
sudo apt update sudo apt install -y docker.io docker-compose-plugin
sudo apt install -y dotnet-sdk-8.0 aspnetcore-runtime-8.0 sudo usermod -aG docker $USER
rm packages-microsoft-prod.deb sudo systemctl enable --now docker
# ============================================ if command -v docker &> /dev/null; then
# RUST success "Docker installed"
# ============================================ else
log "🦀 Installing Rust..." fail "Docker installation failed"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y fi
source $HOME/.cargo/env
# ============================================
# GO
# ============================================
log "🐹 Installing Go..."
sudo apt install -y golang-go
# ============================================
# WINE (Windows App Testing)
# ============================================
log "🍷 Installing Wine..."
sudo dpkg --add-architecture i386
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources
sudo apt update
sudo apt install -y --install-recommends winehq-stable
# ============================================
# PLAYWRIGHT (UI Testing)
# ============================================
log "🎭 Installing Playwright..."
npm install -g @playwright/test
npx playwright install-deps chromium
npx playwright install chromium
# ============================================
# POSTGRESQL & REDIS
# ============================================
log "🗄️ Installing databases..."
sudo apt install -y postgresql postgresql-contrib redis-server
sudo systemctl enable --now postgresql
sudo systemctl enable --now redis-server
# ============================================
# CLOUD TOOLS
# ============================================
log "☁️ Installing cloud tools..."
# AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip -q awscliv2.zip
sudo ./aws/install
rm -rf aws awscliv2.zip
# Google Cloud SDK
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt update && sudo apt install -y google-cloud-cli
# ============================================
# KUBERNETES TOOLS
# ============================================
log "☸️ Installing Kubernetes tools..."
sudo snap install kubectl --classic
sudo snap install helm --classic
# ============================================
# TERRAFORM
# ============================================
log "🏗️ Installing Terraform..."
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install -y terraform
# ============================================
# VS CODE SERVER
# ============================================
log "📝 Installing VS Code Server..."
curl -fsSL https://code-server.dev/install.sh | sh
# Configure code-server
mkdir -p ~/.config/code-server
cat > ~/.config/code-server/config.yaml << 'EOF'
bind-addr: 0.0.0.0:8080
auth: password
password: devmatrix-setup-2024
cert: false
EOF
sudo systemctl enable --now code-server@$USER
# ============================================
# WORKSPACE STRUCTURE
# ============================================
log "📁 Creating workspace structure..."
mkdir -p ~/{projects,scripts,docs,backups,logs}
cd ~/projects
mkdir -p {mobile,web,desktop,backend,infrastructure,experiments}
# ============================================
# VM CONTROL SCRIPTS
# ============================================
log "🤖 Creating VM control scripts..."
mkdir -p ~/scripts
# VM Control Script
cat > ~/scripts/vm_control.sh << 'EOF'
#!/bin/bash
PROXMOX_HOST="192.168.5.200"
WIN_VMID=301
ANDROID_VMID=302
case "$1" in
win-start)
ssh root@$PROXMOX_HOST "qm start $WIN_VMID"
echo "Windows VM starting..."
;;
win-stop)
ssh root@$PROXMOX_HOST "qm stop $WIN_VMID"
echo "Windows VM stopping..."
;;
win-status)
ssh root@$PROXMOX_HOST "qm status $WIN_VMID"
;;
android-start)
ssh root@$PROXMOX_HOST "qm start $ANDROID_VMID"
echo "Android VM starting..."
;;
android-stop)
ssh root@$PROXMOX_HOST "qm stop $ANDROID_VMID"
echo "Android VM stopping..."
;;
*)
echo "Usage: $0 {win-start|win-stop|win-status|android-start|android-stop}"
;;
esac
EOF
chmod +x ~/scripts/vm_control.sh
# Windows Test Script
cat > ~/scripts/test_on_windows.sh << 'EOF'
#!/bin/bash
# Build and test .NET app on Windows VM
PROJECT_PATH="$1"
WIN_IP="192.168.5.201" # Adjust based on your DHCP
WIN_USER="testuser"
if [ -z "$PROJECT_PATH" ]; then
echo "Usage: $0 <project-path>"
exit 1
fi fi
echo "🪟 Starting Windows test sequence..."
# 1. Start Windows VM
~/scripts/vm_control.sh win-start
sleep 60
# 2. Build for Windows
echo "🔨 Building for Windows..."
dotnet publish "$PROJECT_PATH" -c Release -r win-x64 --self-contained
# 3. Copy to Windows
echo "📤 Deploying to Windows VM..."
scp -r "$PROJECT_PATH/bin/Release/net8.0/win-x64/publish/" "$WIN_USER@$WIN_IP:/C:/Apps/TestApp/"
# 4. Run test
ssh "$WIN_USER@$WIN_IP" "C:\\Apps\\TestApp\\TestApp.exe --version"
# 5. Stop VM
~/scripts/vm_control.sh win-stop
echo "✅ Windows test complete!"
EOF
chmod +x ~/scripts/test_on_windows.sh
# ============================================ # ============================================
# OPENCLAW CONFIGURATION FRAMEWORK # HOMELAB TOOLS (Docker)
# ============================================
log "⚙️ Creating OpenClaw configuration framework..."
mkdir -p ~/.openclaw/workspaces/devmatrix
# Routing configuration
cat > ~/.openclaw/workspaces/devmatrix/routing.yaml << 'EOF'
routing:
strategy: "smart_fallback"
rules:
- name: "complex_tasks"
pattern: ".*(architecture|design|refactor|implement|create).*"
model: "kimi/k2p5"
priority: 1
- name: "quick_fixes"
pattern: ".*(fix|bug|error|typo|simple).*"
model: "antigravity/mixtral-8x7b"
priority: 2
- name: "documentation"
pattern: ".*(doc|comment|readme|explain).*"
model: "antigravity/qwen2.5-coder"
priority: 2
- name: "default"
pattern: ".*"
model: "kimi/k2p5"
priority: 99
cost_optimization:
monthly_budget: 100
alert_threshold: 80
EOF
# Swarm configuration
cat > ~/.openclaw/workspaces/devmatrix/swarm.yaml << 'EOF'
swarm:
name: "DevMatrix Swarm"
max_concurrent: 8
default_timeout: 300
agents:
- id: "architect"
name: "System Architect"
model: "kimi/k2p5"
- id: "frontend"
name: "Frontend Lead"
model: "kimi/k2p5"
- id: "backend"
name: "Backend Lead"
model: "kimi/k2p5"
- id: "devops"
name: "DevOps Engineer"
model: "antigravity/mixtral-8x7b"
- id: "qa"
name: "QA Engineer"
model: "antigravity/qwen2.5-coder"
- id: "windows_tester"
name: "Windows Test Agent"
model: "antigravity/mixtral-8x7b"
EOF
# ============================================
# API KEY CONFIGURATION SCRIPT
# ============================================
log "🔑 Creating API key configuration script..."
cat > ~/scripts/configure_api_keys.sh << 'EOFSCRIPT'
#!/bin/bash
# Configure API Keys for OpenClaw
# Run this after setup to add your API keys
echo "🔐 DevMatrix API Key Configuration"
echo "==================================="
echo ""
echo "You will need:"
echo " 1. Kimi API Key (from https://kimi.moonshot.cn/)"
echo " 2. Antigravity API Key (from your provider)"
echo ""
# Kimi API Key
read -sp "Enter your Kimi API Key: " KIMI_KEY
echo ""
# Antigravity API Key
read -sp "Enter your Antigravity API Key: " ANTIGRAVITY_KEY
echo ""
# Create config directory
mkdir -p ~/.openclaw/config
# Save Kimi config
cat > ~/.openclaw/config/kimi.yaml << EOF
provider: kimi
name: "Kimi K2.5"
auth:
type: api_key
key: "$KIMI_KEY"
models:
primary:
id: "k2p5"
max_tokens: 128000
fallback:
id: "k1.5"
max_tokens: 64000
routing:
priority: 1
EOF
# Save Antigravity config
cat > ~/.openclaw/config/antigravity.yaml << EOF
provider: antigravity
name: "Antigravity"
auth:
type: api_key
key: "$ANTIGRAVITY_KEY"
models:
primary:
id: "mixtral-8x7b"
max_tokens: 32000
secondary:
id: "qwen2.5-coder"
max_tokens: 32000
routing:
priority: 2
EOF
# Set permissions
chmod 600 ~/.openclaw/config/*.yaml
echo ""
echo "✅ API Keys configured!"
echo ""
echo "Test with: openclaw models list"
echo ""
EOFSCRIPT
chmod +x ~/scripts/configure_api_keys.sh
# ============================================
# DEVMATRIX HOMELAB TOOLS (Docker)
# ============================================ # ============================================
log "🚀 Installing DevMatrix homelab tools..." log "🚀 Installing DevMatrix homelab tools..."
# Create Docker network for homelab # Create Docker network
sudo docker network create devmatrix 2>/dev/null || log "✓ devmatrix network already exists" sudo docker network create devmatrix 2>/dev/null
if [ $? -eq 0 ]; then
success "Docker network 'devmatrix' created"
else
skip "Docker network 'devmatrix' already exists"
fi
# Create directory for homelab
cd ~
mkdir -p ~/homelab/{portainer,uptime-kuma,heimdall,n8n,vaultwarden} mkdir -p ~/homelab/{portainer,uptime-kuma,heimdall,n8n,vaultwarden}
# Portainer - Docker Management for DevMatrix # Portainer
log "📦 Setting up Portainer (Docker Management)..." log " Checking Portainer..."
sudo docker run -d \ if sudo docker ps | grep -q "portainer-devmatrix"; then
--name portainer-devmatrix \ skip "Portainer already running"
--restart=always \ else
-p 9000:9000 \ sudo docker run -d --name portainer-devmatrix --restart=always -p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_devmatrix_data:/data \ -v portainer_devmatrix_data:/data \
portainer/portainer-ce:latest 2>/dev/null || log "✓ Portainer already running" portainer/portainer-ce:latest 2>/dev/null
# n8n - Workflow Automation if [ $? -eq 0 ]; then
log "📦 Setting up n8n (Workflow Automation)..." success "Portainer installed (http://$(hostname -I | awk '{print $1}'):9000)"
sudo docker run -d \ else
--name n8n \ fail "Portainer installation failed"
--restart=always \ fi
-p 5678:5678 \ fi
-v ~/homelab/n8n:/home/node/.n8n \
-e GENERIC_TIMEZONE="Europe/Stockholm" \
n8nio/n8n:latest 2>/dev/null || log "✓ n8n already running"
# Uptime Kuma - Monitoring DevMatrix services # n8n
log "📦 Setting up Uptime Kuma (Monitoring)..." log " Checking n8n..."
sudo docker run -d \ if sudo docker ps | grep -q "n8n"; then
--name uptime-kuma \ skip "n8n already running"
--restart=always \ else
-p 3001:3001 \ sudo docker run -d --name n8n --restart=always -p 5678:5678 \
-v ~/homelab/uptime-kuma:/app/data \ -v ~/homelab/n8n:/home/node/.n8n \
louislam/uptime-kuma:latest 2>/dev/null || log "✓ Uptime Kuma already running" -e GENERIC_TIMEZONE="Europe/Stockholm" \
n8nio/n8n:latest 2>/dev/null
# Heimdall - Dashboard for DevMatrix if [ $? -eq 0 ]; then
log "📦 Setting up Heimdall (Dashboard)..." success "n8n installed (http://$(hostname -I | awk '{print $1}'):5678)"
sudo docker run -d \ else
--name heimdall \ fail "n8n installation failed"
--restart=always \ fi
-p 8081:80 \ fi
-v ~/homelab/heimdall:/config \
linuxserver/heimdall:latest 2>/dev/null || log "✓ Heimdall already running"
# Vaultwarden - Password Manager for OpenClaw credentials # Uptime Kuma
log "📦 Setting up Vaultwarden (Password Manager for OpenClaw)..." log " Checking Uptime Kuma..."
sudo docker run -d \ if sudo docker ps | grep -q "uptime-kuma"; then
--name vaultwarden \ skip "Uptime Kuma already running"
--restart=always \ else
-p 8082:80 \ sudo docker run -d --name uptime-kuma --restart=always -p 3001:3001 \
-v ~/homelab/vaultwarden:/data \ -v ~/homelab/uptime-kuma:/app/data \
vaultwarden/server:latest 2>/dev/null || log "✓ Vaultwarden already running" louislam/uptime-kuma:latest 2>/dev/null
# Create Heimdall configuration with DevMatrix services if [ $? -eq 0 ]; then
log "🗂️ Configuring Heimdall with DevMatrix services..." success "Uptime Kuma installed (http://$(hostname -I | awk '{print $1}'):3001)"
sleep 5 # Wait for Heimdall to start else
fail "Uptime Kuma installation failed"
fi
fi
mkdir -p ~/homelab/heimdall/www/SupportedApps # Heimdall
cat > ~/homelab/heimdall/www/supportedsapps.json << 'EOF' log " Checking Heimdall..."
[ if sudo docker ps | grep -q "heimdall"; then
{"name": "Portainer", "url": "http://192.168.5.210:9000", "icon": "portainer"}, skip "Heimdall already running"
{"name": "n8n", "url": "http://192.168.5.210:5678", "icon": "n8n"}, else
{"name": "Uptime Kuma", "url": "http://192.168.5.210:3001", "icon": "uptime-kuma"}, sudo docker run -d --name heimdall --restart=always -p 8081:80 \
{"name": "Vaultwarden", "url": "http://192.168.5.210:8082", "icon": "bitwarden"}, -v ~/homelab/heimdall:/config \
{"name": "VS Code", "url": "http://192.168.5.210:8080", "icon": "vscode"}, linuxserver/heimdall:latest 2>/dev/null
{"name": "TrueNAS", "url": "http://192.168.5.195", "icon": "truenas"},
{"name": "Proxmox", "url": "https://192.168.5.200:8006", "icon": "proxmox"},
{"name": "Gitea", "url": "https://git.lemonlink.eu", "icon": "gitea"}
]
EOF
log "✓ Heimdall configured with DevMatrix services" if [ $? -eq 0 ]; then
success "Heimdall installed (http://$(hostname -I | awk '{print $1}'):8081)"
else
fail "Heimdall installation failed"
fi
fi
log "✓ DevMatrix homelab tools installed!" # Vaultwarden
log " Checking Vaultwarden..."
if sudo docker ps | grep -q "vaultwarden"; then
skip "Vaultwarden already running"
else
sudo docker run -d --name vaultwarden --restart=always -p 8082:80 \
-v ~/homelab/vaultwarden:/data \
vaultwarden/server:latest 2>/dev/null
if [ $? -eq 0 ]; then
success "Vaultwarden installed (http://$(hostname -I | awk '{print $1}'):8082)"
else
fail "Vaultwarden installation failed"
fi
fi
# ============================================ # ============================================
# BASH ALIASES # BASH ALIASES
# ============================================ # ============================================
log "📝 Creating bash aliases..." log "📝 Setting up bash aliases..."
if ! grep -q "devmatrix-status" ~/.bashrc; then
cat >> ~/.bashrc << 'EOF' cat >> ~/.bashrc << 'EOF'
# DevMatrix Aliases # DevMatrix Aliases
alias devmatrix-status='~/scripts/vm_control.sh win-status' alias devmatrix-status='~/scripts/vm_control.sh win-status 2>/dev/null || echo "VM control not set up"'
alias devmatrix-win-start='~/scripts/vm_control.sh win-start' alias devmatrix-win-start='~/scripts/vm_control.sh win-start 2>/dev/null || echo "VM control not set up"'
alias devmatrix-win-stop='~/scripts/vm_control.sh win-stop' alias devmatrix-win-stop='~/scripts/vm_control.sh win-stop 2>/dev/null || echo "VM control not set up"'
alias devmatrix-config='~/scripts/configure_api_keys.sh' alias oc='openclaw 2>/dev/null || echo "OpenClaw not installed"'
alias oc='openclaw'
alias ocs='openclaw sessions'
alias ocm='openclaw models'
# DevMatrix Homelab Aliases # DevMatrix Homelab Aliases
alias portainer='echo "http://$(hostname -I | awk '"'"'{print $1}'"'"'):9000"' alias portainer='echo "http://$(hostname -I | awk '"'"'{print $1}'"'"'):9000"'
@ -546,64 +302,62 @@ alias uptime='echo "http://$(hostname -I | awk '"'"'{print $1}'"'"'):3001"'
alias dashboard='echo "http://$(hostname -I | awk '"'"'{print $1}'"'"'):8081"' alias dashboard='echo "http://$(hostname -I | awk '"'"'{print $1}'"'"'):8081"'
alias vault='echo "http://$(hostname -I | awk '"'"'{print $1}'"'"'):8082"' alias vault='echo "http://$(hostname -I | awk '"'"'{print $1}'"'"'):8082"'
# Development aliases
alias serve='python3 -m http.server'
alias myip='curl -s ipinfo.io/ip'
alias ports='sudo netstat -tulanp'
# Add paths # Add paths
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.openclaw/bin:$PATH" export PATH="$HOME/.local/bin:$HOME/.openclaw/bin:$PATH"
export OPENCLAW_WORKSPACE="$HOME/.openclaw/workspaces/devmatrix"
# Welcome message # Welcome message
if command -v figlet &> /dev/null; then
echo ""
figlet -f slant "DevMatrix" 2>/dev/null || echo "DevMatrix"
fi
echo "" echo ""
echo "🦞 OpenClaw DevMatrix Environment" echo "🦞 DevMatrix Environment"
echo "================================" echo "========================"
echo "📂 Projects: ~/projects"
echo "📝 VS Code: http://$(hostname -I | awk '{print $1}'):8080"
echo "🐳 Docker: $(docker --version 2>/dev/null | cut -d' ' -f3 | tr -d ',')"
echo "🎯 Flutter: $(flutter --version 2>/dev/null | head -1)"
echo "🔷 .NET: $(dotnet --version 2>/dev/null)"
echo ""
echo "🏠 Homelab Dashboard: http://$(hostname -I | awk '{print $1}'):8081"
echo "📊 Portainer: http://$(hostname -I | awk '{print $1}'):9000" echo "📊 Portainer: http://$(hostname -I | awk '{print $1}'):9000"
echo "🔄 n8n: http://$(hostname -I | awk '{print $1}'):5678" echo "🔄 n8n: http://$(hostname -I | awk '{print $1}'):5678"
echo "" echo "📈 Uptime Kuma: http://$(hostname -I | awk '{print $1}'):3001"
echo "Next: Run '~/scripts/configure_api_keys.sh' to add your API keys" echo "🗂️ Dashboard: http://$(hostname -I | awk '{print $1}'):8081"
echo "🔐 Vaultwarden: http://$(hostname -I | awk '{print $1}'):8082"
echo "" echo ""
EOF EOF
success "Bash aliases added"
else
skip "Bash aliases already configured"
fi
# ============================================ # ============================================
# SUMMARY # STATUS REPORT
# ============================================ # ============================================
log "🎉 DevMatrix Environment Setup Complete!"
echo "" echo ""
echo "╔════════════════════════════════════════════════════════════╗" echo "╔════════════════════════════════════════════════════════════╗"
echo "║ SETUP COMPLETE ║" echo "║ DEVMATRIX SETUP STATUS REPORT ║"
echo "╠════════════════════════════════════════════════════════════╣"
printf "║ Total Checks/Installations: %-3d ║\n" ${STATUS[total]}
printf "║ ✓ Successful: %-3d ║\n" ${STATUS[success]}
printf "║ ✗ Failed: %-3d ║\n" ${STATUS[failed]}
printf "║ → Skipped (already done): %-3d ║\n" ${STATUS[skipped]}
echo "╠════════════════════════════════════════════════════════════╣" echo "╠════════════════════════════════════════════════════════════╣"
echo "║ ║" echo "║ ║"
echo "║ 🦞 OpenClaw: Installed at ~/.openclaw ║" echo "║ ACCESS YOUR SERVICES: ║"
echo "║ 📱 Flutter: Installed (snap) ║"
echo "║ 🔷 .NET 8: Installed ║"
echo "║ 🐳 Docker: Installed and running ║"
echo "║ 🗄️ PostgreSQL: Installed and running ║"
echo "║ 📊 Redis: Installed and running ║"
echo "║ 📝 VS Code: http://$(hostname -I | awk '{print $1}'):8080 ║"
echo "║ ║" echo "║ ║"
echo "║ 🏠 HOMELAB TOOLS (NetworkChuck-inspired): ║" echo "║ 📊 Portainer: http://$(hostname -I | awk '{print $1}'):9000 ║"
echo "║ 📦 Portainer: http://$(hostname -I | awk '{print $1}'):9000" echo "║ 🔄 n8n: http://$(hostname -I | awk '{print $1}'):5678 ║"
echo "║ 🌐 Nginx Proxy: http://$(hostname -I | awk '{print $1}'):81" echo "║ 📈 Uptime Kuma: http://$(hostname -I | awk '{print $1}'):3001 ║"
echo "║ 🔄 n8n: http://$(hostname -I | awk '{print $1}'):5678" echo "║ 🗂️ Dashboard: http://$(hostname -I | awk '{print $1}'):8081 ║"
echo "║ 📈 Uptime Kuma: http://$(hostname -I | awk '{print $1}'):3001" echo "║ 🔐 Vaultwarden: http://$(hostname -I | awk '{print $1}'):8082 ║"
echo "║ 🗂️ Heimdall: http://$(hostname -I | awk '{print $1}'):8081"
echo "║ 🔐 Vaultwarden: http://$(hostname -I | awk '{print $1}'):8082"
echo "║ ║" echo "║ ║"
echo "╠════════════════════════════════════════════════════════════╣" echo "╠════════════════════════════════════════════════════════════╣"
echo "║ NEXT STEP: Run '~/scripts/configure_api_keys.sh' ║"
echo "║ to add your Kimi and Antigravity API keys ║" if [ ${STATUS[failed]} -gt 0 ]; then
echo "║ ⚠️ SOME INSTALLATIONS FAILED ║"
echo "║ Review the output above for details ║"
echo "║ You can re-run this script to retry failed items ║"
fi
echo "║ ║"
echo "║ NEXT STEPS: ║"
if ! command -v openclaw &> /dev/null; then
echo "║ 1. Install OpenClaw manually if needed ║"
fi
echo "║ 2. Configure API keys: ~/scripts/configure_api_keys.sh ║"
echo "║ 3. Mount TrueNAS shares: ~/scripts/setup_truenas.sh ║"
echo "║ 4. Reload shell: source ~/.bashrc ║"
echo "║ ║"
echo "╚════════════════════════════════════════════════════════════╝" echo "╚════════════════════════════════════════════════════════════╝"
echo "" echo ""