3 # Written March 26, 2000
4 # Luke Ehresman (lehresma@css.tayloru.edu)
6 # A simple configure script to configure squirrelmail
7 ############################################################
11 ############################################################
12 # First, lets read in the data already in there...
13 ############################################################
14 if ( -e
"config.php") {
15 print "The file \"config.php\" exists. Using it for defaults.\n\n";
16 open (FILE
, "config.php");
18 print "No config file found. Reading from config_defaults.php.\n\n";
19 open (FILE
, "config_default.php");
22 # Reads and parses the current configuration file (either
23 # config.php or config_default.php).
25 while ($line = <FILE
>) {
26 if ($line =~ /^\s+\$/) {
30 if ($var =~ /^([a-z]|[A-Z])/) {
31 @options = split(/\s=\s/, $var);
32 $options[1] =~ s/[\n|\r]//g;
33 $options[1] =~ s/^"//g;
34 $options[1] =~ s/;.*$//g;
35 $options[1] =~ s/"$//g;
37 if ($options[0] =~ /^special_folders/) {
38 if ($options[0] =~ /\[.*\]$/) {
41 $sub = substr ($sub, @sub-1, 1);
43 $special_folders[$sub] = $options[1];
45 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
47 $sub =~ s/\]\["PATH"\]//;
48 $sub = substr ($sub, @sub-1, 1);
49 $theme_path[$sub] = $options[1];
50 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
52 $sub =~ s/\]\["NAME"\]//;
53 $sub = substr ($sub, @sub-1, 1);
54 $theme_name[$sub] = $options[1];
56 ${$options[0]} = $options[1];
61 if ($useSendmail ne "true") {
62 $useSendmail = "false";
64 if (!$sendmail_path) {
65 $sendmail_path = "/usr/sbin/sendmail";
69 #####################################################################################
71 while (($command ne "q") && ($command ne "Q")) {
74 print $WHT."Main Menu --\n".$NRM;
75 print "1. Organization Preferences\n";
76 print "2. Server Settings\n";
77 print "3. Folder Defaults\n";
78 print "4. General Options\n";
80 print "6. Address Books (LDAP)\n";
81 print "7. Message of the Day (MOTD)\n";
83 } elsif ($menu == 1) {
84 print $WHT."Organization Preferences\n".$NRM;
85 print "1. Organization Name : $WHT$org_name$NRM\n";
86 print "2. Organization Logo : $WHT$org_logo$NRM\n";
87 print "3. Organization Title : $WHT$org_title$NRM\n";
89 print "R Return to Main Menu\n";
90 } elsif ($menu == 2) {
91 print $WHT."Server Settings\n".$NRM;
92 print "1. Domain : $WHT$domain$NRM\n";
93 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
94 print "3. IMAP Port : $WHT$imapPort$NRM\n";
95 print "4. Use Sendmail : $WHT$useSendmail$NRM\n";
96 if ($useSendmail eq "true") {
97 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
99 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
100 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
103 print "R Return to Main Menu\n";
104 } elsif ($menu == 3) {
105 print $WHT."Folder Defaults\n".$NRM;
106 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
107 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
108 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
109 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
110 print "5. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
111 print "6. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
112 print "7. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
113 print "8. Auto Expunge : $WHT$auto_expunge$NRM\n";
114 print "9. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
115 print "10. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
116 print "11. Special Folders > $WHT$special_folders[0]$NRM\n";
117 for ($count = 1; $count <= $#special_folders; $count++) {
118 print " > $WHT$special_folders[$count]$NRM\n";
121 print "R Return to Main Menu\n";
122 } elsif ($menu == 4) {
123 print $WHT."General Options\n".$NRM;
125 print "R Return to Main Menu\n";
126 } elsif ($menu == 5) {
127 print $WHT."Themes\n".$NRM;
129 print "R Return to Main Menu\n";
130 } elsif ($menu == 6) {
131 print $WHT."Address Books (LDAP)\n".$NRM;
133 print "R Return to Main Menu\n";
134 } elsif ($menu == 7) {
135 print $WHT."Message of the Day (MOTD)\n".$NRM;
138 print "1 Edit the MOTD\n";
140 print "R Return to Main Menu\n";
142 print "X Quit without saving\n";
143 print "Q Save and exit\n";
146 print "Command >> ".$WHT;
148 $command =~ s/[\n|\r]//g;
151 # Read the commands they entered.
152 if (($command eq "R") || ($command eq "r")) {
156 if (($command > 0) && ($command < 8)) {
159 } elsif ($menu == 1) {
160 if ($command == 1) { $org_name = command1
(); }
161 elsif ($command == 2) { $org_logo = command2
(); }
162 elsif ($command == 3) { $org_title = command3
(); }
163 } elsif ($menu == 2) {
164 if ($command == 1) { $domain = command11
(); }
165 elsif ($command == 2) { $imapServerAddress = command12
(); }
166 elsif ($command == 3) { $imapPort = command13
(); }
167 elsif ($command == 4) { $useSendmail = command14
(); }
168 elsif ($command == 5) { $sendmail_path = command15
(); }
169 elsif ($command == 6) { $smtpServerAddress = command16
(); }
170 elsif ($command == 7) { $smtpPort = command17
(); }
171 } elsif ($menu == 3) {
172 if ($command == 1) { $default_folder_prefix = command21
(); }
173 elsif ($command == 2) { $show_prefix_option = command22
(); }
174 elsif ($command == 3) { $trash_folder = command23
(); }
175 elsif ($command == 4) { $sent_folder = command24
(); }
176 elsif ($command == 5) { $list_special_folders_first = command25
(); }
177 elsif ($command == 6) { $use_special_folder_color = command26
(); }
178 elsif ($command == 7) { $default_move_to_trash = command27
(); }
179 elsif ($command == 8) { $auto_expunge = command28
(); }
180 elsif ($command == 9) { $default_sub_of_inbox = command29
(); }
181 elsif ($command == 10){ $show_contain_subfolders_option = command210
(); }
182 elsif ($command == 11){ $special_folders = command211
(); }
183 } elsif ($menu == 4) {
184 } elsif ($menu == 5) {
185 } elsif ($menu == 6) {
186 } elsif ($menu == 7) {
187 if ($command == 1) { $motd = command71
(); }
192 ####################################################################################
196 print "We have tried to make the name SquirrelMail as transparent as\n";
197 print "possible. If you set up an organization name, most places where\n";
198 print "SquirrelMail would take credit will be credited to your organization.\n";
200 print "[$WHT$org_name$NRM]: $WHT";
201 $new_org_name = <STDIN
>;
202 if ($new_org_name eq "\n") {
203 $new_org_name = $org_name;
205 $new_org_name =~ s/[\r|\n]//g;
207 return $new_org_name;
213 print "Your organization's logo is an image that will be displayed at\n";
214 print "different times throughout SquirrelMail. This is asking for the\n";
215 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
216 print "(../images/logo.jpg) path to your logo.\n";
218 print "[$WHT$org_logo$NRM]: $WHT";
219 $new_org_logo = <STDIN
>;
220 if ($new_org_logo eq "\n") {
221 $new_org_logo = $org_logo;
223 $new_org_logo =~ s/[\r|\n]//g;
225 return $new_org_logo;
230 print "A title is what is displayed at the top of the browser window in\n";
231 print "the titlebar. Usually this will end up looking something like:\n";
232 print "\"Netscape: $org_title\"\n";
234 print "[$WHT$org_title$NRM]: $WHT";
235 $new_org_title = <STDIN
>;
236 if ($new_org_title eq "\n") {
237 $new_org_title = $org_title;
239 $new_org_title =~ s/[\r|\n]//g;
241 return $new_org_title;
244 ####################################################################################
248 print "The domain name is the suffix at the end of all email messages. If\n";
249 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
250 print "would be myorg.com.\n";
252 print "[$WHT$domain$NRM]: $WHT";
253 $new_domain = <STDIN
>;
254 if ($new_domain eq "\n") {
255 $new_domain = $domain;
257 $new_domain =~ s/[\r|\n]//g;
264 print "This is the address where your IMAP server resides.\n";
265 print "[$WHT$imapServerAddress$NRM]: $WHT";
266 $new_imapServerAddress = <STDIN
>;
267 if ($new_imapServerAddress eq "\n") {
268 $new_imapServerAddress = $imapServerAddress;
270 $new_imapServerAddress =~ s/[\r|\n]//g;
272 return $new_imapServerAddress;
277 print "This is the port that your IMAP server is on. Usually this is 143.\n";
278 print "[$WHT$imapPort$NRM]: $WHT";
279 $new_imapPort = <STDIN
>;
280 if ($new_imapPort eq "\n") {
281 $new_imapPort = $imapPort;
283 $new_imapPort =~ s/[\r|\n]//g;
285 return $new_imapPort;
290 print "You now need to choose the method that you will use for sending\n";
291 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
292 print "or use sendmail directly.\n";
293 if ($useSendmail eq "true") {
294 $default_value = "y";
296 $default_value = "n";
299 print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
300 $use_sendmail = <STDIN
>;
301 if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
302 $useSendmail = "true";
304 $useSendmail = "false";
311 if ($sendmail_path[0] !~ /./) {
312 $sendmail_path = "/usr/sbin/sendmail";
314 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
315 print "[$WHT$sendmail_path$NRM]: $WHT";
316 $new_sendmail_path = <STDIN
>;
317 if ($new_sendmail_path eq "\n") {
318 $new_sendmail_path = $sendmail_path;
320 $new_sendmail_path =~ s/[\r|\n]//g;
322 return $new_sendmail_path;
327 print "This is the location of your SMTP server.\n";
328 print "[$WHT$smtpServerAddress$NRM]: $WHT";
329 $new_smtpServerAddress = <STDIN
>;
330 if ($new_smtpServerAddress eq "\n") {
331 $new_smtpServerAddress = $smtpServerAddress;
333 $new_smtpServerAddress =~ s/[\r|\n]//g;
335 return $new_smtpServerAddress;
340 print "This is the port to connect to for SMTP. Usually 25.\n";
341 print "[$WHT$smtpPort$NRM]: $WHT";
342 $new_smtpPort = <STDIN
>;
343 if ($new_smtpPort eq "\n") {
344 $new_smtpPort = $smtpPort;
346 $new_smtpPort =~ s/[\r|\n]//g;
348 return $new_smtpPort;
353 print "\nYou can now create the welcome message that is displayed\n";
354 print "every time a user logs on. You can use HTML or just plain\n";
355 print "text.\n\n(Type @ on a blank line to exit)\n";
359 $line =~ s/[\r|\n]//g;
360 $line =~ s/ /\ \ /g;
362 $new_motd = $new_motd . $line;
364 } while ($line ne "@");
368 ################# FOLDERS ###################
370 # default_folder_prefix
372 print "Some IMAP servers (UW, for example) store mail and folders in\n";
373 print "your user space in a separate subdirectory. This is where you\n";
374 print "specify what that directory is.\n";
376 print "NOTE: If you use Cyrus, or some server that would not use this\n";
377 print " option, you must set this to 'none'.\n";
379 print "[$WHT$default_folder_prefix$NRM]: $WHT";
380 $new_default_folder_prefix = <STDIN
>;
381 if ($new_default_folder_prefix eq "\n") {
382 $new_default_folder_prefix = $default_folder_prefix;
384 $new_default_folder_prefix =~ s/[\r|\n]//g;
386 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
387 $new_default_folder_prefix = "";
389 $new_default_folder_prefix =~ s/\/*$//g
;
390 $new_default_folder_prefix =~ s/$/\//g
;
392 return $new_default_folder_prefix;
397 print "It is possible to set up the default folder prefix as a user\n";
398 print "specific option, where each user can specify what their mail\n";
399 print "folder is. If you set this to false, they will never see the\n";
400 print "option, but if it is true, this option will appear in the\n";
401 print "'options' section.\n";
403 print "NOTE: You set the default folder prefix in option '1' of this\n";
404 print " section. That will be the default if the user doesn't\n";
405 print " specify anything different.\n";
408 if ($show_prefix_option eq "true") {
409 $default_value = "y";
411 $default_value = "n";
414 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
416 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
417 $show_prefix_option = "true";
419 $show_prefix_option = "false";
421 return $show_prefix_option;
426 print "You can now specify where the default trash folder is located.\n";
427 print "On servers where you do not want this, you can set it to anything\n";
428 print "and set option 7 to false.\n";
430 print "This is relative to where the rest of your email is kept. You do\n";
431 print "not need to worry about their mail directory. If this folder\n";
432 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
433 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
436 print "[$WHT$trash_folder$NRM]: $WHT";
437 $new_trash_folder = <STDIN
>;
438 if ($new_trash_folder eq "\n") {
439 $new_trash_folder = $trash_folder;
441 $new_trash_folder =~ s/[\r|\n]//g;
443 return $new_trash_folder;
448 print "This is where messages that are sent will be stored. SquirrelMail\n";
449 print "by default puts a copy of all outgoing messages in this folder.\n";
451 print "This is relative to where the rest of your email is kept. You do\n";
452 print "not need to worry about their mail directory. If this folder\n";
453 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
454 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
457 print "[$WHT$sent_folder$NRM]: $WHT";
458 $new_sent_folder = <STDIN
>;
459 if ($new_sent_folder eq "\n") {
460 $new_sent_folder = $sent_folder;
462 $new_sent_folder =~ s/[\r|\n]//g;
464 return $new_sent_folder;
467 # List special folders first
469 print "SquirrelMail has what we call 'special folders' that are not\n";
470 print "manipulated and viewed like normal folders. Some examples of\n";
471 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
472 print "Simply asks if you want these folders listed first in the folder\n";
476 if ($list_special_folders_first eq "true") {
477 $default_value = "y";
479 $default_value = "n";
482 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
484 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
485 $list_special_folders_first = "true";
487 $list_special_folders_first = "false";
489 return $list_special_folders_first;
492 # Show special folders color
494 print "SquirrelMail has what we call 'special folders' that are not\n";
495 print "manipulated and viewed like normal folders. Some examples of\n";
496 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
497 print "wants to know if we should display special folders in a\n";
498 print "color than the other folders.\n";
501 if ($use_special_folder_color eq "true") {
502 $default_value = "y";
504 $default_value = "n";
507 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
509 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
510 $use_special_folder_color = "true";
512 $use_special_folder_color = "false";
514 return $use_special_folder_color;
517 # default move to trash
519 print "By default, should messages get moved to the trash folder? You\n";
520 print "can specify the default trash folder in option 3. If this is set\n";
521 print "to false, messages will get deleted immediately without moving\n";
522 print "to the trash folder.\n";
524 print "Trash folder is currently: $trash_folder\n";
527 if ($default_move_to_trash eq "true") {
528 $default_value = "y";
530 $default_value = "n";
532 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
534 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
535 $default_move_to_trash = "true";
537 $default_move_to_trash = "false";
539 return $default_move_to_trash;
544 print "The way that IMAP handles deleting messages is as follows. You\n";
545 print "mark the message as deleted, and then to 'really' delete it, you\n";
546 print "expunge it. This option asks if you want to just have messages\n";
547 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
548 print "messages too.\n";
551 if ($auto_expunge eq "true") {
552 $default_value = "y";
554 $default_value = "n";
556 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
558 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
559 $auto_expunge = "true";
561 $auto_expunge = "false";
563 return $auto_expunge;
566 # Default sub of inbox
568 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
569 print "This can cause some confusion in folder creation for users when\n";
570 print "they try to create folders and don't put it as a subfolder of INBOX\n";
571 print "and get permission errors. This option asks if you want folders\n";
572 print "to be subfolders of INBOX by default.\n";
575 if ($default_sub_of_inbox eq "true") {
576 $default_value = "y";
578 $default_value = "n";
580 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
582 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
583 $default_sub_of_inbox = "true";
585 $default_sub_of_inbox = "false";
587 return $default_sub_of_inbox;
590 # Show contain subfolder option
592 print "Some IMAP servers (UW) make it so that there are two types of\n";
593 print "folders. Those that contain messages, and those that contain\n";
594 print "subfolders. If this is the case for your server, set this to\n";
595 print "true, and it will ask the user whether the folder they are\n";
596 print "creating contains subfolders or messages.\n";
599 if ($show_contain_subfolders_option eq "true") {
600 $default_value = "y";
602 $default_value = "n";
604 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
606 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
607 $show_contain_subfolders_option = "true";
609 $show_contain_subfolders_option = "false";
611 return $show_contain_subfolders_option;
616 print "\nSpecial folders are folders that can't be manipulated like normal\n";
617 print "user-created folders. A couple of examples of these would be the\n";
618 print "trash folder, the sent folder, etc.\n";
619 print "Special Folders:\n";
622 while ($count < @special_folders) {
623 print " $count) $WHT" . $special_folders[$count] . "$NRM\n";
626 print "\n[folders] command (?=help) > ";
628 $input =~ s/[\r|\n]//g;
629 while ($input !~ /^d$/i) {
631 if ($input =~ /^\s*\+\s*.*/) {
632 $input =~ s/^\s*\+\s*//;
633 $special_folders[$#special_folders+1] = $input;
636 elsif ($input =~ /^\s*-\s*[0-9]?/i) {
637 if ($input =~ /[0-9]+\s*$/) {
639 $rem_num =~ s/^\s*-\s*//g;
640 $rem_num =~ s/\s*$//;
642 $rem_num = $#special_folders;
646 print "You cannot remove INBOX. It is a very special folder.\n";
649 @new_special_folders = ();
651 while ($count <= $#special_folders) {
652 if ($count != $rem_num) {
653 @new_special_folders = (@new_special_folders, $special_folders[$count]);
655 if ($count == $rem_num) {
656 print "Removed: $special_folders[$rem_num]\n";
662 print "Error: Can't delete an entry that's not there!\n";
664 @special_folders = @new_special_folders;
668 elsif ($input =~ /^\s*l\s*/i) {
671 while ($count < @special_folders) {
672 print " $count) $WHT" . $special_folders[$count] . "$NRM\n";
675 } elsif ($input =~ /^\s*\?\s*/) {
676 print ".-------------------------.\n";
677 print "| + Folder (add folder) |\n";
678 print "| - N (remove folder) |\n";
679 print "| l (list folders) |\n";
680 print "| d (done) |\n";
681 print "`-------------------------'\n";
685 print "Unrecognized command.\n";
688 print "\n[folders] command (?=help) > ";
690 $input =~ s/[\r|\n]//g;
692 return @special_folders;