From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22953 invoked by uid 1002); 19 Aug 2003 06:50:46 -0000 Mailing-List: contact gentoo-dev-help@gentoo.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Received: (qmail 23590 invoked from network); 19 Aug 2003 06:50:46 -0000 From: Karsten Schulz To: gentoo-dev@gentoo.org Date: Tue, 19 Aug 2003 08:50:43 +0200 User-Agent: KMail/1.5.2 References: <20030819053722.GA28151@force.stwing.upenn.edu> In-Reply-To: <20030819053722.GA28151@force.stwing.upenn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200308190850.43935.kaschu@t800.ping.de> Subject: Re: [gentoo-dev] patch: emergemail feature in functions.sh X-Archives-Salt: c7c11dea-4b21-4e30-98e5-f7a768e0e776 X-Archives-Hash: 08bf607cdd1463cbb7f895d741aaae9f Am Dienstag, 19. August 2003 07:37 schrieb Owen Gunden: > When this feature is turned on (and an mta > is present), all einfo, ewarn, and eerror messages are emailed to > root. I like that idea! > There is a major flaw with the current implementation. Namely, you > get an email for _every_ invocation of einfo, ewarn, or error. what about collection all einfo/ewarn/eerror output in an ENV variable (or in a temporary file) and send them in one mail to root after each stage of the emerge process (compile, install, ...)? You will get this functionality, when your 'emergemail' function only collects the data (and does not send it at this time) and you enter a line 'trap sendallmsg EXIT' at the beginning of functions.sh. This will call the 'sendallmsg' function, when the shell, which executes 'functions.sh', exits (which happens after each stage of the emerge process) The new function 'sendallmsg' has to mail the collected einfos (like emergemail does it now). Example (not tested!): = snip =================================================== trap sendallmsg EXIT .... sendallmsg() { if [ -x /usr/sbin/sendmail ]; then echo -e "${MYMESSAGES}" | /usr/sbin/sendmail root unset MYMESSAGES else # don't you dare try to use ewarn here :) echo -e " ${WARN}*${NORMAL} the emergemail feature was unable to" echo -e " ${WARN}*${NORMAL} find /usr/sbin/sendmail. You must have" echo -e " ${WARN}*${NORMAL} a Mail Transfer Agent (MTA) such as" echo -e " ${WARN}*${NORMAL} postfix, exim, ssmtp, etc. to use this" echo -e " ${WARN}*${NORMAL} feature." fi } emergemail() { SEVERITY=$1 MESSAGE=$2 if echo ${FEATURES} | grep -iq emergemail; then MYMESSAGES="${MYMESSAGES}\n${SEVERITY} ${MESSAGE}" fi } = snip =================================================== The EXIT trap is not used by other scripts in /sbin/* and /usr/lib/portage/bin/*, so I hope, it is ok to set it in /sbin/functions.sh! have fun! Karsten -- gentoo-dev@gentoo.org mailing list