My most recent large update (>500 packages) prompted this idea. Around the tenth time an ebuild failed mere moments after I left the room (not to return for hours), I decided to have the darn thing alert me when it wanted attention.

The following assumes you have installed:

The mailx client (mail-client/mailx), to send mail from shell scripts and the command line.

An MTA (mail transfer agent) for mailx to use, such as Postfix, Sendmail or ssmtp.

This script is intended to run in a pipeline after emerge and send a short message to explain why emerge stopped.

The message body reports the last ebuild attempted, whether the overall merge succeeded or failed and whether you need to apply any configuration file updates. Any command-line arguments supplied to emobalert are appended to the message.

On those rare occasions when you have better things to do than watch compiler output scroll by, this trick helps you still catch problems quickly._________________Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.

For US Verizon Wireless numbers the gateway address is number@vtext.com for text, number@vzwpix.com for multimedia messages. I think most carriers provide a similar service (in the US at least). Check the support section of the carrier's website or call customer service._________________Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.

Nice trick... But isn't it easier to use --keep-going emerge parameter?

The two are not mutually exclusive._________________Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.

Nice trick... But isn't it easier to use --keep-going emerge parameter?

The two are not mutually exclusive.

True... Though, if I understand the script well, it seems that the informative value of running it after emerge -keep-going would be very small. Did you think about modifying it so that it would parse the log more thoroughly? I guess it wouldn't be that difficult to detect, how many packages were skipped during such emerge job.

True... Though, if I understand the script well, it seems that the informative value of running it after emerge -keep-going would be very small. Did you think about modifying it so that it would parse the log more thoroughly? I guess it wouldn't be that difficult to detect, how many packages were skipped during such emerge job.

Agreed, but I have no need. I am not too fond of --keep-going, I prefer to fix problems as they arise (as you might have guessed ). When I have some time I'll look into counting failed packages. I have an idea for a simple solution but need to experiment.

Thanks for all the compliments and comments so far. _________________Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.

This is one of the coolest things I have ever seen someone contribute! I really would like to see this suggested as a feature update to portage so that you can just define an address in your /etc/make.conf and have it done every time without remembering to run the script. Have you submitted it as a feature request? I'd certainly vote for it's injection!!

Hey this looks like a great little script. Thanks so much for your effort.

I was wondering if this could be edited to include the ability to send an email about a package failure. I do have a cell phone but I'm a cheap sob and don't have unlimited text._________________Increasingly becoming a 2 channel audio nut!

Thanks! Sorry for not responding sooner, this thread fell off my egosearch due to age.

bobspencer123 wrote:

I was wondering if this could be edited to include the ability to send an email...

Er...that's what it does. Conversion to SMS happens at the carrier's gateway address, not in the script. Just change SMS_ADDR to the email address where you want to send the note.

Note: The script is partially broken as of Portage 2.1.6.13 and later (at least in the 2.1.x series). The exit status of emerge no longer reflects the pass/fail status of the last ebuild. As a result the message sent reports PASS even if an ebuild failed. The log excerpt will still clue you in if there was a failure (e.g., "(5 of 17) app-who/badwolf").

I'll look into it soon and either find a more reliable test or file a bug on Portage (if warranted)._________________Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.

If you read through the script closely you'll notice that I'm both printing to the console and saving STDOUT and STDERR to a log file.

The script basically does this:

take commands ie:

Code:

run_with_email_confirm "emerge --sync" "emerge -u world"

separate the commands (each of which is just an argument)

run them one at a time

if it passes then run the next command (if it passes all command arguments, then send an email with a PASS and indicate the commands run)

if it fails then take the command that failed ${arg}, exit code ${PIPESTATUS[0]}, last 30 lines of console output ${OUTPUT_TEMP_FILE} and pass it to the email script "email_results" which basically makes it pretty.

I apologize for all the hack html tags in there...there's probably a better way to handle it. The email wouldn't take terminal color codes etc since it's not a terminal interpretting them so I had to go with html.

You can follow this link to set up gentoo to send from your own gmail address:

Maybe this'll be useful to someone else in the future. The code could be cleaned up indeed etc but hey, it works. I'm working on an embedded device (Beagleboard-XM) so I have to leave it plugged in on top of the router and I can't monitor it 24/7 over serial console right.

UPDATE: I was stupid and forgot that my $RESULT variable is actually the same as $EXIT_STATUS after I changed the script up at one point; meaning...$RESULT is pretty useless..meh

Thanks! Sorry for not responding sooner, this thread fell off my egosearch due to age.

bobspencer123 wrote:

I was wondering if this could be edited to include the ability to send an email...

Er...that's what it does. Conversion to SMS happens at the carrier's gateway address, not in the script. Just change SMS_ADDR to the email address where you want to send the note.

Note: The script is partially broken as of Portage 2.1.6.13 and later (at least in the 2.1.x series). The exit status of emerge no longer reflects the pass/fail status of the last ebuild. As a result the message sent reports PASS even if an ebuild failed. The log excerpt will still clue you in if there was a failure (e.g., "(5 of 17) app-who/badwolf").

I'll look into it soon and either find a more reliable test or file a bug on Portage (if warranted).

It might be overkill for something so simple, but my script (see my signature below) does keep track of the number of failed packages and the number of skipped packages. You could hook up your script to be executed at the end of the emerge process (via a config variable POST_CMD). Since your script will be run from inside my script, it will actually be able to access the internal variables of my script, in particular the array exit_status which contains the number of failed and skipped packages._________________emerge --quiet redefined | E17 vids: I, II | Now using e from git | e18, e19, and kde4 sucks :-/