Parses unattended upgrade emails and sends Slack notifications.
- 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
./scripts/setup.shcp src/config.ini.sample config.iniEdit config.ini:
[slack]
token = xoxb-your-actual-slack-token
channel = #your-channel
bot_username = UpdateBot
[system]
hostname = your-server-hostname
username = rootEnvironment variables: SLACK_TOKEN, SLACK_CHANNEL, HOSTNAME, USERNAME, BOT_USERNAME
File input:
python src/notifyslack.py /path/to/email.txtStdin:
cat email.txt | python src/notifyslack.pyTwo build options available:
Jinja2 templates for Ansible:
python build.pyDirect Python usage: Use the generated script directly without Ansible.
Configure unattended-upgrades to send emails to postfix:
- Edit
/etc/apt/apt.conf.d/50unattended-upgrades:
Unattended-Upgrade::Mail "root@localhost";
- 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
- Add transport rule in
/etc/postfix/main.cf:
transport_maps = hash:/etc/postfix/transport
- Create
/etc/postfix/transport:
root@localhost notifyslack:
- Python 3.10+
- requests>=2.25.0
MIT
Generated documentation