Compare commits
7 Commits
testing
...
999d745710
| Author | SHA1 | Date | |
|---|---|---|---|
|
999d745710
|
|||
|
655e6fffac
|
|||
|
1ad726d0f7
|
|||
|
0d622723ac
|
|||
|
94e50e97e1
|
|||
|
13a7988ade
|
|||
|
80cd53f234
|
5
docker/.local/bin/docker
Executable file
5
docker/.local/bin/docker
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# SPDX-FileCopyrightText: 2025 Kris Lamoureux
|
||||||
|
# SPDX-License-Identifier: 0BSD
|
||||||
|
unset DOCKER_HOST
|
||||||
|
exec /usr/bin/docker "$@"
|
||||||
4
docker/.local/bin/podman
Executable file
4
docker/.local/bin/podman
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# SPDX-FileCopyrightText: 2025 Kris Lamoureux
|
||||||
|
# SPDX-License-Identifier: 0BSD
|
||||||
|
exec /usr/bin/docker --context podman "$@"
|
||||||
90
gotify/.local/bin/gotify
Executable file
90
gotify/.local/bin/gotify
Executable file
@@ -0,0 +1,90 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
USAGE="Usage: $0 [-v] <priority> <title> <message>"
|
||||||
|
VERBOSE=0
|
||||||
|
while getopts "hv" OPT; do
|
||||||
|
case "$OPT" in
|
||||||
|
h)
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
v)
|
||||||
|
VERBOSE=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
|
if [ $# -lt 3 ]; then
|
||||||
|
echo "[ERROR]: Missing required arguments"
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${GOTIFY_URL:-}" ] || [ -z "${GOTIFY_TOKEN:-}" ]; then
|
||||||
|
if [ -d ~/.config/gotify ] && [ -f ~/.config/gotify/env ]; then
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
. ~/.config/gotify/env
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
|
||||||
|
if [ "$VERBOSE" -eq 1 ]; then
|
||||||
|
echo "$RESPONSE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user