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

Revision 22998, 2.4 KB checked in by ghudson, 16 years ago (diff)
Add new evolution wrapper script package to perform initial configuration and Hesiod lookups.
  • 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.
32    my $change = 0;
33    foreach (@$accounts) {
34        my $old = $_;
35        if (/name="MIT mail"/) {
36            s|(imap://[^/]*@)(po\d+\.mit\.edu)|\1$server|;
37        }
38        $change = 1 if ($_ ne $old);
39    }
40
41    if ($change) {
42        $client->set_list("/apps/evolution/mail/accounts", "string",
43                          $accounts);
44    }
45} else {
46    # Pre-configuration.
47    $client->set_string("/apps/evolution/calendar/display/timezone",
48                        "America/New_York");
49    ($_, $_, $_, $_, $_, $_, my $gecos) = getpwuid($<);
50    my @fields = split(",", $gecos);
51    my $name = $fields[0];
52    my $home = $ENV{"HOME"};
53    my $local = "mbox:$home/.evolution/mail/local";
54    my $a = '<?xml version="1.0"?>' . "\n";
55    $a .= '<account name="MIT mail" uid="mitinitial" enabled="true">';
56    $a .= '<identity>';
57    $a .= "<name>$name</name>";
58    $a .= "<addr-spec>$user\@mit.edu</addr-spec>";
59    $a .= '</identity>';
60    $a .= '<source save-passwd="false">';
61    $a .= "<url>imap://$user;auth=KERBEROS_V4\@$server/;use_ssl=always</url>";
62    $a .= '</source>';
63    $a .= '<transport save-passwd="false">';
64    $a .= "<url>smtp://$user;auth=GSSAPI\@outgoing.mit.edu/;use_ssl=always";
65    $a .= '</url>';
66    $a .= '</transport>';
67    $a .= "<drafts-folder>$local#Drafts</drafts-folder>";
68    $a .= "<sent-folder>$local#Sent</sent-folder>";
69    $a .= '</account>' . "\n";
70    $accounts = [ $a ];
71    $client->set_list("/apps/evolution/mail/accounts", "string", $accounts);
72    $client->set_string("/apps/evolution/mail/default_account", "mitinitial");
73}
74
75exec("/usr/bin/evolution.debathena-orig", @ARGV);
Note: See TracBrowser for help on using the repository browser.