mirror of
https://github.com/turtlebasket/env.git
synced 2026-03-04 11:34:27 -08:00
update ntfy scripts
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# ntfy-me — run any command, then send ntfy success/failure notification (via curl)
|
# ntfy-cmd — run any command, then send ntfy success/failure notification (via curl)
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# ntfy-me <command> [args...]
|
# ntfy-cmd <command> [args...]
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# ntfy-me make build
|
# ntfy-cmd make build
|
||||||
# ntfy-me bash -c "sleep 10 && false"
|
# ntfy-cmd bash -c "sleep 10 && false"
|
||||||
# ntfy-me ls /nonexistent
|
# ntfy-cmd ls /nonexistent
|
||||||
#
|
#
|
||||||
# Notes:
|
# Notes:
|
||||||
# - Requires $NTFY_ME_TOPIC set (e.g., mytopic)
|
# - Requires $NTFY_ME_TOPIC set (e.g., mytopic)
|
||||||
@@ -76,3 +76,4 @@ curl -fsS -X POST \
|
|||||||
"$NTFY_HOST/$NTFY_ME_TOPIC" >/dev/null 2>&1 || echo "Warning: failed to send ntfy notification" >&2
|
"$NTFY_HOST/$NTFY_ME_TOPIC" >/dev/null 2>&1 || echo "Warning: failed to send ntfy notification" >&2
|
||||||
|
|
||||||
exit $code
|
exit $code
|
||||||
|
|
||||||
36
scripts/ntfy-msg
Executable file
36
scripts/ntfy-msg
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# ntfy-msg — send a message to ntfy (via curl)
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ntfy-msg <message>
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# ntfy-msg "Build finished"
|
||||||
|
#
|
||||||
|
# Notes:
|
||||||
|
# - Requires $NTFY_ME_TOPIC set (e.g., mytopic)
|
||||||
|
# - Optional $NTFY_HOST (defaults to https://ntfy.sh)
|
||||||
|
|
||||||
|
set -u
|
||||||
|
|
||||||
|
if [ -z "${NTFY_ME_TOPIC:-}" ]; then
|
||||||
|
echo "Error: NTFY_ME_TOPIC environment variable not set."
|
||||||
|
echo "Set it like: export NTFY_ME_TOPIC=mytopic"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set default ntfy host if not provided
|
||||||
|
NTFY_HOST="${NTFY_HOST:-https://ntfy.sh}"
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "Usage: $0 <message>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
message="$*"
|
||||||
|
|
||||||
|
curl -fsS -X POST \
|
||||||
|
-d "$message" \
|
||||||
|
"$NTFY_HOST/$NTFY_ME_TOPIC" >/dev/null 2>&1 || echo "Warning: failed to send ntfy message" >&2
|
||||||
|
|
||||||
Reference in New Issue
Block a user