Advertisement
xangin

earthquake notify shell script by Synology Chat

Oct 13th, 2024
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.86 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #記得要先在configuration.yaml做以下設定讓tmp可對外才行唷!!
  4. #homeassistant:  
  5. #  allowlist_external_dirs:
  6. #    - "/tmp"
  7.  
  8. #修改成自己HA的IP:PORT,注意等號左右不能有空格唷!!
  9. DST=http://192.168.1.123:8123
  10.  
  11. #Synology Chat source,網址記得去掉s並改用http的port,注意網址前後要用"符號包起來唷!!
  12. SYNOCHAT_SOURCE="http://192.168.1.100:5000/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=XXXXXXXXXXXXX"
  13.  
  14. #通知內容
  15. msg="警告!!芮氏規模$1的地震,將於$2秒後到達!!"
  16.  
  17. #截圖指令
  18. VNC=:0 gnome-screenshot -w -f /config/www/tmp/OX.png
  19.  
  20. #發送Synology Chat通知
  21. curl -X POST \
  22.   -d "payload={ \"text\":\" $msg \", \"file_url\":\"$DST/local/tmp/OX.png\" }" \
  23.   $SYNOCHAT_SOURCE  
  24.      
  25. #等待1秒
  26. sleep 1s
  27.  
  28. #刪除截圖
  29. rm -f /config/www/tmp/OX.png
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement