viernes, 19 de marzo de 2010

vnc4server boot script (working in Debian/Ubuntu/Kubuntu)

Problem : At my debian/ubuntu/kubuntu installing vnc4server dont start at boot, so I had to log via ssh to sart it up. This post is to resolve this problem, at least when no start script is installed.

First instal vnc4server :

sudo apt-get install vnc4server

And also check if that installation created any startup script at /etc/init.d (newer version could do this)

Now, set a password for the user (from the host) to get the desktop

su remoteuser

vnc4server

This will prompt to put a password, also at this point you could check the vnc server.

Now, put this script at /etc/init.d/vcn4server

# /etc/init.d/vnc4server
#

# Some things that run always
touch /var/lock/vnc4server

# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting script vnc4server "
su remoteuser -c 'vnc4server '
;;
stop)
echo "Stopping script vnc4server"
su remoteuser -c 'vnc4server -kill '
;;
*)
echo "Usage: /etc/init.d/vnc4server {start|stop}"
exit 1
;;
esac

exit 0

REMEMBER TO CHANGE THE "remoteuser" AT THE SCRIPT

Add the script at boot:

update-rc.d vnc4server defaults

Reboot and test it!

you could add more entries for remote desktop for different users adding :
   su remoteuser0 -c 'vnc4server '
   su remoteuser1 -c 'vnc4server '
   su remoteuser2 -c 'vnc4server '

Different port will be open for every user

3 comentarios:

Jeremy Harkness dijo...

Dont forget to make the new script Executable

sudo chmod +x scriptname

halycon dijo...

su remoteuser -c 'vnc4server -kill '
will not work. You need to specify the session, e.g. su remoteuser -c 'vnc4server -kill :1'

Hits dijo...

this article appears helpfull, but contains several bugs, like VCN server or space before quotation mark

Google Analytics Alternative