[add] bark server file, notification on iPhone
This commit is contained in:
28
alert/bark/ciphertxt.sh
Normal file
28
alert/bark/ciphertxt.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Documentation: https://bark.day.app/#/encryption
|
||||
|
||||
set -e
|
||||
|
||||
# bark key
|
||||
deviceKey='PFEMc4eVAQutUrcAbXrVCb'
|
||||
# push payload
|
||||
# json='{"body": "test", "sound": "birdsong"}'
|
||||
json=`cat /opt/scripts/alert/bark/option.json`
|
||||
|
||||
# 必须32位
|
||||
key='sqCT9wE25eS2kMYu6BCGN4f9ymx2Fsmj'
|
||||
# IV可以是随机生成的,但如果是随机的就需要放在 iv 参数里传递。
|
||||
iv='QA475QXtg4YaGQzc'
|
||||
|
||||
# OpenSSL 要求输入的 Key 和 IV 需使用十六进制编码。
|
||||
key=$(printf $key | xxd -ps -c 200)
|
||||
iv=$(printf $iv | xxd -ps -c 200)
|
||||
|
||||
ciphertext=$(echo -n $json | openssl enc -aes-256-cbc -K $key -iv $iv | base64)
|
||||
|
||||
# 删除密文中的空格
|
||||
ciphertext=`echo $ciphertext | tr -d ' '`
|
||||
|
||||
# 密文可能有特殊字符,所以记得 URL 编码一下。
|
||||
curl --data-urlencode "ciphertext=$ciphertext" --data-urlencode "iv=QA475QXtg4YaGQzc" https://bark.erratic.eu.org/$deviceKey
|
Reference in New Issue
Block a user