Automatically Updating Ubuntu Linux including mail notification
Daniel Nashed – 7 January 2024 14:57:56
This was on my list for a while. I looked into it, but the mail part wasn't what I wanted.
Most admins will just install BSD mailx. But this had way too much dependencies for me.
I just wrote a simple tool to replace mailx -> https://github.com/nashcom/nsh-tools/tree/main/nshmailx.
But you could just continue to use the standard package.
It wasn't just an option for me, because I try to not install other mail server components on a Domino server (like sendmail).
The setup for automatic updates are pretty easy and base on scripting.
The packages which need to be installed are
apt install unattended-upgrades apt-listchanges
Once installed you can look into the configuration to see, which type of packages you want to install etc.
In my case I am staying with the standard package configuration.
You could also setup to report the machine once a reboot is needed.
I decided to keep that step manual and instead get e-mail notifications what got installed and if a reboot is needed.
In general the configuration is made in the following file
/etc/apt/apt.conf.d/50unattended-upgrades
To enable mail notification, you have to specify the recipient and in which case you want to receive a message in the configuration file.
Just for errors or whenever a package is updated.
Unattended-Upgrade::Mail "recipient@acme.com";
Unattended-Upgrade::MailReport "on-change";
Unattended-Upgrade::Sender "sender@host.acme.com";
Once you are done, configue unattended-updates
dpkg-reconfigure -plow unattended-upgrades
Test the configuration
A basic test without sending an e-mail would be invoked by the following command
unattended-upgrades --dry-run -v
Test including sending a mail
The dry run does not send a mail. The easiest way to test the mail functionality, just configure to always send a mail when unattended-updates runs.
Temporary change the following option:
Unattended-Upgrade::MailReport "always";
And run the update manually:
unattended-upgrades -v
- Comments [0]