Created
August 5, 2024 09:31
-
-
Save at-wr/fa6e9863c1415d413f0429e088a1ef7f to your computer and use it in GitHub Desktop.
Notify via Telegram Bot if mount point doesn't exist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Telegram Bot API Token | |
| API_TOKEN="YOUR_TELEGRAM_BOT_API_TOKEN" | |
| # Your Chat ID | |
| CHAT_ID="YOUR_CHAT_ID" | |
| # API Proxy Domain (optional) | |
| API_PROXY_DOMAIN="YOUR_API_PROXY_DOMAIN" | |
| # Mount Path | |
| MOUNT_POINT="/mnt/example" | |
| if ! mountpoint -q $MOUNT_POINT; then | |
| MESSAGE="Disk at $MOUNT_POINT has been disconnected!" | |
| if [ -z "$API_PROXY_DOMAIN" ]; then | |
| API_URL="https://api.telegram.org" | |
| else | |
| API_URL="https://$API_PROXY_DOMAIN" | |
| fi | |
| curl -s -X POST "$API_URL/bot$API_TOKEN/sendMessage" -d chat_id=$CHAT_ID -d text="$MESSAGE" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment