Update pushover script. Adjust scripts for new syntax.
This commit is contained in:
parent
f43a82d558
commit
2b800a5fcf
11 changed files with 246 additions and 124 deletions
|
|
@ -47,13 +47,17 @@ cp utils/pushover /opt/bin
|
||||||
chmod 755 /opt/bin/pushover
|
chmod 755 /opt/bin/pushover
|
||||||
|
|
||||||
# Decrypt the pushover-config.
|
# Decrypt the pushover-config.
|
||||||
echo "Decrypting /etc/pushover/pushover-config..."
|
echo "Decrypting /etc/pushover/*.gpg..."
|
||||||
gpg -d -o /etc/pushover/pushover-config /etc/pushover/pushover-config.gpg
|
read -r -p "Passphraise (appears in clear text): " PASS
|
||||||
chmod 640 /etc/pushover/pushover-config
|
gpg -d --passphrase "$PASS" -o /etc/pushover/backups /etc/pushover/backups.gpg
|
||||||
|
gpg -d --passphrase "$PASS" -o /etc/pushover/mirroring /etc/pushover/mirroring.gpg
|
||||||
|
gpg -d --passphrase "$PASS" -o /etc/pushover/server /etc/pushover/server.gpg
|
||||||
|
chmod 640 /etc/pushover/*
|
||||||
|
|
||||||
# Decrypt the netdata SSL key.
|
# Decrypt the netdata SSL key.
|
||||||
echo "Decrypting netdata SSL key..."
|
echo "Decrypting netdata SSL key..."
|
||||||
gpg -d -o /etc/certificates/_netdata_.opensourcerers.net-key.pem /etc/certificates/_netdata_.opensourcerers.net-key.pem.gpg
|
gpg -d --passphrase "$PASS" -o /etc/certificates/_netdata_.opensourcerers.net-key.pem /etc/certificates/_netdata_.opensourcerers.net-key.pem.gpg
|
||||||
chmod 640 /etc/certificates/_netdata_.opensourcerers.net-key.pem
|
chmod 640 /etc/certificates/_netdata_.opensourcerers.net-key.pem
|
||||||
chown root:36 /etc/certificates/_netdata_.opensourcerers.net-key.pem
|
chown root:36 /etc/certificates/_netdata_.opensourcerers.net-key.pem
|
||||||
rm -f /etc/certificates/_netdata_.opensourcerers.net-key.pem.gpg
|
rm -f /etc/certificates/_netdata_.opensourcerers.net-key.pem.gpg
|
||||||
|
unset PASS
|
||||||
|
|
|
||||||
4
base-files/.gitignore
vendored
4
base-files/.gitignore
vendored
|
|
@ -2,7 +2,9 @@
|
||||||
gshadow
|
gshadow
|
||||||
shadow
|
shadow
|
||||||
ssh/*_key
|
ssh/*_key
|
||||||
pubshover/pushover-config
|
pushover/backups
|
||||||
|
pushover/mirroring
|
||||||
|
pushover/server
|
||||||
|
|
||||||
# Temporary, backup, sample and dist files.
|
# Temporary, backup, sample and dist files.
|
||||||
*.swp
|
*.swp
|
||||||
|
|
|
||||||
BIN
base-files/pushover/backups.gpg
Normal file
BIN
base-files/pushover/backups.gpg
Normal file
Binary file not shown.
8
base-files/pushover/default
Normal file
8
base-files/pushover/default
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
user_key=
|
||||||
|
api_token=
|
||||||
|
device=
|
||||||
|
url=
|
||||||
|
url_title=
|
||||||
|
priority=
|
||||||
|
title=
|
||||||
|
sound=
|
||||||
2
base-files/pushover/mirroring.gpg
Normal file
2
base-files/pushover/mirroring.gpg
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
Œ
õ'§È±`Ò¹ž—‰)o 3?HÝÑïüOR΢J‰›^'ñoÐï‚ÐWYðµa¦/eùëæ—Ø¨ŽuSv
|
||||||
|
^ÈîJˆptMð<16>â,ÈÀK£³½ØÃûµÖ-Ín;h»Ø „–l]7ÄÀ1Oº„zoÍ\ÝÔõQ*+‘$çÝ€?žŸäÛ6ÆLÞ.î«÷jÎ4îæÊwÁWb‰l„œÑÈÈùw·—¦W§<MšÚ—pDÙq™u ÿL7<C2AD>0Ò€
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
Œ
ïâ<C3AF>3®åÖ`ÒÀº£aÅ[«¬µ»}ºdhÊU¡Ñþ!t vÕ<76>MSlP¬á…ïŽ:í'¾œë¹V¹h„pöõ ‹Sã>±
|
|
||||||
ÚdûJI<4A>
:å÷K΀PPzÝ)ãH`ä0é7ieæµ`SŸw^ÊZ"ŸÕ˜v¾œÐŽ<C390>—å¦F=÷ÔíeóQ…ÍÈ3¸k1å:kqªDªÂQYd*J•É!š'¾Å—ÂktT—K@üA<>l=¯?¬K¤)ƒyÍnC3Ð5>[ͯ„‹ÄÇè
|
|
||||||
1
base-files/pushover/server.gpg
Normal file
1
base-files/pushover/server.gpg
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Œ
ö“"t‡¨Ñ`ÒµL™‡?§ýÚ£µAøöçhË<>‘1ÿÈ”3¼‰3w^¸û/Ù¤ó)Uþ_ñ<>Kšåúa¨ñÃÜÑDzB¼üU—ÊNâZ{z± lS=Ó9Ýó{5Ø<35>Ik}§!8…štÊ<74>ó7l{xDb9”Ï—ÅAt>¨H+{ûÇm´XKú›–<E280BA>¹ƒ_¥x¦ÇΦw—Ó;ÐŽ<C390>Ás ÖÌ¡Ú)kªEW9Ó ˜GoB,i7‘Ùv!
|
||||||
|
|
@ -57,4 +57,4 @@ grep "^seeder:" /etc/passwd >/dev/null 2>&1 && su - seeder -c /home/seeder/start
|
||||||
}
|
}
|
||||||
|
|
||||||
# Notify that the server has booted.
|
# Notify that the server has booted.
|
||||||
/opt/bin/pushover -T "Successful boot up: ${HOSTNAME%%.*}" -p 1 -m "$(printf '%(%d %b %Y - %H:%M:%S)T')"
|
CONFIG_FILE="server" /opt/bin/pushover -T "Successful boot up: ${HOSTNAME%%.*}" -p 1 -m "$(printf '%(%d %b %Y - %H:%M:%S)T')"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# This script will be run when the system is shutdown or rebooted.
|
# This script will be run when the system is shutdown or rebooted.
|
||||||
|
|
||||||
# Notify that the server is shutting down.
|
# Notify that the server is shutting down.
|
||||||
/opt/bin/pushover -T "Shutting down: ${HOSTNAME%%.*}" -p 1 -m "$(printf '%(%d %b %Y - %H:%M:%S)T')"
|
CONFIG_FILE="server" /opt/bin/pushover -T "Shutting down: ${HOSTNAME%%.*}" -p 1 -m "$(printf '%(%d %b %Y - %H:%M:%S)T')"
|
||||||
|
|
||||||
# Stop containers.
|
# Stop containers.
|
||||||
[ -x /etc/rc.d/rc.lxc ] && /etc/rc.d/rc.lxc stop
|
[ -x /etc/rc.d/rc.lxc ] && /etc/rc.d/rc.lxc stop
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
|
|
||||||
readonly API_URL="https://api.pushover.net/1/messages.json"
|
readonly API_URL="https://api.pushover.net/1/messages.json"
|
||||||
readonly CONFIG_FILE="pushover-config"
|
readonly CONFIG_FILE="${CONFIG_FILE:-default}"
|
||||||
readonly DEFAULT_CONFIG="/etc/pushover/${CONFIG_FILE}"
|
readonly DEFAULT_CONFIG="/etc/pushover/${CONFIG_FILE}"
|
||||||
readonly USER_OVERRIDE="${HOME}/.pushover/${CONFIG_FILE}"
|
readonly USER_OVERRIDE="${HOME}/.pushover/${CONFIG_FILE}"
|
||||||
readonly EXPIRE_DEFAULT=180
|
readonly EXPIRE_DEFAULT=180
|
||||||
|
|
|
||||||
|
|
@ -1,124 +1,231 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# ./pushover.sh -t "Pushover via Bash" -m "Pushover message sent with bash from $(hostname -f)" -p1 -s siren -u http://www.google.com -n "Google"
|
|
||||||
|
|
||||||
USER_TOKEN="uscT77WKKzaNoLWXZDiBaECab3pE9z"
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
# YOUR APPS TOKENS / UPPERCASE NAME WITH _TOKEN (usage: "-a monitor" uses MONITOR_TOKEN)
|
readonly API_URL="https://api.pushover.net/1/messages.json"
|
||||||
SERVER_TOKEN="a484bt3qn6d78noowrik1rwhk3beuk"
|
readonly CONFIG_FILE="pushover-config"
|
||||||
#BACKUP_TOKEN=APP_TOKEN
|
readonly DEFAULT_CONFIG="/etc/pushover/${CONFIG_FILE}"
|
||||||
#ALERT_TOKEN=APP_TOKEN
|
readonly USER_OVERRIDE="${HOME}/.pushover/${CONFIG_FILE}"
|
||||||
APP_LIST="server" # FOR USAGE
|
readonly EXPIRE_DEFAULT=180
|
||||||
|
readonly RETRY_DEFAULT=30
|
||||||
|
HIDE_REPLY=true
|
||||||
|
|
||||||
# v1.6
|
showHelp()
|
||||||
# 12-03-2018 : Added image attachment
|
|
||||||
# 30-01-2016 : Added -getopts- arguments to set retry/expire
|
|
||||||
# 23-04-2015 : HTML markup language option
|
|
||||||
|
|
||||||
usage()
|
|
||||||
{
|
{
|
||||||
cat << EOF
|
local script=`basename "$0"`
|
||||||
|
echo "Send Pushover v1.2 scripted by Nathan Martini"
|
||||||
usage: $0 options
|
echo "Push notifications to your Android, iOS, or desktop devices"
|
||||||
|
echo
|
||||||
Send a notification via pushover.
|
echo "NOTE: This script requires an account at http://www.pushover.net"
|
||||||
|
echo
|
||||||
OPTIONS:
|
echo "usage: ${script} <-t|--token apikey> <-u|--user userkey> <-m|--message message> [options]"
|
||||||
-a Application name : "$APP_LIST" (required)
|
echo
|
||||||
-m Message (required)
|
echo " -t, --token APIKEY The pushover.net API Key for your application"
|
||||||
-t Title of your notification
|
echo " -u, --user USERKEY Your pushover.net user key"
|
||||||
-p Priority of your message : -2 (Silent), -1 (Quiet), 1 (High), 2 (Emergency)
|
echo " -m, --message MESSAGE The message to send; supports HTML formatting"
|
||||||
-s Sound (https://pushover.net/api#sounds)
|
echo " -a, --attachment filename The Picture you want to send"
|
||||||
-i Attach an image (up to 2.5mb)
|
echo " -T, --title TITLE Title of the message"
|
||||||
-u URL Link
|
echo " -d, --device NAME Comma seperated list of devices to receive message"
|
||||||
-n URL Title
|
echo " -U, --url URL URL to send with message"
|
||||||
-r Retry (seconds)
|
echo " --url-title URLTITLE Title of the URL"
|
||||||
-e Expire (seconds)
|
echo " -p, --priority PRIORITY Priority of the message"
|
||||||
-d Send to a specific device name
|
echo " -2 - no notification/alert"
|
||||||
|
echo " -1 - quiet notification"
|
||||||
-f HTML Format
|
echo " 0 - normal priority"
|
||||||
-x Debug
|
echo " 1 - bypass the user's quiet hours"
|
||||||
-h Show this message
|
echo " 2 - require confirmation from the user"
|
||||||
|
echo " -e, --expire SECONDS Set expiration time for notifications with priority 2 (default ${EXPIRE_DEFAULT})"
|
||||||
EOF
|
echo " -r, --retry COUNT Set retry period for notifications with priority 2 (default ${RETRY_DEFAULT})"
|
||||||
|
echo " -s, --sound SOUND Notification sound to play with message"
|
||||||
|
echo " pushover - Pushover (default)"
|
||||||
|
echo " bike - Bike"
|
||||||
|
echo " bugle - Bugle"
|
||||||
|
echo " cashregister - Cash Register"
|
||||||
|
echo " classical - Classical"
|
||||||
|
echo " cosmic - Cosmic"
|
||||||
|
echo " falling - Falling"
|
||||||
|
echo " gamelan - Gamelan"
|
||||||
|
echo " incoming - Incoming"
|
||||||
|
echo " intermission - Intermission"
|
||||||
|
echo " magic - Magic"
|
||||||
|
echo " mechanical - Mechanical"
|
||||||
|
echo " pianobar - Piano Bar"
|
||||||
|
echo " siren - Siren"
|
||||||
|
echo " spacealarm - Space Alarm"
|
||||||
|
echo " tugboat - Tug Boat"
|
||||||
|
echo " alien - Alien Alarm (long)"
|
||||||
|
echo " climb - Climb (long)"
|
||||||
|
echo " persistent - Persistent (long)"
|
||||||
|
echo " echo - Pushover Echo (long)"
|
||||||
|
echo " updown - Up Down (long)"
|
||||||
|
echo " none - None (silent)"
|
||||||
|
echo " -v, --verbose Return API execution reply to stdout"
|
||||||
|
echo
|
||||||
|
echo "EXAMPLES:"
|
||||||
|
echo
|
||||||
|
echo " ${script} -t xxxxxxxxxx -u yyyyyyyyyy -m \"This is a test\""
|
||||||
|
echo " Sends a simple \"This is a test\" message to all devices."
|
||||||
|
echo
|
||||||
|
echo " ${script} -t xxxxxxxxxx -u yyyyyyyyyy -m \"This is a test\" -T \"Test Title\""
|
||||||
|
echo " Sends a simple \"This is a test\" message with the title \"Test Title\" to all devices."
|
||||||
|
echo
|
||||||
|
echo " ${script} -t xxxxxxxxxx -u yyyyyyyyyy -m \"This is a test\" -d \"Phone,Home Desktop\""
|
||||||
|
echo " Sends a simple \"This is a test\" message to the devices named \"Phone\" and \"Home Desktop\"."
|
||||||
|
echo
|
||||||
|
echo " ${script} -t xxxxxxxxxx -u yyyyyyyyyy -m \"This is a test\" -U \"http://www.google.com\" --url-title Google"
|
||||||
|
echo " Sends a simple \"This is a test\" message to all devices that contains a link to www.google.com titled \"Google\"."
|
||||||
|
echo
|
||||||
|
echo " ${script} -t xxxxxxxxxx -u yyyyyyyyyy -m \"This is a test\" -p 1"
|
||||||
|
echo " Sends a simple \"This is a test\" high priority message to all devices."
|
||||||
|
echo
|
||||||
|
echo " ${script} -t xxxxxxxxxx -u yyyyyyyyyy -m \"This is a test\" -s bike"
|
||||||
|
echo " Sends a simple \"This is a test\" message to all devices that uses the sound of a bike bell as the notification sound."
|
||||||
|
echo
|
||||||
|
echo " ${script} -t xxxxxxxxxx -u yyyyyyyyyy -m \"This is a test Pic\" -a /path/to/pic.jpg"
|
||||||
|
echo " Sends a simple \"This is a test Pic\" message to all devices and send the Picture with the message."
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
# FIXME: Missing date setting from options - see:
|
|
||||||
# https://pushover.net/api
|
|
||||||
|
|
||||||
APP_ID=
|
curl --version > /dev/null 2>&1 || { echo "This script requires curl; aborting."; echo; exit 1; }
|
||||||
TITLE=
|
|
||||||
URL=
|
|
||||||
URL_TITLE=
|
|
||||||
PRIORITY=0
|
|
||||||
RETRY=60
|
|
||||||
EXPIRE=86400
|
|
||||||
SOUND="pushover"
|
|
||||||
HTML=0
|
|
||||||
MESSAGE=
|
|
||||||
DEVICE=
|
|
||||||
IMAGE=
|
|
||||||
|
|
||||||
while getopts “hfret:u:n:p:s:m:a:d:i:x” OPTION
|
if [ -f ${DEFAULT_CONFIG} ]; then
|
||||||
|
source ${DEFAULT_CONFIG}
|
||||||
|
fi
|
||||||
|
if [ -f ${USER_OVERRIDE} ]; then
|
||||||
|
source ${USER_OVERRIDE}
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case "${1:-}" in
|
||||||
t) TITLE=$OPTARG ;;
|
-t|--token)
|
||||||
u) URL=$OPTARG ;;
|
api_token="${2:-}"
|
||||||
n) URL_TITLE=$OPTARG ;;
|
shift
|
||||||
p) PRIORITY=$OPTARG ;;
|
|
||||||
s) SOUND=$OPTARG ;;
|
|
||||||
f) HTML=1 ;;
|
|
||||||
r) [ ! -z $OPTARG ] && RETRY=$OPTARG ;;
|
|
||||||
e) [ ! -z $OPTARG ] && EXPIRE=$OPTARG ;;
|
|
||||||
d) DEVICE=$OPTARG ;;
|
|
||||||
i) IMAGE="$OPTARG" ;;
|
|
||||||
a)
|
|
||||||
APP_ID=`echo $OPTARG | tr '[:lower:]' '[:upper:]'`
|
|
||||||
APP_NAME="$APP_ID""_TOKEN"
|
|
||||||
APP_TOKEN=${!APP_NAME}
|
|
||||||
;;
|
;;
|
||||||
m) MESSAGE=$OPTARG ;;
|
|
||||||
x)
|
-u|--user)
|
||||||
echo "TITLE ...... "$TITLE
|
user_key="${2:-}"
|
||||||
echo "URL ........ "$URL
|
shift
|
||||||
echo "URL TITLE .. "$URL_TITLE
|
;;
|
||||||
echo "PRIORITY ... "$PRIORITY
|
|
||||||
echo "SOUND ...... "$SOUND
|
-m|--message)
|
||||||
echo "MESSAGE .... "$MESSAGE
|
message="${2:-}"
|
||||||
echo "DEVIC ...... "$DEVICE
|
shift
|
||||||
echo "IMAGE ..... "$IMAGE
|
;;
|
||||||
echo "APP ID ..... "$APP_ID
|
|
||||||
echo "APP TOKEN .. "$APP_TOKEN
|
-a|--attachment)
|
||||||
exit 0
|
attachment="${2:-}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-T|--title)
|
||||||
|
title="${2:-}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-d|--device)
|
||||||
|
device="${2:-}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-U|--url)
|
||||||
|
url="${2:-}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
--url-title)
|
||||||
|
url_title="${2:-}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-p|--priority)
|
||||||
|
priority="${2:-}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-s|--sound)
|
||||||
|
sound="${2:-}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-e|--expire)
|
||||||
|
expire="${2:-}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-r|--retry)
|
||||||
|
retry="${2:-}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-v|--verbose)
|
||||||
|
unset HIDE_REPLY
|
||||||
|
;;
|
||||||
|
|
||||||
|
-h|--help)
|
||||||
|
showHelp
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
;;
|
;;
|
||||||
:) echo "Option -$OPTARG requires an argument." >&2; exit 1 ;;
|
|
||||||
h) usage; exit 1 ;;
|
|
||||||
?) usage; exit ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z $MESSAGE ]] || [[ -z $APP_TOKEN ]]; then
|
if [ $priority -eq 2 ]; then
|
||||||
echo -e "\n\\033[31mMessage and Application token are required.\\033[0m"
|
if [ -z "${expire:-}" ]; then
|
||||||
usage
|
expire=${EXPIRE_DEFAULT}
|
||||||
|
fi
|
||||||
|
if [ -z "${retry:-}" ]; then
|
||||||
|
retry=${RETRY_DEFAULT}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${api_token:-}" ]; then
|
||||||
|
echo "-t|--token must be set"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#curl -s \
|
if [ -z "${user_key:-}" ]; then
|
||||||
#curl \
|
echo "-u|--user must be set"
|
||||||
# -F "token=$APP_TOKEN" \
|
exit 1
|
||||||
# -F "user=$USER_TOKEN" \
|
fi
|
||||||
# -F "title=$TITLE" \
|
|
||||||
# -F "url=$URL" \
|
|
||||||
# -F "url_title=$URL_TITLE" \
|
|
||||||
# -F "priority=$PRIORITY" \
|
|
||||||
# -F "device=$DEVICE" \
|
|
||||||
# -F "attachment=@${IMAGE}" \
|
|
||||||
# -F "retry=$RETRY" \
|
|
||||||
# -F "expire=$EXPIRE" \
|
|
||||||
# -F "sound=$SOUND" \
|
|
||||||
# -F "html=$HTML" \
|
|
||||||
# -F "message=$MESSAGE" \
|
|
||||||
# https://api.pushover.net/1/messages.json
|
|
||||||
|
|
||||||
# This is the same as the curl above (except for attachment=), but actually works.
|
if [ -z "${message:-}" ]; then
|
||||||
wget --hsts-file=/dev/null --no-check-certificate --hsts-file /dev/null --post-data \
|
echo "-m|--message must be set"
|
||||||
"token=$APP_TOKEN&user=$USER_TOKEN&title=$TITLE&url=$URL&url_title=$URL_TITLE&priority=$PRIORITY&device=$DEVICE&retry=$RETRY&expire=$EXPIRE&sound=$SOUND&html=$HTML&message=$MESSAGE" \
|
exit 1
|
||||||
-O - https://api.pushover.net/1/messages.json 2>/dev/null
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "${attachment:-}" ] && [ ! -f "${attachment}" ]; then
|
||||||
|
echo "${attachment} not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${attachment:-}" ]; then
|
||||||
|
json="{\"token\":\"${api_token}\",\"user\":\"${user_key}\",\"message\":\"${message}\""
|
||||||
|
if [ "${device:-}" ]; then json="${json},\"device\":\"${device}\""; fi
|
||||||
|
if [ "${title:-}" ]; then json="${json},\"title\":\"${title}\""; fi
|
||||||
|
if [ "${url:-}" ]; then json="${json},\"url\":\"${url}\""; fi
|
||||||
|
if [ "${url_title:-}" ]; then json="${json},\"url_title\":\"${url_title}\""; fi
|
||||||
|
if [ "${priority:-}" ]; then json="${json},\"priority\":${priority}"; fi
|
||||||
|
if [ "${expire:-}" ]; then json="${json},\"expire\":${expire}"; fi
|
||||||
|
if [ "${retry:-}" ]; then json="${json},\"retry\":${retry}"; fi
|
||||||
|
if [ "${sound:-}" ]; then json="${json},\"sound\":\"${sound}\""; fi
|
||||||
|
json="${json}}"
|
||||||
|
|
||||||
|
curl -s ${HIDE_REPLY:+ -o /dev/null} -H "Content-Type: application/json" -d "${json}" "${API_URL}" ${HIDE_REPLY:+ > /dev/null} 2>&1
|
||||||
|
else
|
||||||
|
curl -s ${HIDE_REPLY:+ -o /dev/null} \
|
||||||
|
--form-string "token=${api_token}" \
|
||||||
|
--form-string "user=${user_key}" \
|
||||||
|
--form-string "message=${message}" \
|
||||||
|
--form "attachment=@${attachment}" \
|
||||||
|
${priority:+ --form-string "priority=${priority}"} \
|
||||||
|
${sound:+ --form-string "sound=${sound}"} \
|
||||||
|
${device:+ --form-string "device=${device}"} \
|
||||||
|
${title:+ --form-string "title=${title}"} \
|
||||||
|
"${API_URL}" ${HIDE_REPLY:+ > /dev/null} 2>&1
|
||||||
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue