#!/bin/sh

xinetd_dir=/etc/xinetd.d
vnc1=vnc-800x600
vnc2=vnc-1024x768
services=/etc/services

cat > $xinetd_dir/$vnc1 << EOF

service vnc-800x600

{
	disable	= no
	socket_type	= stream
	protocol	= tcp
	wait		= no
	user		= nobody
	server		= /usr/bin/Xvnc
	server_args	= :10 -inetd -query localhost -geometry 800x600 -depth 16 -once -securitytypes=none
	# note on some brands of linux the server value will be /usr/bin/Xvnc (check your for the correct value)
	# also the server_args value may need -securitytypes=none to stop the remote vncviewer being prompted for a 
	# vnc password instead of the GDM/XDM login prompt

}

EOF

cat > $xinetd_dir/$vnc2 << EOF

service vnc-1024x768
{
	disable	= no
	socket_type	= stream
	protocol	= tcp
	wait		= no
	user		= nobody
	server		= /usr/bin/Xvnc
	server_args	= :11 -inetd -query localhost -geometry 1024x768 -depth 16 -once -securitytypes=none

	# note on some brands of linux the server value will be /usr/bin/Xvnc
	# also the server_args value may need -securitytypes=none to stop the remote vncviewer being prompted for a 
	# vnc password instead of the GDM/XDM login prompt
}

EOF
grep -q $vnc1 $services 

if [ $? -ne 0 ] ; then
	echo -e "$vnc1\t5901/tcp" >> $services
fi

grep -q $vnc2 $services 
 
if [ $? -ne 0 ] ; then
	echo -e "$vnc2\t5902/tcp" >> $services
fi

service xinetd reload

