http://www.abdevelopment.ca/blog/start-vnc-server-ubuntu-boot
update to correct update-rc hint:
http://www.debuntu.org/how-to-manage-services-with-update-rc.d
To set it up, follow these steps:
- First, install the TightVNC server. This VNC server has excellent compatibility with clients, and provides reasonable compression for slow networks. It can be installed with Synaptic, or with
sudo aptitude install tightvncserver
. - Set up the VNC server for the user you wish to log in as. When you run "vncserver" for the first time, it will ask you to set a password. VNC authentication is not the strongest encryption available, so be sure to firewall your server from all but trusted machines. Better yet, deny direct access to VNC and only allow SSH tunnelled or VPN connections. To launch programs or a session when your VNC session starts, modify
~/.vnc/xstartup
. Here is my copy of xstartup: it runs an icewm session, Azureus, and K3B. For Gnome, try running "gnome-session", and for KDE, try "startkde".
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid black
/opt/azureus/azureus &
k3b &
icewm-session & - Copy the following into
/etc/init.d/vncserver
. The easiest way to do it is to copy it to your clipboard, runsudo -i && cat > /etc/init.d/vncserve && exit
in a terminal, paste it in, and typeCTRL-D
. Be sure to change theUSER
variable to whatever user you want the VNC server to run under.
#!/bin/sh -e
PATH="$PATH:/usr/X11R6/bin/"
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Default-Start: 3 4 5
# Default-Stop: 0 6
### END INIT INFO
# The Username:Group that will run VNC
export USER="mythtv"
#${RUNAS}
# The display that VNC will use
DISPLAY="1"
# Color depth (between 8 and 32)
DEPTH="16"
# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"
# The name that the VNC Desktop will have.
NAME="my-vnc-server"
OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
exit 0 - Make the script executable with
sudo chmod +x /etc/init.d/vncserver
. - Then, run
sudo update-rc.d vncserver defaults
. This adds the appropriate symlinks to the vncserver script so that it is sent the start and stop commands at the appropriate time. Update: jpb writes that you may need to usesudo update-rc.d vncserver default 99
instead if the job is running too early in the boot process. - To start the server without rebooting, run
sudo /etc/init.d/vncserver start
- Finally, connect to your server with a VNC client on port 590X, where X is the value of "DISPLAY" in the vncserver script. On OS X, I like to use Chicken of the VNC. On Windows and Linux, the TightVNC client works nicely.
No comments:
Post a Comment