aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Martin <slarti@gentoo.org>2005-04-25 19:19:36 +0000
committerTom Martin <slarti@gentoo.org>2005-04-25 19:19:36 +0000
commit93c3f48196194a513c672a26ca4f5820c9feb605 (patch)
tree7eac47f4cdcfe37e617af28d351b8a0d23e39b30
parentoutput misc/Makefile. (diff)
downloadeselect-93c3f48196194a513c672a26ca4f5820c9feb605.tar.gz
eselect-93c3f48196194a513c672a26ca4f5820c9feb605.tar.bz2
eselect-93c3f48196194a513c672a26ca4f5820c9feb605.zip
Added mailwrapper symlink module.
svn path=/trunk/; revision=25
-rw-r--r--ChangeLog4
-rw-r--r--modules/Makefile.am3
-rw-r--r--modules/mailer-symlink.eclectic96
3 files changed, 102 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bab5518..3fbce94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
ChangeLog for eclectic
+2005-04-25 Tom Martin <slarti@gentoo.org>
+
+ * modules/mailer-symlink.eclectic: Added mailwrapper symlink module.
+
2005-04-11 Aaron Walker <ka0ttic@gentoo.org>
* man/Makefile.am: forgot to add $(man_MANS) to EXTRA_DIST.
diff --git a/modules/Makefile.am b/modules/Makefile.am
index b7cd311..96033df 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -3,7 +3,8 @@ noinst_SCRIPTS = bashcomp.eclectic \
cow.eclectic \
kernel-symlink.eclectic \
profile-symlink.eclectic \
- vi-symlink.eclectic
+ vi-symlink.eclectic \
+ mailer-symlink.eclectic
EXTRA_DIST = $(noinst_SCRIPTS)
diff --git a/modules/mailer-symlink.eclectic b/modules/mailer-symlink.eclectic
new file mode 100644
index 0000000..0c368b8
--- /dev/null
+++ b/modules/mailer-symlink.eclectic
@@ -0,0 +1,96 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+DESCRIPTION="Manage the mailwrapper profiles in /etc/mail"
+VERSION="1.0"
+MAINTAINER="slarti@gentoo.org"
+
+# find a list of mailer.conf symlink targets
+find_targets() {
+ for f in ${ROOT}/etc/mail/*.mailer ; do
+ echo $(basename ${f} )
+ done
+}
+
+# try to remove the mailer.conf symlink
+remove_symlink() {
+ rm "${ROOT}/etc/mail/mailer.conf"
+}
+
+# set the mailer.conf symlink
+set_symlink() {
+ target=${1}
+ if [[ -z "${target//[[:digit:]]}" ]] ; then
+ targets=( $(find_targets ) )
+ target=${targets[$(( ${target} -1 ))]}
+ fi
+ if [[ -z ${target} ]] ; then
+ die -q "Target \"${1}\" doesn't appear to be valid!"
+ elif [[ -f "${ROOT}/etc/mail/${target}.mailer" ]] ; then
+ pushd "${ROOT}/etc/mail" 1>/dev/null
+ ln -s "${target}.mailer" "mailer.conf"
+ popd 1>/dev/null
+ else
+ die -q "Target \"${1}\" doesn't appear to be valid!"
+ fi
+}
+
+### show action ###
+
+describe_show() {
+ echo "Show the current mailer.conf profile"
+}
+
+do_show() {
+ write_list_start "Current mailer.conf profile:"
+ if [[ -L "${ROOT}/etc/mail/mailer.conf" ]] ; then
+ profile="$(readlink ${ROOT}/etc/mail/mailer.conf )"
+ write_kv_list_entry "${profile%.mailer}" ""
+ elif [[ -e "${ROOT}/etc/mail/mailer.conf" ]] ; then
+ write_kv_list_entry "(not a symlink)" ""
+ else
+ write_kv_list_entry "(unset)" ""
+ fi
+}
+
+### list action ###
+
+describe_list() {
+ echo "List available mailer.conf profiles"
+}
+
+do_list() {
+ targets=( $(find_targets ) )
+ targets=( ${targets[@]%.mailer} )
+ write_list_start "Available mailer.conf profiles:"
+ write_numbered_list "${targets[@]}"
+}
+
+### set action ###
+
+describe_set() {
+ echo "Set a new mailer.conf profile"
+}
+
+do_set() {
+ if [[ -z ${1} ]] ; then
+ die -q "You didn't tell me what to set the profile to"
+
+ elif [[ -L "${ROOT}/etc/mail/mailer.conf" ]] ; then
+ if ! remove_symlink ; then
+ die -q "Couldn't remove existing mailer.conf"
+ elif ! set_symlink "${1}" ; then
+ die -q "Couldn't set a new profile"
+ fi
+
+ elif [[ -e "${ROOT}/etc/mail/mailer.conf" ]] ; then
+ # we have something strange
+ die -q "Sorry, ${ROOT}/etc/mail/mailer.conf confuses me"
+
+ else
+ set_symlink "${1}" || die -q "Couldn't set a new symlink"
+ fi
+}
+
+# vim: set ft=ebuild :