Handle hostnames with upper-case letters
[webmin.git] / apache / restart.cgi
1 #!/usr/local/bin/perl
2 # restart.cgi
3 # Send a SIGHUP to apache
4
5 require './apache-lib.pl';
6 &ReadParse();
7 &error_setup($text{'restart_err'});
8
9 $access{'apply'} || &error($text{'restart_ecannot'});
10 $conf = &get_config();
11
12 if ($config{'test_config'}) {
13         $err = &test_config();
14         &error("<pre>".&html_escape($err)."</pre>") if ($err);
15         }
16 $err = &restart_apache();
17 &error($err) if ($err);
18
19 # Check if restart was successful.. some config file error may have caused it
20 # to silently fail
21 for($i=0; $i<5; $i++) {
22         if (&is_apache_running()) {
23                 $running = 1;
24                 last;
25                 }
26         sleep(1);
27         }
28 if (!$running) {
29         # Not running..  find out why
30         $errorlogstr = &find_directive_struct("ErrorLog", $conf);
31         $errorlog = $errorlogstr ? $errorlogstr->{'words'}->[0]
32                                  : "logs/error_log";
33         if ($errorlog eq 'syslog' || $errorlog =~ /^\|/) {
34                 &error($text{'restart_eunknown'});
35                 }
36         else {
37                 $errorlog = &server_root($errorlog, $conf);
38                 $out = `tail -5 $errorlog`;
39                 &error("<pre>$out</pre>");
40                 }
41         }
42 &webmin_log("apply");
43 &redirect($in{'redir'});
44