Blame SOURCES/tigervnc-add-option-to-fallback-to-free-port.patch

12537a
diff --git a/unix/vncserver b/unix/vncserver
12537a
index 2ef436a..e032da5 100755
12537a
--- a/unix/vncserver
12537a
+++ b/unix/vncserver
12537a
@@ -137,7 +137,7 @@ if ($fontPath eq "") {
12537a
 # Check command line options
12537a
 
12537a
 &ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,"-kill",1,
12537a
-	      "-help",0,"-h",0,"--help",0,"-fp",1,"-list",0,"-fg",0,"-autokill",0,"-noxstartup",0,"-xstartup",1);
12537a
+	      "-help",0,"-h",0,"--help",0,"-fp",1,"-list",0,"-fg",0,"-autokill",0,"-noxstartup",0,"-xstartup",1,"-fallbacktofreeport",0);
12537a
 
12537a
 &Usage() if ($opt{'-help'} || $opt{'-h'} || $opt{'--help'});
12537a
 
12537a
@@ -184,7 +184,13 @@ if ((@ARGV > 0) && ($ARGV[0] =~ /^:(\d+)$/)) {
12537a
     $displayNumber = $1;
12537a
     shift(@ARGV);
12537a
     if (!&CheckDisplayNumber($displayNumber)) {
12537a
-	die "A VNC server is already running as :$displayNumber\n";
12537a
+        if ($opt{'-fallbacktofreeport'}) {
12537a
+            warn "A VNC server is already running as :$displayNumber\n";
12537a
+            $displayNumber = &GetDisplayNumber();
12537a
+            warn "Using port :$displayNumber as fallback\n";
12537a
+        } else {
12537a
+            die "A VNC server is already running as :$displayNumber\n";
12537a
+        }
12537a
     }
12537a
 } elsif ((@ARGV > 0) && ($ARGV[0] !~ /^-/) && ($ARGV[0] !~ /^\+/)) {
12537a
     &Usage();
12537a
@@ -688,6 +694,7 @@ sub Usage
12537a
 	"                 [-autokill]\n".
12537a
 	"                 [-noxstartup]\n".
12537a
 	"                 [-xstartup <file>]\n".
12537a
+	"                 [-fallbacktofreeport]\n".
12537a
 	"                 <Xvnc-options>...\n\n".
12537a
 	"       $prog -kill <X-display>\n\n".
12537a
 	"       $prog -list\n\n");