[X2go-Dev] [PATCH] Make sure the [...] - The right patch!

Reinhard Tartler siretart at tauware.de
Fri Dec 9 21:53:05 CET 2011


On Fr, Dez 09, 2011 at 18:58:35 (CET), Moritz Struebe wrote:


> --- a/x2goserver/bin/x2gostartagent
> +++ b/x2goserver/bin/x2gostartagent
> @@ -120,8 +120,8 @@ USED_DISPLAYS=`$X2GO_LIB_PATH/x2gogetdisplays $HOSTNAME`
>  while [ "$OUTPUT"  != "inserted" ]; do
>  	X2GO_PORT=$(($X2GO_PORT + 1))
>  	X2GO_PORT=`echo "for(\\$i=$X2GO_PORT;\\$br ne \"true\";\\$i++){ if(\"$USED_DISPLAYS\" =~ m/\\|\\$i\\|/){\\$br=\"false\";}else{\\$br=\"true\";print \\$i;}}"|perl`
> -
> -	if  [ -e "/tmp/.X${X2GO_PORT}-lock" ] || [ -e "/tmp/.X11-unix/X${X2GO_PORT}" ]; then
> +	#Test if the session is already in use. nxagent uses 6000+DISPLAY to open a port. Therefore this must be tested, too.
> +	if  [ -e "/tmp/.X${X2GO_PORT}-lock" ] || [ -e "/tmp/.X11-unix/X${X2GO_PORT}" ] || `netstat -ntl | grep ":${X2GO_PORT} "` ; then
>  		OUTPUT="XXX"
>  	else
>  		SESSION_NAME=${USER}-${X2GO_PORT}-`date +"%s"`

That looks overly convoluted to me. What about this (untested, but shell
syntax works):

if  [ -e "/tmp/.X${X2GO_PORT}-lock" ] || 
    [ -e "/tmp/.X11-unix/X${X2GO_PORT}" ] ||
    netstat -ntl 2>/dev/null | grep -q ":${X2GO_PORT}"; then
	OUTPUT="XXX"
else
	SESSION_NAME=${USER}-${X2GO_PORT}-`date +"%s"`
fi

Cheers,
Reinhard

-- 
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4




More information about the x2go-dev mailing list