source: trunk/debathena/debathena/evolution-wrapper/evolution.debathena @ 23019

Revision 23019, 2.6 KB checked in by ghudson, 16 years ago (diff)
In evolution-wrapper: * Fix updating of server name from Hesiod. * Convert @_hesiod server specifications if we see them.
  • Property svn:executable set to *
Line 
1#!/usr/bin/perl
2
3# Evolution wrapper script for Athena
4
5# Performs the following Evolution customizations:
6#   * Ensures $HOME/.evolution is private when created.
7#   * Performs Hesiod lookup of user inbox.
8#   * Pre-configures Evolution for MIT mail on first invocation.
9
10use strict;
11use Gnome2::GConf;
12
13# Ensure $HOME/.evolution is private when created.
14my $homedir = $ENV{"HOME"};
15if ($homedir && ! -e "$homedir/.evolution") {
16    if (mkdir("$homedir/.evolution")) {
17        system("fs sa $homedir/.evolution system:anyuser none 2>/dev/null");
18    }
19}
20
21# Look up user inbox in Hesiod.
22my $user = $ENV{"USER"} || getpwuid($<);
23my $result = `hesinfo $user pobox`;
24my @fields = split(' ', $result);
25my $server = $fields[1];
26
27my $client = Gnome2::GConf::Client->get_default;
28my $accounts = $client->get_list("/apps/evolution/mail/accounts");
29
30if ($accounts) {
31    # Update the server with the value from Hesiod.  Also convert
32    # Athena 9.4-style Hesiod specifications (although it should be
33    # unusual to see one due to debathena-gconf2-config).
34    my $change = 0;
35    foreach (@$accounts) {
36        my $old = $_;
37        if (/name="MIT mail"/) {
38            s|(imap://[^/]*\@)(po\d+\.mit\.edu)|\1$server|i;
39            s|(imap://[^/]*\@)_hesiod|\1$server|;
40        }
41        $change = 1 if ($_ ne $old);
42    }
43
44    if ($change) {
45        $client->set_list("/apps/evolution/mail/accounts", "string",
46                          $accounts);
47    }
48} else {
49    # Pre-configuration.
50    $client->set_string("/apps/evolution/calendar/display/timezone",
51                        "America/New_York");
52    ($_, $_, $_, $_, $_, $_, my $gecos) = getpwuid($<);
53    my @fields = split(",", $gecos);
54    my $name = $fields[0];
55    my $home = $ENV{"HOME"};
56    my $local = "mbox:$home/.evolution/mail/local";
57    my $a = '<?xml version="1.0"?>' . "\n";
58    $a .= '<account name="MIT mail" uid="mitinitial" enabled="true">';
59    $a .= '<identity>';
60    $a .= "<name>$name</name>";
61    $a .= "<addr-spec>$user\@mit.edu</addr-spec>";
62    $a .= '</identity>';
63    $a .= '<source save-passwd="false">';
64    $a .= "<url>imap://$user;auth=KERBEROS_V4\@$server/;use_ssl=always</url>";
65    $a .= '</source>';
66    $a .= '<transport save-passwd="false">';
67    $a .= "<url>smtp://$user;auth=GSSAPI\@outgoing.mit.edu/;use_ssl=always";
68    $a .= '</url>';
69    $a .= '</transport>';
70    $a .= "<drafts-folder>$local#Drafts</drafts-folder>";
71    $a .= "<sent-folder>$local#Sent</sent-folder>";
72    $a .= '</account>' . "\n";
73    $accounts = [ $a ];
74    $client->set_list("/apps/evolution/mail/accounts", "string", $accounts);
75    $client->set_string("/apps/evolution/mail/default_account", "mitinitial");
76}
77
78exec("/usr/bin/evolution.debathena-orig", @ARGV);
Note: See TracBrowser for help on using the repository browser.