summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorFernando J. Pereda <ferdy@gentoo.org>2005-04-25 13:19:25 +0000
committerFernando J. Pereda <ferdy@gentoo.org>2005-04-25 13:19:25 +0000
commit2f4c1e80df52a0bbbdb32fa2042611424934dedd (patch)
tree76f5290e6153593ca93708d72880c988fb68effb /eclass
parentcleaning (diff)
downloadhistorical-2f4c1e80df52a0bbbdb32fa2042611424934dedd.tar.gz
historical-2f4c1e80df52a0bbbdb32fa2042611424934dedd.tar.bz2
historical-2f4c1e80df52a0bbbdb32fa2042611424934dedd.zip
eclass to use with the new mailer-config/mailwrapper scheme
Diffstat (limited to 'eclass')
-rw-r--r--eclass/mailer.eclass84
1 files changed, 84 insertions, 0 deletions
diff --git a/eclass/mailer.eclass b/eclass/mailer.eclass
new file mode 100644
index 000000000000..e9ffe7711ccf
--- /dev/null
+++ b/eclass/mailer.eclass
@@ -0,0 +1,84 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/mailer.eclass,v 1.1 2005/04/25 13:19:25 ferdy Exp $
+
+#
+# Original Author: Fernando J. Pereda <ferdy@gentoo.org>
+# Purpose: eclass to intarface with net-mail/mailer-config, used to manage
+# multiple MTA's installed on a Gentoo system.
+#
+
+ECLASS="mailer"
+INHERITED="$INHERITED $ECLASS"
+IUSE="${IUSE} mailwrapper"
+RDEPEND="${RDEPEND}
+ mailwrapper? ( net-mail/mailer-config
+ >=net-mail/mailwrapper-0.2.1-r1 )"
+
+EXPORT_FUNCTIONS pkg_postinst pkg_postrm
+
+# Gets current mailer profile
+mailer_get_current() {
+ echo $(mailer-config --get-current-profile)
+ return $?
+}
+
+# Installs a new mailer.conf from FILESDIR
+mailer_install_conf() {
+ local newname
+
+ if [[ ${PN} == "mailer-config" ]] ; then
+ newname="default"
+ else
+ newname=${P}
+ fi
+
+ # If the newfile does not exist or the version in the system
+ # differs from the one in FILESDIR/ (update); install it
+ if [[ ! -f /etc/mail/${newname}.mailer ]] || \
+ ! diff /etc/mail/${newname}.mailer "${FILESDIR}/mailer.conf" > /dev/null ; then
+ insinto /etc/mail/
+ newins "${FILESDIR}/mailer.conf" ${newname}.mailer
+ fi
+}
+
+# Set current mailer profile
+mailer_set_profile() {
+ local newprofile=${1:-${P}}
+
+ ebegin "Setting the current mailer profile to \"${newprofile}\""
+ mailer-config --set-profile ${newprofile} >/dev/null || die
+ eend $?
+}
+
+# Wipe unused configs
+mailer_wipe_confs() {
+ local x i
+
+ ebegin "Wiping all non-used mailer profiles"
+ for x in /etc/mail/*.mailer ; do
+ i=${x##*/}
+ i=${i%.mailer}
+
+ [[ ${i} == ${P} ]] && continue
+ [[ ${i} == "default" ]] && continue
+
+ if ! has_version '=mail-mta/${i}*' ; then
+ rm ${x}
+ fi
+ done
+ eend 0
+}
+
+mailer_pkg_postinst() {
+ use mailwrapper && mailer_set_profile
+}
+
+mailer_pkg_postrm() {
+ if use mailwrapper ; then
+ mailer_wipe_confs
+
+ # We are removing the current profile, switch back to default
+ [[ $(mailer_get_current) == ${P} ]] && mailer_set_profile default
+ fi
+}