Skip to content

DeerHide/UnattendedUpgrades-slacknotify

Repository files navigation

Unattended Upgrades Slack Notifier

Parses unattended upgrade emails and sends Slack notifications.

Features

  • Email parsing for update status and package details
  • Slack notifications using Block Kit
  • Configurable mention rules for different update states
  • File input and stdin support

Setup

./scripts/setup.sh

Configuration

cp src/config.ini.sample config.ini

Edit config.ini:

[slack]
token = xoxb-your-actual-slack-token
channel = #your-channel
bot_username = UpdateBot

[system]
hostname = your-server-hostname
username = root

Environment variables: SLACK_TOKEN, SLACK_CHANNEL, HOSTNAME, USERNAME, BOT_USERNAME

Usage

File input:

python src/notifyslack.py /path/to/email.txt

Stdin:

cat email.txt | python src/notifyslack.py

Build

Two build options available:

Jinja2 templates for Ansible:

python build.py

Direct Python usage: Use the generated script directly without Ansible.

Postfix Integration

Configure unattended-upgrades to send emails to postfix:

  1. Edit /etc/apt/apt.conf.d/50unattended-upgrades:
Unattended-Upgrade::Mail "root@localhost";
  1. Configure postfix to pipe emails to the script:
# In /etc/postfix/master.cf
notifyslack unix - n n - - pipe
  flags=F user=root argv=/path/to/notifyslack.py
  1. Add transport rule in /etc/postfix/main.cf:
transport_maps = hash:/etc/postfix/transport
  1. Create /etc/postfix/transport:
root@localhost notifyslack:

Requirements

  • Python 3.10+
  • requests>=2.25.0

License

MIT

Generated documentation

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors