mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2025-01-05 21:48:49 +01:00
vncserver: extract DetectDisplayNumberFromCliArgs()
This commit is contained in:
parent
55525a627b
commit
c79da47c21
@ -78,19 +78,7 @@ chop($host = `uname -n`);
|
||||
# Create the user's vnc directory if necessary.
|
||||
&CreateDotVncDir();
|
||||
|
||||
# Find display number.
|
||||
if ((@ARGV > 0) && ($ARGV[0] =~ /^:(\d+)$/)) {
|
||||
$displayNumber = $1;
|
||||
shift(@ARGV);
|
||||
if (!&CheckDisplayNumber($displayNumber)) {
|
||||
die "A VNC server is already running as :$displayNumber\n";
|
||||
}
|
||||
} elsif ((@ARGV > 0) && ($ARGV[0] !~ /^-/) && ($ARGV[0] !~ /^\+/)) {
|
||||
&Usage();
|
||||
} else {
|
||||
$displayNumber = &GetLowestAvailableDisplayNumber();
|
||||
}
|
||||
|
||||
&DetectDisplayNumberFromCliArgs();
|
||||
$vncPort = 5900 + $displayNumber;
|
||||
|
||||
if ($opt{'-name'}) {
|
||||
@ -953,3 +941,20 @@ sub AskUserToChooseDeOrManualXstartup {
|
||||
system($selectDeCmd) == 0 || die("Failed to execute $selectDeCmd\n");
|
||||
}
|
||||
}
|
||||
|
||||
sub DetectDisplayNumberFromCliArgs {
|
||||
if (@ARGV == 0) {
|
||||
$displayNumber = &GetLowestAvailableDisplayNumber();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($ARGV[0] =~ /^:(\d+)$/) {
|
||||
$displayNumber = $1;
|
||||
shift(@ARGV);
|
||||
if (!&CheckDisplayNumber($displayNumber)) {
|
||||
die "A VNC server is already running as :$displayNumber\n";
|
||||
}
|
||||
} elsif (($ARGV[0] !~ /^-/) && ($ARGV[0] !~ /^\+/)) {
|
||||
&Usage();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user