#!/usr/bin/env bash # welcomebot-logs — print logs for the yttrx-welcomebot container (welcome + abuse bot). # # Installed at /usr/local/bin/welcomebot-logs on admin.yttrx.com. # Source of truth: ~/yttrx-welcomebot/bin/welcomebot-logs (workstation). # Run as root (how `ssh admin.yttrx.com` logs in); needs Docker access. set -euo pipefail CONTAINER="${WELCOMEBOT_CONTAINER:-yttrx-welcomebot}" tail_n=200 follow=0 since="" pattern="" usage() { cat <&2; usage >&2; exit 2 ;; esac shift done if ! command -v docker >/dev/null 2>&1; then echo "welcomebot-logs: docker not found in PATH" >&2; exit 1 fi if ! docker inspect "$CONTAINER" >/dev/null 2>&1; then echo "welcomebot-logs: container '$CONTAINER' not found (is it deployed/running?)" >&2; exit 1 fi args=(logs --tail "$tail_n") [ "$follow" -eq 1 ] && args+=(--follow) [ -n "$since" ] && args+=(--since "$since") # docker logs writes app output to stdout+stderr; merge then optionally filter. if [ -n "$pattern" ]; then docker "${args[@]}" "$CONTAINER" 2>&1 | grep -E --line-buffered -- "$pattern" || true else docker "${args[@]}" "$CONTAINER" 2>&1 fi