]> git.proxmox.com Git - mirror_acme.sh.git/blob - notify/bark.sh
the envs are moved to acmetest
[mirror_acme.sh.git] / notify / bark.sh
1 #!/usr/bin/env sh
2
3 #Support iOS Bark Notification
4
5 #BARK_API_URL="https://api.day.app/xxxx"
6 #BARK_SOUND="yyyy"
7 #BARK_GROUP="zzzz"
8
9 # subject content statusCode
10 bark_send() {
11 _subject="$1"
12 _content="$2"
13 _statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
14 _debug "_subject" "$_subject"
15 _debug "_content" "$_content"
16 _debug "_statusCode" "$_statusCode"
17
18 BARK_API_URL="${BARK_API_URL:-$(_readaccountconf_mutable BARK_API_URL)}"
19 if [ -z "$BARK_API_URL" ]; then
20 BARK_API_URL=""
21 _err "You didn't specify a Bark API URL BARK_API_URL yet."
22 _err "You can download Bark from App Store and get yours."
23 return 1
24 fi
25 _saveaccountconf_mutable BARK_API_URL "$BARK_API_URL"
26
27 BARK_SOUND="${BARK_SOUND:-$(_readaccountconf_mutable BARK_SOUND)}"
28 _saveaccountconf_mutable BARK_SOUND "$BARK_SOUND"
29
30 BARK_GROUP="${BARK_GROUP:-$(_readaccountconf_mutable BARK_GROUP)}"
31 if [ -z "$BARK_GROUP" ]; then
32 BARK_GROUP="ACME"
33 _info "The BARK_GROUP is not set, so use the default ACME as group name."
34 else
35 _saveaccountconf_mutable BARK_GROUP "$BARK_GROUP"
36 fi
37
38 _content=$(echo "$_content" | _url_encode)
39 _subject=$(echo "$_subject" | _url_encode)
40
41 response="$(_get "$BARK_API_URL/$_subject/$_content?sound=$BARK_SOUND&group=$BARK_GROUP")"
42
43 if [ "$?" = "0" ] && _contains "$response" "success"; then
44 _info "Bark API fired success."
45 return 0
46 fi
47
48 _err "Bark API fired error."
49 _err "$response"
50 return 1
51 }