From: Owen Gunden <ogunden@stwing.upenn.edu>
To: gentoo-dev@gentoo.org
Subject: [gentoo-dev] patch: emergemail feature in functions.sh
Date: Tue, 19 Aug 2003 01:37:23 -0400 [thread overview]
Message-ID: <20030819053722.GA28151@force.stwing.upenn.edu> (raw)
[-- Attachment #1: Type: text/plain, Size: 769 bytes --]
Hi,
Attached is a small patch for the file functions.sh (part of baselayout)
which implements the feature "emergemail" (set in /etc/make.conf FEATURES).
When this feature is turned on (and an mta is present), all einfo, ewarn,
and eerror messages are emailed to root.
This is useful if you upgrade or install multiple packages at once, and you
don't want to miss any important messages that go whizzing by.
There is a major flaw with the current implementation. Namely, you get an
email for _every_ invocation of einfo, ewarn, or error. The way those
functions are commonly used (repeated calls for multi-line messages) makes
avoiding this flaw quite difficult without rather sweeping changes to the
design of emerge/ebuild.
Comments or suggestions welcome.
Owen
[-- Attachment #2: functions.sh.patch --]
[-- Type: text/plain, Size: 1695 bytes --]
--- functions-old.sh 2003-08-18 21:49:35.000000000 -0400
+++ functions.sh 2003-08-19 01:23:25.000000000 -0400
@@ -121,6 +121,31 @@
BRACKET=$'\e[34;01m'
fi
+# void emergemail(char *severity, char *message)
+#
+# send mail to root with the given message (if possible)
+# severity is either "information" (for einfo),
+# "warning" (for ewarn),
+# or "error" (for eerror).
+#
+emergemail() {
+ SEVERITY=$1
+ MESSAGE=$2
+ if echo ${FEATURES} | grep -iq emergemail; then
+ if [ -x /usr/sbin/sendmail ]; then
+ echo -e "Subject: ${SEVERITY} from emerge of ${P}\n\n${MESSAGE}" \
+ | /usr/sbin/sendmail root
+ 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
+ fi
+}
+
# void esyslog(char* priority, char* tag, char* message)
#
# use the system logger to log a message
@@ -153,6 +178,8 @@
echo -e " ${GOOD}*${NORMAL} ${*}"
fi
+ emergemail information "${*}"
+
return 0
}
@@ -166,6 +193,8 @@
echo -ne " ${GOOD}*${NORMAL} ${*}"
fi
+ emergemail information "${*}"
+
return 0
}
@@ -181,6 +210,8 @@
echo -e " ${WARN}*${NORMAL} ${*}"
fi
+ emergemail warning "${*}"
+
# Log warnings to system log
esyslog "daemon.warning" "rc-scripts" "${*}"
@@ -199,6 +230,8 @@
echo -e " ${BAD}*${NORMAL} ${*}"
fi
+ emergemail error "${*}"
+
# Log errors to system log
esyslog "daemon.err" "rc-scripts" "${*}"
[-- Attachment #3: Type: text/plain, Size: 37 bytes --]
--
gentoo-dev@gentoo.org mailing list
next reply other threads:[~2003-08-19 5:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-19 5:37 Owen Gunden [this message]
2003-08-19 5:44 ` [gentoo-dev] patch: emergemail feature in functions.sh Jon Portnoy
2003-08-19 5:54 ` Mike Frysinger
2003-08-19 6:50 ` Karsten Schulz
2003-08-19 8:34 ` Owen Gunden
2003-08-19 23:53 ` Owen Gunden
2003-08-19 13:05 ` Thomas de Grenier de Latour
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030819053722.GA28151@force.stwing.upenn.edu \
--to=ogunden@stwing.upenn.edu \
--cc=gentoo-dev@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox