# Fix: rsync Not Found During Deployment

**Issue**: Deployment fails with `rsync: command not found` on target VMIDs

**Status**: ✅ **FIXED**

---

## Problem

The deployment script was failing because `rsync` was not installed on the target VMIDs (2400, 2401, 2402).

**Error:**
```
bash: line 1: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12)
```

---

## Solution

Updated `scripts/deploy-to-vmid.sh` to automatically install required dependencies before copying files:

1. **Install `rsync`** - Required for file copying
2. **Install `curl`** - Required for Node.js installation
3. **Install Node.js** - If not already installed
4. **Install `npm`** - If not already installed

---

## What Changed

**File**: `scripts/deploy-to-vmid.sh`

**Added dependency installation step:**
```bash
# Install required dependencies on remote (rsync, nodejs, npm)
echo "Installing required dependencies on VMID $VMID..."
ssh $SSH_KEY -o StrictHostKeyChecking=no "root@$VMIP" "
  export DEBIAN_FRONTEND=noninteractive
  apt-get update -qq
  apt-get install -y -qq rsync curl >/dev/null 2>&1 || true
  # Check if Node.js is installed, if not install it
  if ! command -v node >/dev/null 2>&1; then
    curl -fsSL https://deb.nodesource.com/setup_20.x | bash - >/dev/null 2>&1
    apt-get install -y -qq nodejs >/dev/null 2>&1
  fi
  # Ensure npm is available
  if ! command -v npm >/dev/null 2>&1; then
    apt-get install -y -qq npm >/dev/null 2>&1
  fi
"
```

**Also updated npm installation to support pnpm:**
```bash
# Use npm or pnpm if available
if command -v pnpm >/dev/null 2>&1; then
  pnpm install --production
else
  npm install --production
fi
```

---

## Deploy Now

The deployment script now automatically installs dependencies. Run:

```bash
cd /home/intlc/projects/proxmox/rpc-translator-138
./scripts/deploy-smart-interception.sh
```

Or deploy to a specific VMID:

```bash
./scripts/deploy-to-vmid.sh 2402 192.168.11.242
```

---

## What Gets Installed

On each target VMID, the script now automatically installs:

1. ✅ **rsync** - For file synchronization
2. ✅ **curl** - For downloading Node.js installer
3. ✅ **Node.js 20.x** - If not already installed
4. ✅ **npm** - If not already installed

All installations are done silently (`-qq` flag) to keep output clean.

---

**Status**: ✅ **Fixed - Ready to deploy!**
