updated config script, and added 2 people to AUTHORs file
[squirrelmail.git] / config / conf.pl
CommitLineData
bbd30ac8 1#!/usr/bin/perl
2# conf.pl
3# Written March 26, 2000
4# Luke Ehresman (lehresma@css.tayloru.edu)
5#
6# A simple configure script to configure squirrelmail
5b6ae78a 7############################################################
bbd30ac8 8$WHT = "\x1B[37;1m";
9$NRM = "\x1B[0m";
10
5b6ae78a 11############################################################
bbd30ac8 12# First, lets read in the data already in there...
5b6ae78a 13############################################################
bbd30ac8 14if ( -e "config.php") {
5b6ae78a 15 print "The file \"config.php\" exists. Using it for defaults.\n\n";
16 open (FILE, "config.php");
bbd30ac8 17} else {
5b6ae78a 18 print "No config file found. Reading from config_defaults.php.\n\n";
19 open (FILE, "config_default.php");
bbd30ac8 20}
21
22# Reads and parses the current configuration file (either
23# config.php or config_default.php).
24
25while ($line = <FILE>) {
5b6ae78a 26 if ($line =~ /^\s+\$/) {
27 $line =~ s/^\s+\$//;
28 $var = $line;
29
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;
36
37 if ($options[0] =~ /^special_folders/) {
38 if ($options[0] =~ /\[.*\]$/) {
39 $sub = $options[0];
40 $sub =~ s/\]$//;
41 $sub = substr ($sub, @sub-1, 1);
42
43 $special_folders[$sub] = $options[1];
44 }
45 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
46 $sub = $options[0];
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"\]/) {
51 $sub = $options[0];
52 $sub =~ s/\]\["NAME"\]//;
53 $sub = substr ($sub, @sub-1, 1);
54 $theme_name[$sub] = $options[1];
55 } else {
56 ${$options[0]} = $options[1];
57 }
58 }
59 }
bbd30ac8 60}
828b4753 61if ($useSendmail ne "true") {
62 $useSendmail = "false";
63}
64if (!$sendmail_path) {
65 $sendmail_path = "/usr/sbin/sendmail";
66}
bbd30ac8 67
bbd30ac8 68
5b6ae78a 69#####################################################################################
70
828b4753 71while (($command ne "q") && ($command ne "Q")) {
72 system "clear";
73 if ($menu == 0) {
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";
79 print "5. Themes\n";
80 print "6. Address Books (LDAP)\n";
81 print "7. Message of the Day (MOTD)\n";
82 print "\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";
88 print "\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";
98 } else {
99 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
100 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
101 }
102 print "\n";
103 print "R Return to Main Menu\n";
104 } elsif ($menu == 3) {
105 print $WHT."Folder Defaults\n".$NRM;
106 print "\n";
107 print "R Return to Main Menu\n";
108 } elsif ($menu == 4) {
109 print $WHT."General Options\n".$NRM;
110 print "\n";
111 print "R Return to Main Menu\n";
112 } elsif ($menu == 5) {
113 print $WHT."Themes\n".$NRM;
114 print "\n";
115 print "R Return to Main Menu\n";
116 } elsif ($menu == 6) {
117 print $WHT."Address Books (LDAP)\n".$NRM;
118 print "\n";
119 print "R Return to Main Menu\n";
120 } elsif ($menu == 7) {
121 print $WHT."Message of the Day (MOTD)\n".$NRM;
122 print "\n";
123 print "R Return to Main Menu\n";
124 }
125 print "X Quit without saving\n";
126 print "Q Save and exit\n";
127
128 print "\n";
129 print "Command >> ".$WHT;
130 $command = <STDIN>;
131 $command =~ s/[\n|\r]//g;
132 print "$NRM\n";
133
134 # Read the commands they entered.
135 if (($command eq "R") || ($command eq "r")) {
136 $menu = 0;
137 } else {
138 if ($menu == 0) {
139 if (($command > 0) && ($command < 7)) {
140 $menu = $command;
141 }
142 } elsif ($menu == 1) {
143 if ($command == 1) { $org_name = command1 (); }
144 elsif ($command == 2) { $org_logo = command2 (); }
145 elsif ($command == 3) { $org_title = command3 (); }
146 } elsif ($menu == 2) {
147 if ($command == 1) { $domain = command11 (); }
148 elsif ($command == 2) { $imapServerAddress = command12 (); }
149 elsif ($command == 3) { $imapPort = command13 (); }
150 elsif ($command == 4) { $useSendmail = command14 (); }
151 elsif ($command == 5) { $sendmail_path = command15 (); }
152 elsif ($command == 6) { $smtpServerAddress = command16 (); }
153 elsif ($command == 7) { $smtpPort = command17 (); }
154 } elsif ($menu == 3) {
155 } elsif ($menu == 4) {
156 } elsif ($menu == 5) {
157 } elsif ($menu == 6) {
158 } elsif ($menu == 7) {
159 }
160 }
161}
162
163####################################################################################
164
5b6ae78a 165# org_name
166sub command1 {
167 print "We have tried to make the name SquirrelMail as transparent as\n";
168 print "possible. If you set up an organization name, most places where\n";
169 print "SquirrelMail would take credit will be credited to your organization.\n";
170 print "\n";
828b4753 171 print "[$WHT$org_name$NRM]: $WHT";
172 $new_org_name = <STDIN>;
173 if ($new_org_name eq "\n") {
174 $new_org_name = $org_name;
175 } else {
176 $new_org_name =~ s/[\r|\n]//g;
177 }
5b6ae78a 178 return $new_org_name;
179}
180
828b4753 181
5b6ae78a 182# org_logo
183sub command2 {
184 print "Your organization's logo is an image that will be displayed at\n";
185 print "different times throughout SquirrelMail. This is asking for the\n";
186 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
187 print "(../images/logo.jpg) path to your logo.\n";
188 print "\n";
828b4753 189 print "[$WHT$org_logo$NRM]: $WHT";
5b6ae78a 190 $new_org_logo = <STDIN>;
191 if ($new_org_logo eq "\n") {
192 $new_org_logo = $org_logo;
bbd30ac8 193 } else {
5b6ae78a 194 $new_org_logo =~ s/[\r|\n]//g;
bbd30ac8 195 }
5b6ae78a 196 return $new_org_logo;
197}
198
199# org_title
200sub command3 {
201 print "A title is what is displayed at the top of the browser window in\n";
202 print "the titlebar. Usually this will end up looking something like:\n";
203 print "\"Netscape: $org_title\"\n";
204 print "\n";
828b4753 205 print "[$WHT$org_title$NRM]: $WHT";
5b6ae78a 206 $new_org_title = <STDIN>;
207 if ($new_org_title eq "\n") {
208 $new_org_title = $org_title;
bbd30ac8 209 } else {
5b6ae78a 210 $new_org_title =~ s/[\r|\n]//g;
bbd30ac8 211 }
5b6ae78a 212 return $new_org_title;
213}
5b6ae78a 214
828b4753 215####################################################################################
5b6ae78a 216
828b4753 217# domain
218sub command11 {
219 print "The domain name is the suffix at the end of all email messages. If\n";
220 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
221 print "would be myorg.com.\n";
5b6ae78a 222 print "\n";
828b4753 223 print "[$WHT$domain$NRM]: $WHT";
224 $new_domain = <STDIN>;
225 if ($new_domain eq "\n") {
226 $new_domain = $domain;
5b6ae78a 227 } else {
828b4753 228 $new_domain =~ s/[\r|\n]//g;
5b6ae78a 229 }
828b4753 230 return $new_domain;
231}
5b6ae78a 232
828b4753 233# imapServerAddress
234sub command12 {
235 print "This is the address where your IMAP server resides.\n";
236 print "[$WHT$imapServerAddress$NRM]: $WHT";
237 $new_imapServerAddress = <STDIN>;
238 if ($new_imapServerAddress eq "\n") {
239 $new_imapServerAddress = $imapServerAddress;
240 } else {
241 $new_imapServerAddress =~ s/[\r|\n]//g;
242 }
243 return $new_imapServerAddress;
244}
5b6ae78a 245
828b4753 246# imapPort
247sub command13 {
248 print "This is the port that your IMAP server is on. Usually this is 143.\n";
249 print "[$WHT$imapPort$NRM]: $WHT";
250 $new_imapPort = <STDIN>;
251 if ($new_imapPort eq "\n") {
252 $new_imapPort = $imapPort;
253 } else {
254 $new_imapPort =~ s/[\r|\n]//g;
255 }
256 return $new_imapPort;
257}
258
259# useSendmail
260sub command14 {
261 print "You now need to choose the method that you will use for sending\n";
262 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
263 print "or use sendmail directly.\n";
264 if ($useSendmail eq "true") {
265 $default_value = "y";
266 } else {
267 $default_value = "n";
268 }
5b6ae78a 269 print "\n";
828b4753 270 print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
271 $use_sendmail = <STDIN>;
272 if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
273 $useSendmail = "true";
274 } else {
275 $useSendmail = "false";
276 }
277 return $useSendmail;
278}
5b6ae78a 279
828b4753 280# sendmail_path
281sub command15 {
282 if ($sendmail_path[0] !~ /./) {
283 $sendmail_path = "/usr/sbin/sendmail";
284 }
285 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
286 print "[$WHT$sendmail_path$NRM]: $WHT";
287 $new_sendmail_path = <STDIN>;
288 if ($new_sendmail_path eq "\n") {
289 $new_sendmail_path = $sendmail_path;
290 } else {
291 $new_sendmail_path =~ s/[\r|\n]//g;
292 }
293 return $new_sendmail_path;
294}
5b6ae78a 295
828b4753 296# smtpServerAddress
297sub command16 {
298 print "This is the location of your SMTP server.\n";
299 print "[$WHT$smtpServerAddress$NRM]: $WHT";
300 $new_smtpServerAddress = <STDIN>;
301 if ($new_smtpServerAddress eq "\n") {
302 $new_smtpServerAddress = $smtpServerAddress;
303 } else {
304 $new_smtpServerAddress =~ s/[\r|\n]//g;
305 }
306 return $new_smtpServerAddress;
307}
308
309# smtpPort
310sub command17 {
311 print "This is the port to connect to for SMTP. Usually 25.\n";
312 print "[$WHT$smtpPort$NRM]: $WHT";
313 $new_smtpPort = <STDIN>;
314 if ($new_smtpPort eq "\n") {
315 $new_smtpPort = $smtpPort;
316 } else {
317 $new_smtpPort =~ s/[\r|\n]//g;
318 }
319 return $new_smtpPort;
bbd30ac8 320}