This is a program which can notify a User via Telegram about Ubuntu Server upgrades. It use command apt list --upgradeable
for determine new package updates.
The program is written in go.
(Currently in development)
You need to create an telegram Bot to get an API-Key. For creating a Bot do following steps:
- Open with Telegram bot https://t.me/@BotFather
- Type
/newbot
and follow instructions to create a bot - Now you will recieve an Telegram bot API Token.
- Download and Upload program to your Ubuntu Server. You find it under Releases (Check your ARM architecture with
dpkg --print-architecture
) - Untar it:
tar -xvzf telegram-server-update-bot_x.y.z_Linux_amd64.tar.g
- Make it executeable:
chmod +x telegram-server-update-bot
- Place it on the server in a location you like. For example
/home/<<userdir>>/telegram-server-update-bot
- Create an config yaml
/home/<<userdir>>/.telegram-server-update-bot.yaml
(If it is in same directory as script, it should be found automatically)
BotAPIToken: "YOUR_TELEGRAM_API_TOKEN"
- Start program on your Server in setup mode:
./telegram-server-update-bot botsetup
- Open now your own Telegram bot with the Telegram-App and send command
/getchatid
- You should recieve now the chatid
- On your Server stop program with keyboard shortcut
CTRL+C
- Extend now the config with the chatUserID
BotAPIToken: "YOUR_TELEGRAM_API_TOKEN"
ChatUserID: "YOUR_CHAT_USER_ID"
To get now notified about new package updates, you could run the script periodically via cron.
For example you could check for updates every day at 6pm (Use crontab -e
for adding a cron entry):
0 18 * * * /home/<<userdir>>/telegram-server-update-bot update-check
It is possible to use the same API Token on multiple Ubuntu servers. So you get notified for more than one server. To see which server has the update, add following configuration to your yaml file:
ServerName: "My Awesome Server"
This name will be used as title in each message. If no ServerName is set. It will use as name Server
.
If you now on each server put an different server name in the config, you can tell them apart insite the Telegram Chat.
You could place the yaml configuration file whereever you want. If it is another location than the same directory where the script is located,
you could run the program with the option --config
and provide custom location to config file.
For example if you want to place the config in /etc/
/path/to/telegram-server-update-bot update-check --config /etc/telegram-server-update-bot.yaml
With this comand you could test if you would recieve an message to your telegram client. You could also send an custom Message.
Following command will send the message "This is my custom Message" to the Bot. If you do not add any custom message, it will send an default one.
/path/to/telegram-server-update-bot testmessage This is my custom Message
The command and every sub command has an help option. Just add option -h
or --help