Files
buryan-infra/ops/sprint1/sprint2-textfix.sh

23 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
set -e
API_KEY=$(cat /root/.n8n_api)
WID="TSqu00NJx2JOrtoN"
curl -s -H "X-N8N-API-KEY: $API_KEY" http://192.168.1.108:5680/api/v1/workflows/$WID > /root/workflow-current.json
jq --rawfile text /tmp/tg-text.txt '{
name: .name,
nodes: [.nodes[] |
if .name == "Notify Telegram" then
.parameters.bodyParameters.parameters |= map(if .name == "text" then .value = $text else . end)
else del(.id) end],
connections: .connections,
settings: .settings
}' /root/workflow-current.json > /tmp/wf.json
curl -s -o /dev/null -w "PUT: %{http_code}\n" -X PUT \
-H "X-N8N-API-KEY: $API_KEY" -H "Content-Type: application/json" \
-d @/tmp/wf.json http://192.168.1.108:5680/api/v1/workflows/$WID
curl -s -X POST -H "X-N8N-API-KEY: $API_KEY" http://192.168.1.108:5680/api/v1/workflows/$WID/activate > /dev/null
echo "=== Тест текста ==="
curl -s -X POST http://192.168.1.108:5680/webhook/uptime-kuma -H "Content-Type: application/json" \
-d '{"monitor_name":"Проверка текста (998)","monitor_url":"https://text-fix.buryans.ru","heartbeat_status":"0","heartbeat_message":"ok","time":"'"$(date -Iseconds)"'"}'
echo