mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2025-06-22 18:51:48 +02:00
vncserver: extract CheckCliOptionsForBeingValid()
This commit is contained in:
parent
27f7f823fe
commit
21b42e462b
@ -78,7 +78,9 @@ chop($host = `uname -n`);
|
|||||||
# Create the user's vnc directory if necessary.
|
# Create the user's vnc directory if necessary.
|
||||||
&CreateDotVncDir();
|
&CreateDotVncDir();
|
||||||
|
|
||||||
&DetectDisplayNumberFromCliArgs();
|
$displayNumber = &DetectDisplayNumberFromCliArgs() ||
|
||||||
|
&GetLowestAvailableDisplayNumber();
|
||||||
|
&CheckCliOptionsForBeingValid();
|
||||||
$vncPort = 5900 + $displayNumber;
|
$vncPort = 5900 + $displayNumber;
|
||||||
|
|
||||||
$desktopName = $opt{'-name'} || "$host:$displayNumber ($ENV{USER})";
|
$desktopName = $opt{'-name'} || "$host:$displayNumber ($ENV{USER})";
|
||||||
@ -793,21 +795,35 @@ sub AskUserToChooseDeOrManualXstartup {
|
|||||||
|
|
||||||
sub DetectDisplayNumberFromCliArgs {
|
sub DetectDisplayNumberFromCliArgs {
|
||||||
if (@ARGV == 0) {
|
if (@ARGV == 0) {
|
||||||
$displayNumber = &GetLowestAvailableDisplayNumber();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $displayNumber;
|
||||||
if ($ARGV[0] =~ /^:(\d+)$/) {
|
if ($ARGV[0] =~ /^:(\d+)$/) {
|
||||||
$displayNumber = $1;
|
$displayNumber = $1;
|
||||||
shift(@ARGV);
|
shift(@ARGV);
|
||||||
if (!&CheckDisplayNumber($displayNumber)) {
|
if (!&CheckDisplayNumber($displayNumber)) {
|
||||||
die "A VNC server is already running as :$displayNumber\n";
|
die "A VNC server is already running as :$displayNumber\n";
|
||||||
}
|
}
|
||||||
} elsif (($ARGV[0] !~ /^-/) && ($ARGV[0] !~ /^\+/)) {
|
|
||||||
&Usage();
|
|
||||||
} else {
|
|
||||||
$displayNumber = &GetLowestAvailableDisplayNumber();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$displayNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub CheckCliOptionsForBeingValid {
|
||||||
|
if (@ARGV == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! &IsCliOption($ARGV[0])) {
|
||||||
|
&Usage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub IsCliOption {
|
||||||
|
my $arg = shift;
|
||||||
|
|
||||||
|
($arg =~ /^-/) || ($arg =~ /^\+/);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub SetReasonabeDefaults {
|
sub SetReasonabeDefaults {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user