Skip to content

Instantly share code, notes, and snippets.

@axi92
Created January 18, 2021 12:30
Show Gist options
  • Save axi92/52d4697e07fb6a03976caca52216072c to your computer and use it in GitHub Desktop.
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
#!/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
@axi92
Copy link
Author

axi92 commented Jan 18, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment