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

Revision 23104, 2.8 KB checked in by ghudson, 16 years ago (diff)
In evolution-wrapper: * Fix a typo.
  • 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
53    # To configure the accounts we need to know if we have krb4 support.
54    my $provides = `dpkg-query -Wf '\${Provides}' 'libcamel*'`;
55    my $krb4 = "";
56    if ($provides =~ /debathena-libcamel-krb4/) {
57        $krb4 = ";auth=KERBEROS_V4";
58    }
59
60    ($_, $_, $_, $_, $_, $_, my $gecos) = getpwuid($<);
61    my @fields = split(",", $gecos);
62    my $name = $fields[0];
63    my $home = $ENV{"HOME"};
64    my $local = "mbox:$home/.evolution/mail/local";
65    my $a = '<?xml version="1.0"?>' . "\n";
66    $a .= '<account name="MIT mail" uid="mitinitial" enabled="true">';
67    $a .= '<identity>';
68    $a .= "<name>$name</name>";
69    $a .= "<addr-spec>$user\@mit.edu</addr-spec>";
70    $a .= '</identity>';
71    $a .= '<source save-passwd="false">';
72    $a .= "<url>imap://$user$krb4\@$server/;use_ssl=always</url>";
73    $a .= '</source>';
74    $a .= '<transport save-passwd="false">';
75    $a .= "<url>smtp://$user;auth=GSSAPI\@outgoing.mit.edu/;use_ssl=always";
76    $a .= '</url>';
77    $a .= '</transport>';
78    $a .= "<drafts-folder>$local#Drafts</drafts-folder>";
79    $a .= "<sent-folder>$local#Sent</sent-folder>";
80    $a .= '</account>' . "\n";
81    $accounts = [ $a ];
82    $client->set_list("/apps/evolution/mail/accounts", "string", $accounts);
83    $client->set_string("/apps/evolution/mail/default_account", "mitinitial");
84}
85
86exec("/usr/bin/evolution.debathena-orig", @ARGV);
Note: See TracBrowser for help on using the repository browser.