Created
January 18, 2021 12:30
-
-
Save axi92/52d4697e07fb6a03976caca52216072c to your computer and use it in GitHub Desktop.
Send hostname and ip from device via telegram bot to channel or user
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 | |
TEXT="Hostname: $(hostname) - IP: $(hostname -I | awk '{print $1}')" | |
CHATID="" | |
TOKEN="" | |
curl -s -X POST \ | |
-H 'Content-Type: application/json' \ | |
-d '{"chat_id": "'"${CHATID}"'", "text": "'"${TEXT}"'", "disable_notification": false}' \ | |
https://api.telegram.org/bot${TOKEN}/sendMessage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For crontab at reboot, sleep for some delay that the host can get the network connection
@reboot sleep 30 && bash /path/to/script/report-ip-to-telegram-bot.sh