vncserver: extract DetectDisplay() and RunXstartup()
This commit is contained in:
@@ -404,39 +404,10 @@ if (! $skipxstartup) {
|
|||||||
}
|
}
|
||||||
warn "Log file is $desktopLog\n\n";
|
warn "Log file is $desktopLog\n\n";
|
||||||
|
|
||||||
# If the unix domain socket exists then use that (DISPLAY=:n) otherwise use
|
&DetectDisplay();
|
||||||
# TCP (DISPLAY=host:n)
|
|
||||||
|
|
||||||
if (-e "/tmp/.X11-unix/X$displayNumber" ||
|
|
||||||
-e "/usr/spool/sockets/X11/$displayNumber")
|
|
||||||
{
|
|
||||||
$ENV{DISPLAY}= ":$displayNumber";
|
|
||||||
} else {
|
|
||||||
$ENV{DISPLAY}= "$host:$displayNumber";
|
|
||||||
}
|
|
||||||
$ENV{VNCDESKTOP}= $desktopName;
|
$ENV{VNCDESKTOP}= $desktopName;
|
||||||
|
|
||||||
if ($opt{'-fg'}) {
|
&RunXstartup();
|
||||||
if (! $skipxstartup) {
|
|
||||||
system("$xstartupFile >> " . "edString($desktopLog) . " 2>&1");
|
|
||||||
}
|
|
||||||
if (kill 0, `cat $pidFile`) {
|
|
||||||
$opt{'-kill'} = ':'.$displayNumber;
|
|
||||||
&Kill();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($opt{'-autokill'}) {
|
|
||||||
if (! $skipxstartup) {
|
|
||||||
system("($xstartupFile; $0 -kill :$displayNumber) >> "
|
|
||||||
. "edString($desktopLog) . " 2>&1 &");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (! $skipxstartup) {
|
|
||||||
system("$xstartupFile >> " . "edString($desktopLog)
|
|
||||||
. " 2>&1 &");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
@@ -916,3 +887,40 @@ sub CreateXstartup
|
|||||||
close(XSTARTUP);
|
close(XSTARTUP);
|
||||||
chmod 0755, "$xstartupFile";
|
chmod 0755, "$xstartupFile";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub DetectDisplay {
|
||||||
|
# If the unix domain socket exists then use that (DISPLAY=:n) otherwise use
|
||||||
|
# TCP (DISPLAY=host:n)
|
||||||
|
|
||||||
|
if (-e "/tmp/.X11-unix/X$displayNumber" ||
|
||||||
|
-e "/usr/spool/sockets/X11/$displayNumber")
|
||||||
|
{
|
||||||
|
$ENV{DISPLAY}= ":$displayNumber";
|
||||||
|
} else {
|
||||||
|
$ENV{DISPLAY}= "$host:$displayNumber";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub RunXstartup {
|
||||||
|
if ($opt{'-fg'}) {
|
||||||
|
if (! $skipxstartup) {
|
||||||
|
system("$xstartupFile >> " . "edString($desktopLog) . " 2>&1");
|
||||||
|
}
|
||||||
|
if (kill 0, `cat $pidFile`) {
|
||||||
|
$opt{'-kill'} = ':'.$displayNumber;
|
||||||
|
&Kill();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($opt{'-autokill'}) {
|
||||||
|
if (! $skipxstartup) {
|
||||||
|
system("($xstartupFile; $0 -kill :$displayNumber) >> "
|
||||||
|
. "edString($desktopLog) . " 2>&1 &");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (! $skipxstartup) {
|
||||||
|
system("$xstartupFile >> " . "edString($desktopLog)
|
||||||
|
. " 2>&1 &");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user