Disclaimer: This project is not affiliated with systemd. The name may suggest it, but I just could not come up with something better.
This repository provides a script and systemd service to send notifications via Telegram after a unit completes.
The script, as well as a systemd service, can be installed
with the provided Makefile
.
You may need root privileges to execute the Makefile
.
As with everything coming from the internet, please review the files before
executing anything!
git clone https://github.com/lukasdietrich/systemd-telegram
cd systemd-telegram/
sudo make install
If you want to update, but not override the configuration, you can install only the script and systemd unit.
git pull
sudo make update
The Makefile
creates backups when overriding files. If you wish to change
that, you can set the BACKUP
variable.
See the documentation of install for further details.
sudo make update BACKUP=none
To send notifications via Telegram you need a bot token
and your
personal chat_id
. To create both, please see the documentation of the
BotFather.
Once obtained, both secrets need to be configured in
/usr/local/etc/systemd-telegram/telegram.env
.
To send notifications with --user
units, you need to add the above bot secrets
(or a new pair) to ~/.config/systemd-telegram/telegram.env
.
To send a notification on failure (including the journal logs), you must create a drop-in for the service in question.
systemctl edit my-service.service
# [Unit]
# OnFailure=systemd-telegram@%n.service
If you want to send notifications on success, too, add another line with
OnSuccess
instead of OnFailure
. Successful executions do not include journal
logs.