Gentoo Archives: gentoo-dev

From: Karsten Schulz <kaschu@×××××××××.de>
To: gentoo-dev@g.o
Subject: Re: [gentoo-dev] patch: emergemail feature in functions.sh
Date: Tue, 19 Aug 2003 06:50:46
Message-Id: 200308190850.43935.kaschu@t800.ping.de
In Reply to: [gentoo-dev] patch: emergemail feature in functions.sh by Owen Gunden
1 Am Dienstag, 19. August 2003 07:37 schrieb Owen Gunden:
2 > When this feature is turned on (and an mta
3 > is present), all einfo, ewarn, and eerror messages are emailed to
4 > root.
5
6 I like that idea!
7
8 > There is a major flaw with the current implementation. Namely, you
9 > get an email for _every_ invocation of einfo, ewarn, or error.
10
11 what about collection all einfo/ewarn/eerror output in an ENV variable
12 (or in a temporary file) and send them in one mail to root after each
13 stage of the emerge process (compile, install, ...)?
14
15 You will get this functionality, when your 'emergemail' function only
16 collects the data (and does not send it at this time) and you enter a
17 line 'trap sendallmsg EXIT' at the beginning of functions.sh. This will
18 call the 'sendallmsg' function, when the shell, which executes
19 'functions.sh', exits (which happens after each stage of the emerge
20 process)
21 The new function 'sendallmsg' has to mail the collected einfos (like
22 emergemail does it now).
23
24 Example (not tested!):
25 = snip ===================================================
26 trap sendallmsg EXIT
27 ....
28 sendallmsg() {
29 if [ -x /usr/sbin/sendmail ]; then
30 echo -e "${MYMESSAGES}" | /usr/sbin/sendmail root
31 unset MYMESSAGES
32 else
33 # don't you dare try to use ewarn here :)
34 echo -e " ${WARN}*${NORMAL} the emergemail feature was unable to"
35 echo -e " ${WARN}*${NORMAL} find /usr/sbin/sendmail. You must have"
36 echo -e " ${WARN}*${NORMAL} a Mail Transfer Agent (MTA) such as"
37 echo -e " ${WARN}*${NORMAL} postfix, exim, ssmtp, etc. to use this"
38 echo -e " ${WARN}*${NORMAL} feature."
39 fi
40 }
41
42 emergemail() {
43 SEVERITY=$1
44 MESSAGE=$2
45 if echo ${FEATURES} | grep -iq emergemail; then
46 MYMESSAGES="${MYMESSAGES}\n${SEVERITY} ${MESSAGE}"
47 fi
48 }
49
50 = snip ===================================================
51 The EXIT trap is not used by other scripts in /sbin/* and
52 /usr/lib/portage/bin/*, so I hope, it is ok to set it in
53 /sbin/functions.sh!
54
55 have fun!
56 Karsten
57
58
59 --
60 gentoo-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-dev] patch: emergemail feature in functions.sh Owen Gunden <ogunden@××××××××××××.edu>
Re: [gentoo-dev] patch: emergemail feature in functions.sh Owen Gunden <ogunden@××××××××××××.edu>