| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #!/usr/bin/env bash
- # ------------------------------------------------------------------
- # WeCom Center — one-step installer for a new Zabbix frontend
- #
- # Usage:
- # ./install.sh # auto-detect a running zabbix-* web container
- # ./install.sh /path/to/modules# copy into a plain (non-docker) modules dir
- #
- # After this script finishes, open Zabbix -> Administration -> Modules,
- # press "Scan directory", then Enable "WecomCenter". Then open the
- # WeCom Center page and use the "First-time setup / Initialise" button.
- # ------------------------------------------------------------------
- set -euo pipefail
- HERE="$(cd "$(dirname "$0")" && pwd)"
- SRC="$HERE/WecomCenter"
- if [ ! -d "$SRC" ]; then
- echo "ERROR: WecomCenter folder not found next to install.sh" >&2
- exit 1
- fi
- if [ $# -ge 1 ]; then
- DEST="$1"
- mkdir -p "$DEST"
- rm -rf "$DEST/WecomCenter"
- cp -r "$SRC" "$DEST/WecomCenter"
- echo "OK: copied to $DEST/WecomCenter"
- else
- C="$(docker ps --format '{{.Names}}' 2>/dev/null | grep -iE 'zabbix.*(web|nginx|apache|frontend)' | head -n1 || true)"
- if [ -z "$C" ]; then
- echo "ERROR: no running Zabbix frontend container detected." >&2
- echo " Pass the modules directory explicitly, e.g.: ./install.sh /opt/zabbix/zabbix-server/web-modules" >&2
- exit 1
- fi
- docker cp "$SRC" "$C:/usr/share/zabbix/modules/"
- docker exec "$C" sh -c 'chown -R www-data:www-data /usr/share/zabbix/modules/WecomCenter 2>/dev/null || true'
- echo "OK: copied into container '$C' -> /usr/share/zabbix/modules/WecomCenter"
- fi
- echo
- echo "Next steps:"
- echo " 1) Zabbix -> Administration -> Modules -> 'Scan directory' -> Enable 'WecomCenter'"
- echo " 2) Open 'WeCom Center' -> First-time setup -> paste your group-robot key -> Initialise"
- echo " (it creates the media type, robot user, trigger action and {\$WECOM_KEY} macro)"
|