Some checks failed
CI / skip-ci-check (pull_request) Successful in 6s
CI / lint-and-test (pull_request) Failing after 9s
CI / ansible-validation (pull_request) Failing after 6s
CI / secret-scanning (pull_request) Successful in 5s
CI / dependency-scan (pull_request) Successful in 8s
CI / sast-scan (pull_request) Failing after 5s
CI / license-check (pull_request) Successful in 11s
CI / vault-check (pull_request) Failing after 6s
CI / playbook-test (pull_request) Failing after 6s
CI / container-scan (pull_request) Failing after 6s
CI / sonar-analysis (pull_request) Failing after 2s
CI / workflow-summary (pull_request) Successful in 4s
Document pve10 static IPs, monitoring stack, and site LXCs; add portfolio to inventory; Mailcow mailbox automation; vault import/export scripts; security audit guides and UniFi DHCP reference. Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
1.8 KiB
Bash
Executable File
67 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Configure Uptime Kuma SMTP notification (Mailcow) via Socket.IO API.
|
|
# Run from machine with network access to Kuma:
|
|
# export KUMA_URL=http://10.0.10.22:3001
|
|
# export KUMA_USER=admin
|
|
# export KUMA_PASSWORD='your-kuma-password'
|
|
# export SMTP_USER=alerts@levkine.ca
|
|
# export SMTP_PASS='mailbox-password'
|
|
# export SMTP_TO=idobkin@gmail.com
|
|
# pip install uptime-kuma-api
|
|
# ./scripts/kuma-setup-smtp.sh
|
|
|
|
set -euo pipefail
|
|
|
|
KUMA_URL="${KUMA_URL:-http://10.0.10.22:3001}"
|
|
KUMA_USER="${KUMA_USER:-admin}"
|
|
KUMA_PASSWORD="${KUMA_PASSWORD:-}"
|
|
SMTP_HOST="${SMTP_HOST:-mail.levkine.ca}"
|
|
SMTP_PORT="${SMTP_PORT:-587}"
|
|
SMTP_USER="${SMTP_USER:-alerts@levkine.ca}"
|
|
SMTP_PASS="${SMTP_PASS:-}"
|
|
SMTP_TO="${SMTP_TO:-idobkin@gmail.com}"
|
|
|
|
if [[ -z "${KUMA_PASSWORD}" || -z "${SMTP_PASS}" ]]; then
|
|
echo "Set KUMA_PASSWORD and SMTP_PASS" >&2
|
|
exit 1
|
|
fi
|
|
|
|
python3 <<'PY'
|
|
import os
|
|
import sys
|
|
|
|
try:
|
|
from uptime_kuma_api import UptimeKumaApi
|
|
except ImportError:
|
|
print("pip install uptime-kuma-api", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
url = os.environ["KUMA_URL"]
|
|
user = os.environ["KUMA_USER"]
|
|
password = os.environ["KUMA_PASSWORD"]
|
|
smtp_host = os.environ["SMTP_HOST"]
|
|
smtp_port = int(os.environ["SMTP_PORT"])
|
|
smtp_user = os.environ["SMTP_USER"]
|
|
smtp_pass = os.environ["SMTP_PASS"]
|
|
smtp_to = os.environ["SMTP_TO"]
|
|
|
|
with UptimeKumaApi(url) as api:
|
|
api.login(user, password)
|
|
# Notification type name in Kuma 1.x is often 'smtp' / 'email'
|
|
result = api.add_notification(
|
|
name="Mailcow alerts",
|
|
type="smtp",
|
|
isDefault=True,
|
|
applyExisting=True,
|
|
smtpHost=smtp_host,
|
|
smtpPort=smtp_port,
|
|
smtpSecure=True,
|
|
smtpIgnoreTLS=False,
|
|
smtpUsername=smtp_user,
|
|
smtpPassword=smtp_pass,
|
|
smtpFrom=smtp_user,
|
|
smtpTo=smtp_to,
|
|
)
|
|
print(result)
|
|
PY
|