[22998] | 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 | |
---|
| 10 | use strict; |
---|
| 11 | use Gnome2::GConf; |
---|
| 12 | |
---|
| 13 | # Ensure $HOME/.evolution is private when created. |
---|
| 14 | my $homedir = $ENV{"HOME"}; |
---|
| 15 | if ($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. |
---|
| 22 | my $user = $ENV{"USER"} || getpwuid($<); |
---|
| 23 | my $result = `hesinfo $user pobox`; |
---|
| 24 | my @fields = split(' ', $result); |
---|
| 25 | my $server = $fields[1]; |
---|
| 26 | |
---|
| 27 | my $client = Gnome2::GConf::Client->get_default; |
---|
| 28 | my $accounts = $client->get_list("/apps/evolution/mail/accounts"); |
---|
| 29 | |
---|
| 30 | if ($accounts) { |
---|
[23019] | 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). |
---|
[22998] | 34 | my $change = 0; |
---|
| 35 | foreach (@$accounts) { |
---|
| 36 | my $old = $_; |
---|
| 37 | if (/name="MIT mail"/) { |
---|
[23019] | 38 | s|(imap://[^/]*\@)(po\d+\.mit\.edu)|\1$server|i; |
---|
| 39 | s|(imap://[^/]*\@)_hesiod|\1$server|; |
---|
[22998] | 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"); |
---|
[23092] | 52 | |
---|
| 53 | # To configure the accounts we need to know if we have krb4 support. |
---|
[23104] | 54 | my $provides = `dpkg-query -Wf '\${Provides}' 'libcamel*'`; |
---|
[23092] | 55 | my $krb4 = ""; |
---|
[23098] | 56 | if ($provides =~ /debathena-libcamel-krb4/) { |
---|
[23092] | 57 | $krb4 = ";auth=KERBEROS_V4"; |
---|
| 58 | } |
---|
| 59 | |
---|
[22998] | 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">'; |
---|
[23092] | 72 | $a .= "<url>imap://$user$krb4\@$server/;use_ssl=always</url>"; |
---|
[22998] | 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 | |
---|
| 86 | exec("/usr/bin/evolution.debathena-orig", @ARGV); |
---|