Automate Linux server patching and Docker container updates across multiple hosts via SSH.
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.
This skill requires:
Read SETUP.md for complete security configuration guide.
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
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
--skip-docker flagvisudo or /etc/sudoers.d/ filesConfigure 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:
Run scripts directly with command-line arguments (no config file needed).
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
ssh command available)Install missing tools:
# Ubuntu/Debian
sudo apt install curl jq
# RHEL/CentOS/Rocky/Alma
sudo dnf install curl jq
# macOS
brew install curl jq
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:
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.
Required:
apt and docker commands)For full updates:
On each target host, create /etc/sudoers.d/patches:
# For Ubuntu/Debian systems
username ALL=(ALL) NOPASSWD: /usr/bin/apt, /usr/bin/docker
# For 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.
Updates system packages only:
apt update && apt upgrade (or yum update on RHEL)apt autoremove)When to use:
Complete update cycle:
docker system prune)When to use:
sudo apt updatesudo apt -y upgradesudo apt -y autoremovesudo apt update && upgrade && autoremovesudo docker system prune -af (cleanup)sudo docker compose pullsudo docker compose up -d (recreate containers)When using automatic mode:
When Docker path is not specified, the script checks these locations:
/home/$USER/Docker/docker-compose.yml/opt/docker/docker-compose.yml/srv/docker/docker-compose.yml$HOME/Docker/docker-compose.ymlOverride auto-detection:
scripts/patch-host-full.sh user@host /custom/path
# First time: configure credentials
cp scripts/patchmon-credentials.example.conf ~/.patchmon-credentials.conf
nano ~/.patchmon-credentials.conf
# Run automatic updates
scripts/patch-auto.sh
# Preview what would be updated
scripts/patch-auto.sh --dry-run
# Review output, then apply
scripts/patch-auto.sh
# Update packages only, even if Docker is detected
scripts/patch-auto.sh --skip-docker
scripts/patch-host-only.sh admin@webserver.example.com
scripts/patch-host-full.sh docker@app.example.com /home/docker/production
scripts/patch-multiple.sh production-servers.conf
Simply ask OpenClaw:
OpenClaw will use the automatic mode and report results.
cp scripts/patchmon-credentials.example.conf ~/.patchmon-credentials.confPATCHMON_CONFIG environment variable to custom locationcurl -k https://patchmon.example.com/api/healthsystemctl status patchmon-agent/etc/patchmon/config.ymlpatchmon-agent reportssh user@host sudo apt updatessh user@host echo OKscripts/patch-host-full.sh user@host /full/path/home/user/Docker, /opt/docker, /srv/dockerssh 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"For dashboard monitoring and scheduled patching, see references/patchmon-setup.md.
PatchMon provides:
apt, docker only)/etc/sudoers.d/ files (easier to manage)chmod 600 ~/.ssh/id_rsaThe scripts do NOT automatically reboot hosts. After updates:
ssh user@host "[ -f /var/run/reboot-required ] && echo YES || echo NO"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"
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":
When you say "Update my servers, excluding docker":
Important: Docker updates are included by default for maximum automation. Use "excluding docker" to skip container updates.
Target individual hosts without querying PatchMon:
OpenClaw will use the manual scripts for targeted updates.
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.
| 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.
共 1 个版本