updated config script, and added 2 people to AUTHORs file
[squirrelmail.git] / config / conf.pl
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
7 ############################################################
8 $WHT = "\x1B[37;1m";
9 $NRM = "\x1B[0m";
10
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");
17 } else {
18 print "No config file found. Reading from config_defaults.php.\n\n";
19 open (FILE, "config_default.php");
20 }
21
22 # Reads and parses the current configuration file (either
23 # config.php or config_default.php).
24
25 while ($line = <FILE>) {
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 }
60 }
61 if ($useSendmail ne "true") {
62 $useSendmail = "false";
63 }
64 if (!$sendmail_path) {
65 $sendmail_path = "/usr/sbin/sendmail";
66 }
67
68
69 #####################################################################################
70
71 while (($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
165 # org_name
166 sub 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";
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 }
178 return $new_org_name;
179 }
180
181
182 # org_logo
183 sub 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";
189 print "[$WHT$org_logo$NRM]: $WHT";
190 $new_org_logo = <STDIN>;
191 if ($new_org_logo eq "\n") {
192 $new_org_logo = $org_logo;
193 } else {
194 $new_org_logo =~ s/[\r|\n]//g;
195 }
196 return $new_org_logo;
197 }
198
199 # org_title
200 sub 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";
205 print "[$WHT$org_title$NRM]: $WHT";
206 $new_org_title = <STDIN>;
207 if ($new_org_title eq "\n") {
208 $new_org_title = $org_title;
209 } else {
210 $new_org_title =~ s/[\r|\n]//g;
211 }
212 return $new_org_title;
213 }
214
215 ####################################################################################
216
217 # domain
218 sub 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";
222 print "\n";
223 print "[$WHT$domain$NRM]: $WHT";
224 $new_domain = <STDIN>;
225 if ($new_domain eq "\n") {
226 $new_domain = $domain;
227 } else {
228 $new_domain =~ s/[\r|\n]//g;
229 }
230 return $new_domain;
231 }
232
233 # imapServerAddress
234 sub 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 }
245
246 # imapPort
247 sub 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
260 sub 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 }
269 print "\n";
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 }
279
280 # sendmail_path
281 sub 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 }
295
296 # smtpServerAddress
297 sub 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
310 sub 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;
320 }