From 861cb06de563aed2f2afe759898b4a7ff2b116b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lloren=C3=A7=20Garcia=20Martinez?= Date: Fri, 23 Oct 2015 13:37:42 +0200 Subject: [PATCH] new option -noxstartup to not load any xstartup script file --- unix/vncserver | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/unix/vncserver b/unix/vncserver index 64d10c5b..093d9acd 100755 --- a/unix/vncserver +++ b/unix/vncserver @@ -53,6 +53,7 @@ $vncJavaFiles = (((-d "$vncClasses") && "$vncClasses") || ((-d "/usr/local/vnc/classes") && "/usr/local/vnc/classes")); $vncUserDir = "$ENV{HOME}/.vnc"; +$skipxstartup = 0; $xauthorityFile = "$ENV{XAUTHORITY}" || "$ENV{HOME}/.Xauthority"; $defaultXStartup @@ -122,7 +123,7 @@ if ($fontPath eq "") { # Check command line options &ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,"-kill",1, - "-help",0,"-h",0,"--help",0,"-fp",1,"-list",0,"-fg",0,"-autokill",0); + "-help",0,"-h",0,"--help",0,"-fp",1,"-list",0,"-fg",0,"-autokill",0,"-noxstartup",0); &Usage() if ($opt{'-help'} || $opt{'-h'} || $opt{'--help'}); @@ -144,6 +145,9 @@ if ($opt{'-depth'}) { if ($opt{'-pixelformat'}) { $pixelformat = $opt{'-pixelformat'}; } +if ($opt{'-noxstartup'}) { + $skipxstartup = 1; +} if ($opt{'-fp'}) { $fontPath = $opt{'-fp'}; $fpArgSpecified = 1; @@ -313,17 +317,21 @@ warn "\nNew '$desktopName' desktop is $host:$displayNumber\n\n"; # Create the user's xstartup script if necessary. -if (!(-e "$vncUserDir/xstartup")) { - warn "Creating default startup script $vncUserDir/xstartup\n"; - open(XSTARTUP, ">$vncUserDir/xstartup"); - print XSTARTUP $defaultXStartup; - close(XSTARTUP); - chmod 0755, "$vncUserDir/xstartup"; +if (! $skipxstartup) { + if (!(-e "$vncUserDir/xstartup")) { + warn "Creating default startup script $vncUserDir/xstartup\n"; + open(XSTARTUP, ">$vncUserDir/xstartup"); + print XSTARTUP $defaultXStartup; + close(XSTARTUP); + chmod 0755, "$vncUserDir/xstartup"; + } } # Run the X startup script. -warn "Starting applications specified in $vncUserDir/xstartup\n"; +if (! $skipxstartup) { + warn "Starting applications specified in $vncUserDir/xstartup\n"; +} warn "Log file is $desktopLog\n\n"; # If the unix domain socket exists then use that (DISPLAY=:n) otherwise use @@ -341,18 +349,24 @@ $ENV{VNCDESKTOP}= $desktopName; system($exedir."vncconfig -nowin >> " . "edString($desktopLog) . " 2>&1 &"); if ($opt{'-fg'}) { - system("$vncUserDir/xstartup >> " . "edString($desktopLog) . " 2>&1"); + if (! $skipxstartup) { + system("$vncUserDir/xstartup >> " . "edString($desktopLog) . " 2>&1"); + } if (kill 0, `cat $pidFile`) { $opt{'-kill'} = ':'.$displayNumber; &Kill(); } } else { if ($opt{'-autokill'}) { - system("($vncUserDir/xstartup; $0 -kill :$displayNumber) >> " - . "edString($desktopLog) . " 2>&1 &"); + if (! $skipxstartup) { + system("($vncUserDir/xstartup; $0 -kill :$displayNumber) >> " + . "edString($desktopLog) . " 2>&1 &"); + } } else { - system("$vncUserDir/xstartup >> " . "edString($desktopLog) - . " 2>&1 &"); + if (! $skipxstartup) { + system("$vncUserDir/xstartup >> " . "edString($desktopLog) + . " 2>&1 &"); + } } } @@ -569,6 +583,7 @@ sub Usage " [-fp ]\n". " [-fg]\n". " [-autokill]\n". + " [-noxstartup]\n". " ...\n\n". " $prog -kill \n\n". " $prog -list\n\n"); -- 2.39.5