Linux Patcher
by @jgm2025
Automated Linux server patching and Docker container updates. Use when the user asks to update, patch, or upgrade Linux servers, apply security updates, update Docker containers, check for system updates, or manage server maintenance across multiple hosts. Supports Ubuntu, Debian, RHEL, AlmaLinux, Rocky Linux, CentOS, Amazon Linux, and SUSE. Includes PatchMon integration for automatic host detection and intelligent Docker handling.
clawhub install linux-patcherπ About This Skill
name: linux-patcher description: Automated Linux server patching and Docker container updates. Use when the user asks to update, patch, or upgrade Linux servers, apply security updates, update Docker containers, check for system updates, or manage server maintenance across multiple hosts. Supports Ubuntu, Debian, RHEL, AlmaLinux, Rocky Linux, CentOS, Amazon Linux, and SUSE. Includes PatchMon integration for automatic host detection and intelligent Docker handling.
Linux Patcher
Automate Linux server patching and Docker container updates across multiple hosts via SSH.
β οΈ Important Disclaimers
Distribution Support Status
Fully Tested:
Supported but Untested:
Testing Recommendation: Always test untested distributions in a non-production environment first. The script will warn you when running on untested distributions.
Security Notice
This skill requires:
Read SETUP.md for complete security configuration guide.
Quick Start
Automated (Recommended)
Patch all hosts from PatchMon (automatic detection):
scripts/patch-auto.sh
Skip Docker updates (packages only):
scripts/patch-auto.sh --skip-docker
Preview changes (dry-run):
scripts/patch-auto.sh --dry-run
Manual (Alternative)
Single host - packages only:
scripts/patch-host-only.sh user@hostname
Single host - full update:
scripts/patch-host-full.sh user@hostname /path/to/docker/compose
Multiple hosts from config:
scripts/patch-multiple.sh config-file.conf
Features
--skip-docker flagvisudo or /etc/sudoers.d/ filesConfiguration
Option 1: Automatic via PatchMon (Recommended)
Configure PatchMon credentials for automatic host detection:
cp scripts/patchmon-credentials.example.conf ~/.patchmon-credentials.conf
nano ~/.patchmon-credentials.conf
Set your credentials:
PATCHMON_URL=https://patchmon.example.com
PATCHMON_USERNAME=your-username
PATCHMON_PASSWORD=your-password
Then simply run:
scripts/patch-auto.sh
The script will: 1. Query PatchMon for hosts needing updates 2. Auto-detect Docker on each host 3. Apply appropriate updates (host-only or full)
Option 2: Single Host (Quick Manual)
Run scripts directly with command-line arguments (no config file needed).
Option 3: Multiple Hosts (Manual Config)
Create a config file based on scripts/patch-hosts-config.example.sh:
cp scripts/patch-hosts-config.example.sh my-servers.conf
nano my-servers.conf
Example config:
# Host definitions: hostname,ssh_user,docker_path
HOSTS=(
"webserver.example.com,ubuntu,/opt/docker"
"database.example.com,root,/home/admin/compose"
"monitor.example.com,docker,/srv/monitoring"
)Update mode: "host-only" or "full"
UPDATE_MODE="full"Dry run mode (set to "false" to apply changes)
DRY_RUN="true"
Then run:
scripts/patch-multiple.sh my-servers.conf
Prerequisites
Required on Control Machine (where OpenClaw runs)
ssh command available)Install missing tools:
# Ubuntu/Debian
sudo apt install curl jqRHEL/CentOS/Rocky/Alma
sudo dnf install curl jqmacOS
brew install curl jq
Required on Target Hosts
PatchMon Setup (Required for Automatic Mode)
PatchMon is required to automatically detect which hosts need patching.
Important: PatchMon does NOT need to be installed on the same server as OpenClaw. Install PatchMon on a separate server (can be any server on your network), and OpenClaw will query it via API.
Download PatchMon:
What you need:
Architecture:
βββββββββββββββββββ HTTPS API βββββββββββββββββββ
β OpenClaw Host β ββββββββββββββββββ> β PatchMon Server β
β (this machine) β Query updates β (separate host) β
βββββββββββββββββββ βββββββββββββββββββ
β
β Reports
βΌ
βββββββββββββββββββ
β Target Hosts β
β (with agents) β
βββββββββββββββββββ
Quick Start: 1. Install PatchMon server on a separate server (see GitHub repo) 2. Install PatchMon agents on all hosts you want to patch 3. Configure OpenClaw to access PatchMon API:
cp scripts/patchmon-credentials.example.conf ~/.patchmon-credentials.conf
nano ~/.patchmon-credentials.conf # Set PatchMon server URL
chmod 600 ~/.patchmon-credentials.conf
Detailed setup:
See references/patchmon-setup.md for complete installation guide.
Can I use this skill without PatchMon? Yes! You can use manual mode to target specific hosts without PatchMon. However, automatic detection of hosts needing updates requires PatchMon.
On Target Hosts
Required:
apt and docker commands)For full updates:
Configure Passwordless Sudo
On each target host, create /etc/sudoers.d/patches:
# For Ubuntu/Debian systems
username ALL=(ALL) NOPASSWD: /usr/bin/apt, /usr/bin/dockerFor RHEL/CentOS systems
username ALL=(ALL) NOPASSWD: /usr/bin/yum, /usr/bin/docker, /usr/bin/dnf
Replace username with your SSH user. Test with sudo -l to verify.
Update Modes
Host-Only Updates
Updates system packages only:
apt update && apt upgrade (or yum update on RHEL)apt autoremove)When to use:
Full Updates
Complete update cycle:
docker system prune)When to use:
Workflow
Automatic Workflow (patch-auto.sh)
1. Query PatchMon - Fetch hosts needing updates via API 2. For each host: - SSH into host - Check if Docker is installed - Auto-detect Docker Compose path (if not specified) - Apply host-only OR full update based on Docker detection 3. Report results - Summary of successful/failed updates
Host-Only Update Process
1. SSH into target host
2. Run sudo apt update
3. Run sudo apt -y upgrade
4. Run sudo apt -y autoremove
5. Report results
Full Update Process
1. SSH into target host
2. Run sudo apt update && upgrade && autoremove
3. Navigate to Docker Compose directory
4. Run sudo docker system prune -af (cleanup)
5. Pull all Docker images listed in compose file
6. Run sudo docker compose pull
7. Run sudo docker compose up -d (recreate containers)
8. Report results
Docker Detection Logic
When using automatic mode:
Docker Path Auto-Detection
When Docker path is not specified, the script checks these locations:
1. /home/$USER/Docker/docker-compose.yml
2. /opt/docker/docker-compose.yml
3. /srv/docker/docker-compose.yml
4. $HOME/Docker/docker-compose.yml
5. Current directory
Override auto-detection:
scripts/patch-host-full.sh user@host /custom/path
Examples
Example 1: Automatic update via PatchMon (recommended)
# First time: configure credentials
cp scripts/patchmon-credentials.example.conf ~/.patchmon-credentials.conf
nano ~/.patchmon-credentials.confRun automatic updates
scripts/patch-auto.sh
Example 2: Automatic with dry-run
# Preview what would be updated
scripts/patch-auto.sh --dry-runReview output, then apply
scripts/patch-auto.sh
Example 3: Skip Docker updates
# Update packages only, even if Docker is detected
scripts/patch-auto.sh --skip-docker
Example 4: Manual single host, packages only
scripts/patch-host-only.sh admin@webserver.example.com
Example 5: Manual single host, full update with custom Docker path
scripts/patch-host-full.sh docker@app.example.com /home/docker/production
Example 6: Manual multiple hosts from config
scripts/patch-multiple.sh production-servers.conf
Example 7: Via OpenClaw chat
Simply ask OpenClaw:OpenClaw will use the automatic mode and report results.
Troubleshooting
PatchMon Integration Issues
#### "PatchMon credentials not found"
cp scripts/patchmon-credentials.example.conf ~/.patchmon-credentials.confPATCHMON_CONFIG environment variable to custom location#### "Failed to authenticate with PatchMon"
curl -k https://patchmon.example.com/api/health#### "No hosts need updates" but PatchMon shows updates available
systemctl status patchmon-agent/etc/patchmon/config.ymlpatchmon-agent reportSystem Update Issues
#### "Permission denied" on apt/docker commands
ssh user@host sudo apt update#### "Connection refused"
ssh user@host echo OK#### Docker Compose not found
scripts/patch-host-full.sh user@host /full/path/home/user/Docker, /opt/docker, /srv/docker#### Containers fail to start after update
ssh user@host "docker logs container-name"ssh user@host "cd /docker/path && docker compose logs"ssh user@host "cd /docker/path && docker compose down && docker compose up -d"PatchMon Integration (Optional)
For dashboard monitoring and scheduled patching, see references/patchmon-setup.md.
PatchMon provides:
Security Considerations
apt, docker only)
- Use /etc/sudoers.d/ files (easier to manage)
chmod 600 ~/.ssh/id_rsa
Best Practices
1. Test first - Run dry-run mode before applying changes 2. Stagger updates - Don't update all hosts simultaneously (avoid full outage) 3. Monitor logs - Check output for errors after updates 4. Backup configs - Keep Docker Compose files in version control 5. Schedule wisely - Update during low-traffic windows 6. Document paths - Maintain config files for infrastructure 7. Reboot when needed - Kernel updates require reboots (not automated)
Reboot Management
The scripts do NOT automatically reboot hosts. After updates:
1. Check if reboot required: ssh user@host "[ -f /var/run/reboot-required ] && echo YES || echo NO"
2. Schedule manual reboots during maintenance windows
3. Use PatchMon dashboard to track reboot requirements
Integration with OpenClaw
Run Updates on Schedule
Create a cron job for automatic nightly patching:
cron add --name "Nightly Server Patching" \
--schedule "0 2 * * *" \
--task "cd ~/.openclaw/workspace/skills/linux-patcher && scripts/patch-auto.sh"
Or packages-only mode:
cron add --name "Nightly Package Updates" \
--schedule "0 2 * * *" \
--task "cd ~/.openclaw/workspace/skills/linux-patcher && scripts/patch-auto.sh --skip-docker"
Run Updates via Chat
Simply ask OpenClaw natural language commands:
Full updates (packages + Docker containers):
Packages only (exclude Docker):
Query status:
What happens automatically:
When you say "Update my servers": 1. β Queries PatchMon for hosts needing updates 2. β Detects Docker on each host 3. β Updates system packages 4. β Pulls Docker images and recreates containers (if Docker detected) 5. β Reports results with success/failure count
When you say "Update my servers, excluding docker": 1. β Queries PatchMon for hosts needing updates 2. β Updates system packages only 3. β Skips all Docker operations (containers keep running) 4. β Reports results
Important: Docker updates are included by default for maximum automation. Use "excluding docker" to skip container updates.
Manual Override (Specific Hosts)
Target individual hosts without querying PatchMon:
OpenClaw will use the manual scripts for targeted updates.
Documentation Files
This skill includes comprehensive documentation:
First time setup? Read SETUP.md first - it provides step-by-step instructions for secure configuration.
Want to understand the flow? Check WORKFLOWS.md for visual diagrams of how the skill operates.
Supported Linux Distributions
| Distribution | Package Manager | Tested | Status | |--------------|-----------------|--------|--------| | Ubuntu | apt | β Yes | Fully supported | | Debian | apt | β οΈ No | Supported (untested) | | Amazon Linux 2 | yum | β οΈ No | Supported (untested) | | Amazon Linux 2023 | dnf | β οΈ No | Supported (untested) | | RHEL 7 | yum | β οΈ No | Supported (untested) | | RHEL 8+ | dnf | β οΈ No | Supported (untested) | | AlmaLinux | dnf | β οΈ No | Supported (untested) | | Rocky Linux | dnf | β οΈ No | Supported (untested) | | CentOS 7 | yum | β οΈ No | Supported (untested) | | CentOS 8+ | dnf | β οΈ No | Supported (untested) | | SUSE/OpenSUSE | zypper | β οΈ No | Supported (untested) |
The skill automatically detects the distribution and selects the appropriate package manager.
π‘ Examples
Example 1: Automatic update via PatchMon (recommended)
# First time: configure credentials
cp scripts/patchmon-credentials.example.conf ~/.patchmon-credentials.conf
nano ~/.patchmon-credentials.confRun automatic updates
scripts/patch-auto.sh
Example 2: Automatic with dry-run
# Preview what would be updated
scripts/patch-auto.sh --dry-runReview output, then apply
scripts/patch-auto.sh
Example 3: Skip Docker updates
# Update packages only, even if Docker is detected
scripts/patch-auto.sh --skip-docker
Example 4: Manual single host, packages only
scripts/patch-host-only.sh admin@webserver.example.com
Example 5: Manual single host, full update with custom Docker path
scripts/patch-host-full.sh docker@app.example.com /home/docker/production
Example 6: Manual multiple hosts from config
scripts/patch-multiple.sh production-servers.conf
Example 7: Via OpenClaw chat
Simply ask OpenClaw:OpenClaw will use the automatic mode and report results.
βοΈ Configuration
Option 1: Automatic via PatchMon (Recommended)
Configure PatchMon credentials for automatic host detection:
cp scripts/patchmon-credentials.example.conf ~/.patchmon-credentials.conf
nano ~/.patchmon-credentials.conf
Set your credentials:
PATCHMON_URL=https://patchmon.example.com
PATCHMON_USERNAME=your-username
PATCHMON_PASSWORD=your-password
Then simply run:
scripts/patch-auto.sh
The script will: 1. Query PatchMon for hosts needing updates 2. Auto-detect Docker on each host 3. Apply appropriate updates (host-only or full)
Option 2: Single Host (Quick Manual)
Run scripts directly with command-line arguments (no config file needed).
Option 3: Multiple Hosts (Manual Config)
Create a config file based on scripts/patch-hosts-config.example.sh:
cp scripts/patch-hosts-config.example.sh my-servers.conf
nano my-servers.conf
Example config:
# Host definitions: hostname,ssh_user,docker_path
HOSTS=(
"webserver.example.com,ubuntu,/opt/docker"
"database.example.com,root,/home/admin/compose"
"monitor.example.com,docker,/srv/monitoring"
)Update mode: "host-only" or "full"
UPDATE_MODE="full"Dry run mode (set to "false" to apply changes)
DRY_RUN="true"
Then run:
scripts/patch-multiple.sh my-servers.conf
π Tips & Best Practices
1. Test first - Run dry-run mode before applying changes 2. Stagger updates - Don't update all hosts simultaneously (avoid full outage) 3. Monitor logs - Check output for errors after updates 4. Backup configs - Keep Docker Compose files in version control 5. Schedule wisely - Update during low-traffic windows 6. Document paths - Maintain config files for infrastructure 7. Reboot when needed - Kernel updates require reboots (not automated)