#!/bin/sh # # L.S.Lowe at bham.ac.uk. Copyright 2007-2008, GPLv3 license applies. # Adapts lines from vncserver script, copyright RealVNC, GPLv2 applies. # # This is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # See http://www.ep.ph.bham.ac.uk/general/support/vncsetup.html for info. # This script creates the file that the first run of a vncserver command # would create, with the difference that the lines which are marked for # uncommenting if you want a normal desktop, are already uncommented, # and the second line is changed so vncserver is killed after a logoff. # With these lines modified, the created script actually exits before # the Xresources line, but we include the whole thing for completeness. # For more details and the original, see the /usr/bin/vncserver script. # Then, if an operand has been provided (eg kde, gnome), this script # will call switchdesk to setup $HOME/.Xclients and any cronies. But if # the operand is twm, remove the xstartup so that vncserver creates one. # Then, if no VNC password exists yet and we're on a tty, issue vncpasswd. mkdir -p $HOME/.vnc fn=$HOME/.vnc/xstartup cat << 'EOF' >| $fn #!/bin/sh # Uncommented the following two lines for normal desktop & tweaked second line: unset SESSION_MANAGER /etc/X11/xinit/xinitrc; vncserver -kill $DISPLAY; exit [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & twm & EOF chmod a+x $fn if [ $# -gt 0 ]; then if [ "$1" = twm ]; then rm $fn # so vncserver will create its default elif [ -x /usr/bin/switchdesk ]; then if [ "$1" = -h ]; then set -- ""; fi DISPLAY="" /usr/bin/switchdesk "$@" else echo Sorry: no switchdesk - modify $HOME/.Xclients by hand or ask admin fi fi msg="Now set a VNC password for future VNC viewing sessions" if [ ! -r $HOME/.vnc/passwd ] && tty -s; then echo $msg; vncpasswd; fi echo You can now run vncserver :displaynumber