[SOLVED] Email notification customization for Debian unattended-upgrades package
DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is there a way to customize unattended-upgrades email notifications, especially the subject part? I haven't found how so far...
Thanks in advance
Nobody can tell you, because you've included no useful information. unattended-upgrades email notifications tells us nothing. Are you talking about the OS? A package manager? A specific package? Self-hosted Wordpress? Try providing information and you might get an answer.
It's especially laughable that the first line of your signature asks people to Please be specific in your thread title & your question Try actually doing that in your posts.
^ You're right in substance but I'm not very sure there could be a possible confusion here as I can't see any reference to "OS, package manager, self-hosted Wordpress" named unattended-upgrades in the first results of any search engine...
Anyway, yes, let's be more specific: I'm talking in this thread about Debian/Ubuntu/... unattended-upgrades package
skimming through manpage and peaking at some of its installed files Nothing is jumping out at me that would change the subject line.
but I have only skimmed,
you could try
Code:
apt -s source apt-listchanges
#----^ simulate you we only after the git repo
clone the git, and see if you can see where it picks up the subject from.
might be overkill
but sometimes that is the quickest way
Nobody can tell you, because you've included no useful information. unattended-upgrades email notifications tells us nothing. Are you talking about the OS? A package manager? A specific package? Self-hosted Wordpress? Try providing information and you might get an answer.
Really?! The other replys in this thread indicate otherwise. This is the Debian forum and the OP clearly stated that this was for Debian. unattended-upgrades is a well established Debian package that works with APT.
Quote:
Originally Posted by TenTenths
It's especially laughable that the first line of your signature asks people to Please be specific in your thread title & your question Try actually doing that in your posts.
Not exactly. My perception is that apt-listchanges can be used in addition to unattended-upgrades so the user benefits from receiving last changelog/NEWS while upgrading his/her packages.
Both packages have their config files which specify the email configuration part.
Quote:
Originally Posted by Firerat
you could try
Code:
apt -s source apt-listchanges
#----^ simulate you we only after the git repo
clone the git, and see if you can see where it picks up the subject from.
might be overkill
but sometimes that is the quickest way
Clever but the downside is that any modification in source code won't survive after an apt-listchanges binary update.
A config file would be soo much handy!
Clever but the downside is that any modification in source code won't survive after an apt-listchanges binary update.
A config file would be soo much handy!
if there is a configuration option then yes, it would be handy
if not, create a new branch, make modifications.
when you get an update, rebase your modified branch against "upstream"
and if your modification adds this "new feature" cleanly you could submit a patch for upstream to adopt.
I had a look at the source - unattended-upgrade is a python script, and the subject seems hardcoded, with no option of overriding the format afaics.
Fairly trivial to change the script but yeah, it wouldn't survive updates.
Then again you could create a diff from the changes you made and apply it after every upgrade, I believe apt has hooks that allow that.
I wonder if it's worth the effort though.
here is one I use to remove compress from logrotate ( I have transparent compression on zfs )
Code:
DPkg::Post-Invoke {"echo checking logrotate;for i in /etc/logrotate.d/*;do if grep -q compress ${i};then echo removing compress option from ${i};sed -i '/compress/d' ${i};fi;done";}
the bit that defines the subject
Code:
apt -s source unattended-upgrades
Reading package lists... Done
NOTICE: 'unattended-upgrades' packaging is maintained in the 'Git' version control system at:
https://github.com/mvo5/unattended-upgrades.git
Please use:
git clone https://github.com/mvo5/unattended-upgrades.git
to retrieve the latest (possibly unreleased) updates to the package.
Code:
git clone https://github.com/mvo5/unattended-upgrades.git
cd unattended-upgrades
git grep -ni subject
outputs
Code:
COPYING:191:original licensor to copy, distribute or modify the Program subject to
debian/changelog:412: * Use fully qualified domain name in email subject.
debian/changelog:985: * Add [package on hold] to mail subject
debian/changelog:1417: - add the result of the upgrade to email subject, thanks to Yann 'Ze'
debian/changelog:1509: * use "mail -s" again to ensure there is a proper subject line when
test/test_mail.py:279:echo "Subject: $4" >> %(tmp)s/mail.txt
unattended-upgrade:1222:def _send_mail_using_mailx(from_address, to_address, subject, body):
unattended-upgrade:1232: [MAIL_BINARY, "-r", from_address, "-s", subject, to_address],
unattended-upgrade:1240:def _send_mail_using_sendmail(from_address, to_address, subject, body):
unattended-upgrade:1244: msg['Subject'] = subject
unattended-upgrade:1315: subject = _(
unattended-upgrade:1358: ret = _send_mail_using_sendmail(from_email, to_email, subject, body)
unattended-upgrade:1360: ret = _send_mail_using_mailx(from_email, to_email, subject, body)
line 1315 looks promising
Code:
1315 subject = _(
1316 "{hold_flag}{reboot_flag} unattended-upgrades result for "
1317 "{machine}: {result}").format(
1318 hold_flag=hold_flag_str, reboot_flag=reboot_flag_str,
1319 machine=host(), result="SUCCESS" if res else "FAILURE").strip()
that is the bit that needs to be modified
what do you want the subject to be?
Thank you very much Firerat and ondoho for your valuable answers. Nice thorough help
I will keep in mind your tip about apt source -s to identify the latest source code location!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.