Compare commits

...

2 Commits

Author SHA1 Message Date
13a7988ade Unset Podman's DOCKER_HOST when using Docker 2025-11-12 21:53:33 -05:00
80cd53f234 Add Gotify notification script 2025-11-09 22:01:23 -05:00
2 changed files with 64 additions and 0 deletions

3
docker/.local/bin/docker Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
unset DOCKER_HOST
exec /usr/bin/docker "$@"

61
gotify/.local/bin/gotify Executable file
View File

@@ -0,0 +1,61 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2025 Kris Lamoureux
# SPDX-License-Identifier: GPL-3.0-or-later
set -euo pipefail
for cmd in curl jq; do
if ! command -v "$cmd" &>/dev/null; then
echo "[ERROR]: $cmd is required but can't be found"
exit 1
fi
done
if [ $# -lt 3 ]; then
echo "[ERROR]: Missing required arguments"
echo "Usage: $0 <priority> <title> <message>"
exit 1
fi
if [ -z "$GOTIFY_URL" ]; then
echo "[ERROR]: GOTIFY_URL environment variable is not set"
exit 1
fi
if [ -z "$GOTIFY_TOKEN" ]; then
echo "[ERROR]: GOTIFY_TOKEN environment variable is not set"
exit 1
fi
PRIORITY="$1"
TITLE="$2"
MESSAGE="$3"
if ! echo "$PRIORITY" | grep -qE '^[0-9]+$'; then
echo "[ERROR]: Priority must be a number, got: $PRIORITY"
exit 1
fi
if ! PAYLOAD=$(
jq -nc \
--argjson priority "$PRIORITY" \
--arg title "$TITLE" \
--arg message "$MESSAGE" \
'{title: $title, message: $message, priority: $priority}'
); then
echo "[ERROR]: Error with input syntax"
exit 1
fi
if ! RESPONSE=$(
curl -sSf -X POST "$GOTIFY_URL/message" \
-H "X-Gotify-Key: $GOTIFY_TOKEN" \
-H "Content-Type: application/json" \
-d "$PAYLOAD"
); then
echo "[ERROR]: Couldn't send message to $GOTIFY_URL"
echo "$RESPONSE"
exit 1
fi
echo "$RESPONSE"
exit 0