Add RuStore broadcast push script (secrets gitignored)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ captures/
|
||||
*.aab
|
||||
keystore.properties
|
||||
*.jks
|
||||
tools/.push.secrets
|
||||
23
tools/push.sh
Executable file
23
tools/push.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# Рассылка пуша всем подписчикам топика "aprsmap" (RuStore Push).
|
||||
# Использование: ./push.sh "Заголовок" "Текст"
|
||||
# project_id и service token читаются из tools/.push.secrets (в git не хранится).
|
||||
set -euo pipefail
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
[ -f "$DIR/.push.secrets" ] && . "$DIR/.push.secrets"
|
||||
|
||||
SERVICE_TOKEN="${SERVICE_TOKEN:-${SSP:-}}"
|
||||
PROJECT_ID="${PROJECT_ID:-}"
|
||||
|
||||
[ -n "$SERVICE_TOKEN" ] || { echo "SERVICE_TOKEN is not set" >&2; exit 1; }
|
||||
[ -n "$PROJECT_ID" ] || { echo "PROJECT_ID is not set" >&2; exit 1; }
|
||||
|
||||
title="${1:?usage: push.sh <title> <body>}"
|
||||
body="${2:-}"
|
||||
|
||||
curl -s -X POST \
|
||||
"https://vkpns-topics.rustore.ru/v1/projects/${PROJECT_ID}/topics/aprsmap/publish" \
|
||||
-H "Authorization: Bearer ${SERVICE_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"message\":{\"notification\":{\"title\":\"${title}\",\"body\":\"${body}\"}}}"
|
||||
echo
|
||||
Reference in New Issue
Block a user