HOW-TO: Send email notifications about the updates

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
10,628
Location
LT, EU
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:
Code:
#!/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`" [B][email protected][/B]
fi
exit 0;

Set bold=no in options.conf file.
 
Yes, it should be included into CustomBuild 1.1.13.
 
Hello


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

Code:
#!/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 protected]

fi
exit 0;

When testing the script it gives this error:
Code:
/etc/cron.daily/custombuild: line 5: [: : integer expression expected

Ideas?
 
Hmh, firstly you need to change [email protected] 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 protected] to your real email address and see if it works after "./build cron". Good luck!
 
Hi Martynas,


Hmh, firstly you need to change [email protected] 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 protected] to your real email address and see if it works after "./build cron". Good luck!

I put in [email protected] 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?!);
Code:
/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...
 
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.
 
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)
 
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.
 
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.
 
It won't show the output now if autover is set to yes :) Included suphp do "./build versions" and "./build update_versions" too.
 
Back
Top