Handle hostnames with upper-case letters
[webmin.git] / pserver / setup.cgi.bak
1 #!/usr/local/bin/perl
2 # setup.cgi
3 # Setup the CVS server in inetd or xinetd
4
5 require './pserver-lib.pl';
6 $inet = &check_inetd();
7 $restart = $inet->{'type'} if ($inet);
8 if (!$inet) {
9         # Need to setup for the first time
10         if ($has_xinetd) {
11                 # Just add an unlisted service
12                 $restart = "xinetd";
13                 }
14         elsif ($has_inetd) {
15                 # Is there already a service on port 2401, or named cvspserver?
16                 foreach $s (&inetd::list_services()) {
17                         local @al = split(/\s+/, $s->[4]);
18                         if ($s->[2] == $cvs_port ||
19                             $s->[1] eq $cvs_inet_name ||
20                             &indexof($cvs_inet_name, @al) >= 0) {
21                                 # Yes! Use it
22                                 $sname = $s->[1];
23                                 last;
24                                 }
25                         }
26                 if (!$sname) {
27                         $sname = $cvs_inet_name;
28                         &inetd::create_service($sname, $cvs_port, "tcp", undef);
29                         }
30                 &inetd::create_inet(1, $sname, "stream", "tcp", "nowait",
31                                     "root", $cvs_path, "cvs -f --allow-root '$config{'cvsroot'}' pserver");
32                 $restart = "inetd";
33                 }
34         else {
35                 }
36         }
37 elsif ($inet->{'active'}) {
38         # Need to de-activate
39         if ($inet->{'type'} eq 'inetd') {
40                 local @i = @{$inet->{'inetd'}};
41                 &inetd::modify_inet($i[0], 0, $i[3], $i[4], $i[5],
42                                     $i[6], $i[7], $i[8], $i[9], $i[10]);
43                 }
44         else {
45                 }
46         }
47 else {
48         # Need to activate
49         if ($inet->{'type'} eq 'inetd') {
50                 local @i = @{$inet->{'inetd'}};
51                 &inetd::modify_inet($i[0], 1, $i[3], $i[4], $i[5],
52                                     $i[6], $i[7], $i[8], $i[9], $i[10]);
53                 }
54         else {
55                 }
56         }
57
58 # Restart inetd or xinetd
59 if ($restart eq "inetd") {
60         %iconfig = &foreign_config("inetd");
61         &system_logged(
62                 "$iconfig{'restart_command'} >/dev/null 2>&1 </dev/null");
63         }
64 else {
65         %xconfig = &foreign_config("xinetd");
66         if (open(PID, $xconfig{'pid_file'})) {
67                 chop($pid = <PID>);
68                 close(PID);
69                 kill('USR2', $pid);
70                 }
71         }
72 &redirect("");
73