-
Notifications
You must be signed in to change notification settings - Fork 11
/
sabnzbd.sh
32 lines (28 loc) · 864 Bytes
/
sabnzbd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# load env file from $NTFY_ENV or script dir
SCRIPTPATH=${NTFY_ENV:-$(dirname "$0")/.env}
[ -f ${SCRIPTPATH} ] && . "${SCRIPTPATH}" || echo "ENV missing: ${SCRIPTPATH}"
if [[ -n $ntfy_password && -n $ntfy_token ]]; then
echo "Use ntfy_username and ntfy_password OR ntfy_token"
exit 1
elif [ -n "$ntfy_password" ]; then
ntfy_base64=$( echo -n "$ntfy_username:$ntfy_password" | base64 )
ntfy_auth="Authorization: Basic $ntfy_base64"
elif [ -n "$ntfy_token" ]; then
ntfy_auth="Authorization: Bearer $ntfy_token"
else
ntfy_auth=""
fi
if [ "$1" == "warning" ]; then
ntfy_tag=warning
elif [ "$1" == "error" ]; then
ntfy_tag=rotating_light
else
ntfy_tag=information_source
fi
curl -H "$ntfy_auth" \
-H tags:$ntfy_tag \
-H "X-Title: $2" \
-H "X-Icon: $sabnzbd_ntfy_icon" \
-d "$3" \
--request POST "$ntfy_url/$sabnzbd_ntfy_topic"