lukasdietrich / systemd-telegram

Telegram notifications for systemd units

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

systemd-telegram - Telegram notifications for systemd units

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.

Requirements

Installation

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

Configuration

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.

Using --user units

To send notifications with --user units, you need to add the above bot secrets (or a new pair) to ~/.config/systemd-telegram/telegram.env.

Send notifications on failure

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

Send notifications on success

If you want to send notifications on success, too, add another line with OnSuccess instead of OnFailure. Successful executions do not include journal logs.

About

Telegram notifications for systemd units

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Shell 62.3%Language:Makefile 37.7%