#!/usr/bin/env bash set -Eeuo pipefail PHASE="" STATUS="" ARTIFACT_DIR="" MESSAGE="" while [[ $# -gt 0 ]]; do case "$1" in --phase) PHASE="$2"; shift 2 ;; --status) STATUS="$2"; shift 2 ;; --artifact-dir) ARTIFACT_DIR="$2"; shift 2 ;; --message) MESSAGE="$2"; shift 2 ;; *) echo "Unknown argument: $1" >&2; exit 2 ;; esac done : "${TELEGRAM_BOT_TOKEN:?TELEGRAM_BOT_TOKEN is required in host-local env}" : "${TELEGRAM_CHAT_ID:?TELEGRAM_CHAT_ID is required in host-local env}" TEXT="[AWOOOI reboot-recovery] phase=${PHASE} status=${STATUS} ${MESSAGE} artifact=${ARTIFACT_DIR}" curl --fail --silent --show-error --max-time 10 \ --request POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \ --data-urlencode "chat_id=${TELEGRAM_CHAT_ID}" \ --data-urlencode "text=${TEXT}" >/dev/null