[28223] in Source-Commits

home help back first fref pref prev next nref lref last post

alpine-config commit: Default to Exchange configuration

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Thu May 22 15:52:15 2014

Date: Thu, 22 May 2014 15:52:08 -0400
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201405221952.s4MJq8b6008373@drugstore.mit.edu>
To: source-commits@MIT.EDU

https://github.com/mit-athena/alpine-config/commit/9471f8781ad97b2aa4b6a312475cbab1000ca71b
commit 9471f8781ad97b2aa4b6a312475cbab1000ca71b
Author: Jonathan Reed <jdreed@mit.edu>
Date:   Wed Apr 9 14:51:25 2014 -0400

    Default to Exchange configuration
    
    Per (Trac: #1438), Pine now defaults to a configuration suitable
    for Exchange.  This includes removing the "INBOX." prefix that Cyrus
    required, as well as not disabling GSSAPI.  It also uses
    "imap.exchange.mit.edu" as the hostname, not $USER.mail, because
    of SSL certificate hostname validation.  We also provide a utility
    for the stragglers to switch back to IMAP.

 debian/alpine.debathena                |   40 ++++++++++++++++-------
 debian/changelog                       |    8 +++++
 debian/debathena-alpine-config.install |    1 +
 debian/transform_pine.conf.debathena   |    4 +-
 debian/update-pine-config              |   55 ++++++++++++++++++++++++++++++++
 5 files changed, 94 insertions(+), 14 deletions(-)

diff --git a/debian/alpine.debathena b/debian/alpine.debathena
index 61570f9..47741b9 100755
--- a/debian/alpine.debathena
+++ b/debian/alpine.debathena
@@ -1,8 +1,35 @@
 #!/bin/bash
 
+FLAGFILE="$HOME/.config/debathena/alpine-migration-prompted"
+mkdir -p "$(dirname $FLAGFILE)"
+
 arg=()
 case "$(hesinfo "${ATHENA_USER:-$USER}" pobox 2>/dev/null | cut -d' ' -f2)" in
-    *EXCHANGE*) arg=(-disable-these-authenticators=GSSAPI) ;;
+    *EXCHANGE*) ;;
+    *)
+	if ! [ -e "$FLAGFILE" ]; then
+	    echo "Pine's default configuration has been updated to use"
+	    echo "MIT's Exchange environment, but your account still"
+	    echo "appears to be using the legacy Cyrus environment".
+	    echo
+	    echo "IMPORTANT:"
+	    echo " If you received notification that your e-mail was recently"
+	    echo " migrated to the Exchange environment, you should answer 'n'"
+	    echo " to the following question."
+	    echo
+	    echo -n "Would you like to reconfigure Pine to use the legacy Cyrus environment? [y/n] "
+	    read answer
+	    case "$answer" in
+		[Yy]*)
+		    /usr/lib/debathena-alpine-config/update-pine-config cyrus
+		    echo "In the future, when you are migrated to Exchange,"
+		    echo "you must run the following command:"
+		    echo "/usr/lib/debathena-alpine-config/update-pine-config exchange"
+		    ;;
+	    esac
+	    touch "$FLAGFILE"
+	fi
+	;;
 esac
 
 if ! klist -s; then
@@ -12,15 +39,4 @@ fi
 : ${ATHENA_USER=$USER}
 export ATHENA_USER
 
-# If you've customized your folder collections on an Athenified pine,
-# then you probably have copied in mit.edu/hesiod/imap, which isn't
-# going to work.
-#
-# We substitute in $ATHENA_USER rather than use the variable because
-# Athena 9 doesn't have it, and besides this is presumably not being
-# shared between users.
-if [ -e ~/.pinerc ] && grep -qF mit.edu/hesiod/imap ~/.pinerc; then
-    sed -i "s#mit\.edu/hesiod/imap#$ATHENA_USER\.mail\.mit\.edu/imap/user=$ATHENA_USER#g" ~/.pinerc
-fi
-
 exec "alpine.debathena-orig" "${arg[@]}" "$@"
diff --git a/debian/changelog b/debian/changelog
index 65858fd..082b67b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+debathena-alpine-config (1.20) unstable; urgency=low
+
+  * Default to EXCHANGE configuration (Trac: #1438)
+  * Provide a utility for people to switch between Cyrus and EXCHANGE
+    configurations
+
+ -- Jonathan Reed <jdreed@mit.edu>  Wed, 09 Apr 2014 14:51:20 -0400
+
 debathena-alpine-config (1.19) unstable; urgency=low
 
   [ Jonathan Reed ]
diff --git a/debian/debathena-alpine-config.install b/debian/debathena-alpine-config.install
index 11c2cbd..1b85531 100644
--- a/debian/debathena-alpine-config.install
+++ b/debian/debathena-alpine-config.install
@@ -1 +1,2 @@
 debian/alpine.debathena usr/bin
+debian/update-pine-config usr/lib/debathena-alpine-config
diff --git a/debian/transform_pine.conf.debathena b/debian/transform_pine.conf.debathena
index d4b870b..7c9e1d9 100755
--- a/debian/transform_pine.conf.debathena
+++ b/debian/transform_pine.conf.debathena
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -0p
 s%^(user-domain=).*$%${1}mit.edu%m or die;
 s%^(nntp-server=).*$%${1}news.mit.edu%m or die;
-s%^(inbox-path=).*$%${1}{\${ATHENA_USER}.mail.mit.edu/ssl/imap/user=\${ATHENA_USER}}INBOX%m or die;
+s%^(inbox-path=).*$%${1}{imap.exchange.mit.edu/ssl/imap/user=\${ATHENA_USER}}%m or die;
 s%^(feature-list=).*$%${1}enable-mail-check-cue,\n\tsave-will-quote-leading-froms,\n\tenable-full-header-cmd%m or die;
 s%^(bugs-fullname=).*$%${1}Athena Bugs%m or die;
 s%^(bugs-address=).*$%${1}bugs\@mit.edu%m or die;
@@ -10,7 +10,7 @@ s%^(suggest-address=).*$%${1}suggest\@mit.edu%m or die;
 s%^(local-fullname=).*$%${1}Athena Consultants%m or die;
 s%^(local-address=).*$%${1}olc-mail\@mit.edu%m or die;
 s%^(url-viewers=).*$%${1}/usr/bin/sensible-browser%m or die;
-s%^(folder-collections=).*$%${1}"MIT Mail" {\${ATHENA_USER}.mail.mit.edu/ssl/imap/user=\${ATHENA_USER}}INBOX.[],\n\t"Old MH Mail" #mh/[],\n\t"Local Pine Mail" ~/mail/[]%m or die;
+s%^(folder-collections=).*$%${1}"MIT Mail" {imap.exchange.mit.edu/ssl/imap/user=\${ATHENA_USER}}[],\n\t"Old MH Mail" #mh/[],\n\t"Local Pine Mail" ~/mail/[]%m or die;
 s%^(sendmail-path=).*$%${1}/usr/lib/debathena-msmtp -t%m or die;
 s%^(rsh-open-timeout=).*$%${1}0%m or die;
 s%^(ssh-open-timeout=).*$%${1}0%m or die;
diff --git a/debian/update-pine-config b/debian/update-pine-config
new file mode 100755
index 0000000..b171161
--- /dev/null
+++ b/debian/update-pine-config
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+to_cyrus() {
+    if [ ! -e ~/.pinerc ]; then
+	cat <<'EOF' > ~/.pinerc
+# Path of (local or remote) INBOX, e.g. ={mail.somewhere.edu}inbox
+# Normal Unix default is the local INBOX (usually /usr/spool/mail/$USER).
+inbox-path={${ATHENA_USER}.mail.mit.edu/ssl/imap/user=${ATHENA_USER}}INBOX
+
+# List of directories where saved-message folders may be. First one is
+# the default for Saves. Example: Main {host1}mail/[], Desktop mail\[]
+# Syntax: optnl-label {optnl-imap-hostname}optnl-directory-path[]
+folder-collections="MIT Mail" {${ATHENA_USER}.mail.mit.edu/ssl/imap/user=${ATHENA_USER}}INBOX.[],
+        "Old MH Mail" #mh/[],
+        "Local Pine Mail" ~/mail/[]
+
+EOF
+	echo "Your ~/.pinerc has been updated."
+    else
+	cp ~/.pinerc ~/.pinerc.bak.$$
+	perl -0pie - ~/.pinerc <<'EOF'
+s%^(inbox-path=).*$%${1}{\${ATHENA_USER}.mail.mit.edu/ssl/imap/user=\${ATHENA_USER}}INBOX%m or die;
+s%^(folder-collections=).*$%${1}"MIT Mail" {\${ATHENA_USER}.mail.mit.edu/ssl/imap/user=\${ATHENA_USER}}INBOX.[],\n\t"Old MH Mail" #mh/[],\n\t"Local Pine Mail" ~/mail/[]%m or die;
+EOF
+	echo "Your ~/.pinerc has been updated, and your original"
+	echo "~/.pinerc has been saved as ~/.pinerc.bak.$$"
+    fi
+}
+
+to_exchange() {
+    if [ -e ~/.pinerc ]; then
+	cp ~/.pinerc ~/.pinerc.bak.$$
+	perl -0pie - ~/.pinerc <<'EOF'
+s%^(inbox-path=).*$%${1}{imap.exchange.mit.edu/ssl/imap/user=\${ATHENA_USER}}%m or die;
+
+s%^(folder-collections=).*$%${1}"MIT Mail" {imap.exchange.mit.edu/ssl/imap/user=\${ATHENA_USER}}[],\n\t"Old MH Mail" #mh/[],\n\t"Local Pine Mail" ~/mail/[]%m or die;
+EOF
+	echo "Your ~/.pinerc has been updated, and your original"
+	echo "~/.pinerc has been saved as ~/.pinerc.bak.$$"
+    fi
+}
+
+case "$1" in
+    cyrus)
+	to_cyrus
+	;;
+    exchange)
+	to_exchange
+	;;
+    *)
+	echo "Usage: $0 [cyrus | exchange]"
+	exit 1
+	;;
+esac
+exit 0

home help back first fref pref prev next nref lref last post