Blueprints · Systemd & Agents
Beginner
15 min · PortGate
PortGate agent and dead-man cron wrapper
Installs the PortGate agent with --mode all and writes a wrapper that posts to your webhook when a wrapped cron command exits non-zero. The token needs server, AI telemetry, and malware abilities.
Live config
Baked-in protections
- The agent is the same installer used on the host page
- --mode all needs all three token abilities
- The wrapper alerts only after a non-zero exit
- A successful job does not send the failure payload
Step 1 · bash
Install the agent
/root/portgate-blueprints/agent-install.sh
Uses --mode all. Create the token with server, AI, and malware abilities or the malware scan posts will be rejected.
#!/bin/sh set -eu curl -fsSL "https://example.com/downloads/install.sh" | sh -s -- --token "paste-from-dashboard" --mode all --url "https://example.com"
Step 2 · bash
Dead-man wrapper
/root/portgate-blueprints/deadman-install.sh
Usage: portgate-deadman job-name -- /path/to/job. The webhook is skipped while it is still the example URL.
#!/bin/sh
set -eu
cat > /usr/local/sbin/portgate-deadman <<'EOF'
#!/bin/sh
NAME="$1"
shift
if [ "${1:-}" = "--" ]; then
shift
fi
"$@"
STATUS="$?"
if [ "$STATUS" -eq 0 ]; then
exit 0
fi
if [ "https://example.com/hooks/portgate" != "https://example.com/hooks/portgate" ]; then
curl -fsS -m 15 -H "Content-Type: application/json" -d "{\"text\":\"PortGate job failed: ${NAME} status ${STATUS}\"}" "https://example.com/hooks/portgate" || true
fi
exit "$STATUS"
EOF
chmod 755 /usr/local/sbin/portgate-deadman
Step 3 · conf
Example cron
/root/portgate-blueprints/deadman-cron.example
Copy the line into /etc/cron.d after the wrapped command exists. This file is not installed into cron.
0 3 * * * root /usr/local/sbin/portgate-deadman nightly-backup -- /root/portgate-blueprints/backup.sh