LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Email notification customization for Debian unattended-upgrades package (https://www.linuxquestions.org/questions/debian-26/email-notification-customization-for-debian-unattended-upgrades-package-4175660439/)

l0f4r0 09-06-2019 06:29 AM

Email notification customization for Debian unattended-upgrades package
 
Hi,

Is there a way to customize email notifications for Debian unattended-upgrades package, especially the subject part? I haven't found how so far...

Thanks in advance :)

TenTenths 09-06-2019 07:33 AM

Quote:

Originally Posted by l0f4r0 (Post 6033788)
Hi,

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.

l0f4r0 09-06-2019 08:08 AM

^ 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

NB: I've edited my OP to be crystal-clear.

Firerat 09-06-2019 08:28 AM

unattended-upgrades uses apt-listchanges for the mail side if things

https://wiki.debian.org/UnattendedUp...pt-listchanges

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 :D

evo2 09-10-2019 09:04 PM

Hello,
Quote:

Originally Posted by TenTenths (Post 6033811)
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 (Post 6033811)
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.

The OP was very specific.

Evo2.

ondoho 09-12-2019 01:50 AM

Strangely, unattended-upgrades email notifications seems to yield plenty of relevant-looking results...

Firerat 09-12-2019 02:02 AM

Quote:

Originally Posted by ondoho (Post 6035928)
Strangely, unattended-upgrades email notifications seems to yield plenty of relevant-looking results...

do any detail changes to the subject?

l0f4r0 11-11-2019 04:42 PM

Quote:

Originally Posted by Firerat (Post 6033830)
unattended-upgrades uses apt-listchanges for the mail side if things
https://wiki.debian.org/UnattendedUp...pt-listchanges

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 (Post 6033830)
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 :D

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! :)

Quote:

Originally Posted by ondoho (Post 6035928)
Strangely, unattended-upgrades email notifications seems to yield plenty of relevant-looking results...

I've seen nothing about email subject modification though...

Firerat 11-11-2019 06:01 PM

Quote:

Originally Posted by l0f4r0 (Post 6056562)
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.

this is the way of FOSS

ondoho 11-12-2019 01:03 AM

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.

Firerat 11-12-2019 01:46 AM

indeed

in /etc/apt/apt.conf.d/

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?

l0f4r0 11-18-2019 03:38 PM

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!


All times are GMT -5. The time now is 02:22 PM.