mirror of
https://github.com/webmin/webmin.git
synced 2026-02-08 08:19:57 +00:00
74 lines
1.7 KiB
Perl
74 lines
1.7 KiB
Perl
#!/usr/local/bin/perl
|
|
# setup.cgi
|
|
# Setup the CVS server in inetd or xinetd
|
|
|
|
require './pserver-lib.pl';
|
|
$inet = &check_inetd();
|
|
$restart = $inet->{'type'} if ($inet);
|
|
if (!$inet) {
|
|
# Need to setup for the first time
|
|
if ($has_xinetd) {
|
|
# Just add an unlisted service
|
|
$restart = "xinetd";
|
|
}
|
|
elsif ($has_inetd) {
|
|
# Is there already a service on port 2401, or named cvspserver?
|
|
foreach $s (&inetd::list_services()) {
|
|
local @al = split(/\s+/, $s->[4]);
|
|
if ($s->[2] == $cvs_port ||
|
|
$s->[1] eq $cvs_inet_name ||
|
|
&indexof($cvs_inet_name, @al) >= 0) {
|
|
# Yes! Use it
|
|
$sname = $s->[1];
|
|
last;
|
|
}
|
|
}
|
|
if (!$sname) {
|
|
$sname = $cvs_inet_name;
|
|
&inetd::create_service($sname, $cvs_port, "tcp", undef);
|
|
}
|
|
&inetd::create_inet(1, $sname, "stream", "tcp", "nowait",
|
|
"root", $cvs_path, "cvs -f --allow-root '$config{'cvsroot'}' pserver");
|
|
$restart = "inetd";
|
|
}
|
|
else {
|
|
}
|
|
}
|
|
elsif ($inet->{'active'}) {
|
|
# Need to de-activate
|
|
if ($inet->{'type'} eq 'inetd') {
|
|
local @i = @{$inet->{'inetd'}};
|
|
&inetd::modify_inet($i[0], 0, $i[3], $i[4], $i[5],
|
|
$i[6], $i[7], $i[8], $i[9], $i[10]);
|
|
}
|
|
else {
|
|
}
|
|
}
|
|
else {
|
|
# Need to activate
|
|
if ($inet->{'type'} eq 'inetd') {
|
|
local @i = @{$inet->{'inetd'}};
|
|
&inetd::modify_inet($i[0], 1, $i[3], $i[4], $i[5],
|
|
$i[6], $i[7], $i[8], $i[9], $i[10]);
|
|
}
|
|
else {
|
|
}
|
|
}
|
|
|
|
# Restart inetd or xinetd
|
|
if ($restart eq "inetd") {
|
|
%iconfig = &foreign_config("inetd");
|
|
&system_logged(
|
|
"$iconfig{'restart_command'} >/dev/null 2>&1 </dev/null");
|
|
}
|
|
else {
|
|
%xconfig = &foreign_config("xinetd");
|
|
if (open(PID, $xconfig{'pid_file'})) {
|
|
chop($pid = <PID>);
|
|
close(PID);
|
|
kill('USR2', $pid);
|
|
}
|
|
}
|
|
&redirect("");
|
|
|