#!/bin/sh
# {{ ansible_managed }}
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when apcupsd
# restores contact with the UPS (i.e. the serial connection is restored).
# We send an ntfy message to notify
#

message=$(/sbin/apcaccess status)

curl \
  -H "Title: [$(hostname)] - Communications with UPS restored" \
  -H "Priority: default" \
  -H "Tags: +1" \
  -d "$message" \
  {{ ntfy_url }}/{{ ntfy_topic }}

exit 0