Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Get notify email if updates available for your server
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
blu3bird
Retired Dev
Retired Dev


Joined: 04 Oct 2003
Posts: 612
Location: Munich, Germany

PostPosted: Sat Jan 07, 2006 1:05 pm    Post subject: Get notify email if updates available for your server Reply with quote

Hi,

checking the output of emerge -uDp world manually every time was boring so i wrote this little scripts(quite dirty ;))

it will send a mail if there are any updates avilable for your system.

Code:
#!/bin/sh

##configuration
mail_from="update-notification@your-server.com"
mail_to="you@isp.com"
mail_subject="updates are available for $(hostname).$(domainname)!"
##will be translated to $count $mail_subject

##synchronize portage
emerge --sync 2&>/dev/null

##check if there's anything todo
list=$(emerge -uDp world | grep ebuild)

if [ -n "$list" ]; then
        ##we have 1 or more ebuilds waiting for an update

        echo "$list" > /tmp/update-mail
        update_count=$(cat /tmp/update-mail | wc -l)

        echo "Subject: $update_count $mail_subject" > /tmp/update-mail
        echo "Available updates:" >> /tmp/update-mail
        echo "$list" >> /tmp/update-mail
        echo "" >> /tmp/update-mail
        echo "Please update soon." >> /tmp/update-mail
        echo "." >> /tmp/update-mail

        sendmail -f$mail_from $mail_to < /tmp/update-mail
        rm /tmp/update-mail
fi
Back to top
View user's profile Send private message
!equilibrium
Bodhisattva
Bodhisattva


Joined: 06 Jun 2004
Posts: 2109
Location: MI/BG/LC

PostPosted: Sat Jan 07, 2006 1:35 pm    Post subject: Reply with quote

thank you for the script.
if i can suggest, use 'emerge -q sync' instead of 'emerge --sync'.
with the '-q' option, the emerge process became silent and more quick; useful also if the script can be put inside a cron job ;)
_________________
Arch Tester for Gentoo/FreeBSD
Equilibrium's Universe

all my contents are released under the Creative Commons Licence by-nc-nd 2.5
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum