PDA

View Full Version : HOW-TO: Send email notifications about the updates



smtalk
06-06-2008, 02:44 AM
If you want CustomBuild to send notifications about the updates you need to add a new file to /etc/cron.daily with the following content:


#!/bin/sh
cd /usr/local/directadmin/custombuild
./build update >/dev/null 2>&1
AVAIL_UPDATES="`./build versions | grep -c -e 'update is available.'`"
if [ "${AVAIL_UPDATES}" -gt 0 ]; then
./build versions | grep 'update is available.' | mail -s "${AVAIL_UPDATES} updates available for `hostname`" email@address.com
fi
exit 0;


Set bold=no in options.conf file.

jlandes
06-06-2008, 04:41 PM
This will be included into custombuild at some point, right? I thought I read you mentioning something about that. :) Thanks for all your hard work.

smtalk
06-07-2008, 09:14 AM
Yes, it should be included into CustomBuild 1.1.13.

Henrik
06-10-2008, 03:33 PM
Hello


When having enabled cron with "./build" it produces the file "/etc/cron.daily/custombuild" with the contents:


#!/bin/sh
cd /usr/local/directadmin/custombuild
./build update >/dev/null 2>&1
AVAIL_UPDATES="0"
if [ "" -gt 0 ]; then
./build versions | grep 'update is available.' | mail -s " updates running for server1.domain.com" email@domain.com

fi
exit 0;

When testing the script it gives this error:

/etc/cron.daily/custombuild: line 5: [: : integer expression expected

Ideas?

smtalk
06-11-2008, 08:31 AM
Hmh, firstly you need to change email@domain.com to your real email address. And running updates automatically is not recomended :) (but you can do that if you want) So, try "./build update" and change email@domain.com to your real email address and see if it works after "./build cron". Good luck!

Henrik
06-11-2008, 08:52 AM
Hi Martynas,



Hmh, firstly you need to change email@domain.com to your real email address. And running updates automatically is not recomended :) (but you can do that if you want) So, try "./build update" and change email@domain.com to your real email address and see if it works after "./build cron". Good luck!

I put in email@domain.com to not show my email-address, sorry about the confusion this created :p

I did a "./build update" today and then ran the cron-build once more, and voila; it worked (I think)! :D

Here is the output of the new script, without any updates made (and thus it is normal to not have the cron-run send out any updates via email, right?!);

/etc/cron.daily/custombuild
--08:46:40-- http://files.directadmin.com/services/custombuild/versions.txt
=> `/usr/local/directadmin/custombuild/versions.txt'
Resolving files.directadmin.com... 72.35.85.222
Connecting to files.directadmin.com|72.35.85.222|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2,391 (2.3K) [text/plain]

100%[=========================================================================================================================>] 2,391 --.--K/s

08:46:40 (84.45 MB/s) - `/usr/local/directadmin/custombuild/versions.txt' saved [2391/2391]

Weird though...

smtalk
06-11-2008, 09:04 AM
Yes, you are right, it won't send you emails until updates are available. I think you have autover=yes in your options.conf file, that's why you are getting output from it.

Henrik
06-11-2008, 09:07 AM
Yes, you are right, it won't send you emails until updates are available. I think you have autover=yes in your options.conf file, that's why you are getting output from it.

You are correct, Martynas. I will change that though, in order to save bandwidth for both myself and the DA-guys. (Especially since everything seem to work now)

So, the script will autoupdate all installed elements of custombuild without any admin interaction? (If I understood it correctly)

smtalk
06-11-2008, 09:14 AM
Right, but it's not recommended and set to "no" by default because updates can fail, e.g. if PHP update will fail then Apache service will be down. That's why notifications are recommended instead of updates :) But it's up to you what to use.

Henrik
06-11-2008, 09:17 AM
Right, but it's not recommended and set to "no" by default because updates can fail, e.g. if PHP update will fail then Apache service will be down. That's why notifications are recommended instead of updates :) But it's up to you what to use.

I understand, and you are once again correct. I think that I'll set it to "no" too in order to avoid breakdowns.

smtalk
06-11-2008, 01:22 PM
It won't show the output now if autover is set to yes :) Included suphp do "./build versions" and "./build update_versions" too.

Henrik
06-11-2008, 02:57 PM
It won't show the output now if autover is set to yes :) Included suphp do "./build versions" and "./build update_versions" too.

Noted and tested, thank you :)