r3 - 15 May 2007 - 20:25:30 - AndrewZYou are here: TWiki >  Ltsp Web  >  LocalApps > VncViewer

VncViewer

Note: This has only been tested on <= LTSP 4.0

for 4.2, see below

#!/bin/sh
#
# vncviewer
#
#Parameters
#
# VNC_SERVER = your.vnc.server 
#  The ip, or hostname of the  VNC server
#  Default is none

PATH=/bin:$PATH; export PATH

#
# Get the lts.conf entries
#
eval `/bin/getltscfg -a`

DEFAULT_SERVER=
XDM_SERVER=${XDM_SERVER:-${SERVER}}
VNC_SERVER=${VNC_SERVER:-${DEFAULT_SERVER}}
VNC_OPTIONS=${VNC_OPTIONS:-"-depth 24"}

TTY=`/usr/bin/basename \`/usr/bin/tty\``
XFCFG=/tmp/XF86Config.${TTY}
export TTY

if [ $# -lt 1 ]; then
    XF_ARGS=""
else
    XF_ARGS=$*
fi

################################################################################
#
# Setup the XF86Config file
#

XSERVER=${XSERVER:-"auto"}

if [ "${XSERVER}" = "auto" ]; then
    echo "Scanning for video card"
    XSERVER=`/sbin/pci_scan /etc/vidlist`
    if [ -z "${XSERVER}" ]; then
        echo
        echo "  ERROR: Auto probe of the video card failed !"
        echo "         You need to specify the proper X server in lts.conf"
        echo
        echo -n "Press <enter> to continue "
        read CMD
        exit 1
    fi
fi

if [ "${XSERVER}" = "i810" ]; then
    if [ ! -f /tmp/i810_loaded ]; then
        modprobe agpgart
        >/tmp/i810_loaded
    fi
fi

if [ ! -z "${XF86CONFIG_FILE}" ]; then
    #
    # If XF86CONFIG_FILE is defined in the lts.conf file, then
    # it points to an XF86Config file that is pre-made for a workstation
    #
    if [ -f /etc/${XF86CONFIG_FILE} ]; then
        cp /etc/${XF86CONFIG_FILE} ${XFCFG}
    else
        echo
        echo "Error! - ${XF86CONFIG_FILE} - File not found!"
        echo
    fi
else
    #
    # Build the XF86Config file from entries in the lts.conf file
    # If it starts with 'XF86_', then we use XFree86 3.3.6.  Otherwise,
    # we use XFree86 4.x
    #
    case ${XSERVER} in

        XF86_*)  /etc/build_x3_cfg ${XSERVER} >${XFCFG}
                 ;;

        *)       /etc/build_x4_cfg ${XSERVER} >${XFCFG}
                 ;;
    esac
fi

################################################################################
#
# Figure out how to run the X server
#

case ${XSERVER} in

    XF86_*)  XBINARY="${XSERVER}"
             XOPTS=""
             ;;

    Xvesa)   XBINARY="Xvesa"
             case "${X_MODE_0}" in
                 1280x1024)   XOPTS="-shadow -mode 0x011A"
                              ;;
                 1024x768)    XOPTS="-shadow -mode 0x0117"
                              ;;
                 800x600)     XOPTS="-shadow -mode 0x0114"
                              ;;
                 640x480)     XOPTS="-shadow -mode 0x0111"
                              ;;
                 *)           XOPTS="-shadow -mode 0x0117"
                              ;;
             esac
             ;;

    *)       XBINARY="XFree86"
             XOPTS=""
             ;;
esac

ACCESS_CONTROL=${DISABLE_ACCESS_CONTROL:-"N"}
if [ "${ACCESS_CONTROL}" = "Y" ]; then
    ACC_CTRL="-ac"
else
    ACC_CTRL=""
fi

if [ "${XF_ARGS}" = "" ]; then
    XF_ARGS="-query ${XDM_SERVER}"
fi

#Build start_vnc script

cat <<EOF >/tmp/start_vnc
if [ "${VNC_SERVER}" != "" ]; then
  echo "Vncviewer*passwordDialog.dialog.label: Password for ${VNC_SERVER}: " | \
  /usr/X11R6/bin/xrdb -nocpp -merge
fi
/usr/X11R6/bin/vncviewer -encodings "copyrect hextile" ${VNC_OPTIONS} ${VNC_SERVER}
EOF
chmod +x /tmp/start_vnc

clear

if [ -w /proc/progress ]; then
    /usr/X11R6/bin/xinit      /tmp/start_vnc \
                              -- /usr/X11R6/bin/${XBINARY}\
                              -xf86config ${XFCFG}        \
                              vt${TTY} >/dev/tty3 2>&1
else
    /usr/X11R6/bin/xinit      /tmp/start_vnc \
                              -- /usr/X11R6/bin/${XBINARY}\
                              -xf86config ${XFCFG}        \
                              vt${TTY}
fi

-- BobBlanchard - 15 Dec 2004

Just tested this with LTSP 4.2 (first wiki post - please be gentle): copied the /opt/ltsp/i386/etc/screen.d/rdesktop script to /opt/ltsp/i386/etc/screen.d/vnc, modified it and used the static enhanced vncviewer which is in the package enhanced_tightvnc_viewer_no_windows. The modified screen.d/vnc script looks like this:

#!/bin/sh
#
# vnc
#
# vnc screen script for the linux terminal server project.
# This script lives in the /opt/ltsp/i386/etc/screen.d directory
#
# Call it through lts.conf with the `SCREEN_xx = vnc` option.
#
# You can pass options to vnc 2 different ways.
#
#   1)  Place all of the options you want after the 'vnc' setting
#       on the screen_script.
#
#       For example:
#
#           SCREEN_01   = vnc vnc.i-nex.de::5900
#
#
#   2)  Place the VNC options in the VNC_OPTIONS option
#       and the name or IP address of the VNC server in
#       the VNC_SERVER option.
#
#       For example:
#
#           VNC_OPTIONS  = "-depth 24"
#           VNC_SERVER   = vnc.i-nex.de::5900
#           SCREEN_01    = vnc
#

PATH=/bin:$PATH; export PATH
. /etc/ltsp_functions

#
# Get the lts.conf entries
#
eval `/bin/getltscfg -a`

VNC_OPTIONS=${VNC_OPTIONS:-""}

reg_info VNC_SERVER
reg_info VNC_OPTIONS

TTY=`/usr/bin/basename \`/usr/bin/tty\` | sed s/tty//`
XFCFG=/tmp/XF86Config.${TTY}
export TTY

VNCDESKTOP_OPTIONS="${VNC_OPTIONS} $* ${VNC_SERVER}"

#
# Setup the DISP variable
#
export DISP=:$(expr ${TTY} - 1).0

################################################################################
#
# Setup the XF86Config file
#

XSERVER=${XSERVER:-"auto"}

if [ "${XSERVER}" = "auto" ]; then
    echo "Scanning for video card"
    XSERVER=`/sbin/pci_scan /etc/vidlist`
    if [ -z "${XSERVER}" ]; then
        echo
        echo "  ERROR: Auto probe of the video card failed !"
        echo "         You need to specify the proper X server in lts.conf"
        echo
        echo -n "Press <enter> to continue "
        read CMD
        exit 1
    fi
fi

if [ "${XSERVER}" = "i810" ]; then
    if [ ! -f /tmp/i810_loaded ]; then
        modprobe agpgart
        >/tmp/i810_loaded
    fi
fi

if [ ! -z "${XF86CONFIG_FILE}" ]; then
    #
    # If XF86CONFIG_FILE is defined in the lts.conf file, then
    # it points to an XF86Config file that is pre-made for a workstation
    #
    if [ -f /etc/${XF86CONFIG_FILE} ]; then
        cp /etc/${XF86CONFIG_FILE} ${XFCFG}
    else
        echo
        echo "Error! - ${XF86CONFIG_FILE} - File not found!"
        echo
    fi
else
    #
    # Build the XF86Config file from entries in the lts.conf file
    # If it starts with 'XF86_', then we use XFree86 3.3.6.  Otherwise,
    # we use Xorg
    #
    case ${XSERVER} in

        XF86_*)  /etc/build_x3_cfg ${XSERVER} >${XFCFG}
                 ;;

        *)       /etc/build_x4_cfg ${XSERVER} >${XFCFG}
                 ;;
    esac
fi

################################################################################
#
# Figure out how to run the X server
#

case ${XSERVER} in

    XF86_*)  XBINARY="${XSERVER}"
             XOPTS=""
             ;;

    Xvesa)   XBINARY="Xvesa"
             case "${X_MODE_0}" in
                 1280x1024)   XOPTS="-shadow -mode 0x011A"
                              ;;
                 1024x768)    XOPTS="-shadow -mode 0x0117"
                              ;;
                 800x600)     XOPTS="-shadow -mode 0x0114"
                              ;;
                 640x480)     XOPTS="-shadow -mode 0x0111"
                              ;;
                 *)           XOPTS="-shadow -mode 0x0117"
                              ;;
             esac
             ;;

    *)       XBINARY="Xorg"
             XOPTS=""
             ;;
esac

ACCESS_CONTROL=${DISABLE_ACCESS_CONTROL:-"N"}
if [ "${ACCESS_CONTROL}" = "Y" ]; then
    ACC_CTRL="-ac"
else
    ACC_CTRL=""
fi

clear
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
#echo -n "                           Press <enter> to Login "
#read

if [ -w /proc/progress ]; then
    /usr/X11R6/bin/xinit      /usr/bin/vncdesktop.wrapper           \
                              -u ""                       \
                              ${VNCDESKTOP_OPTIONS}         \
                              -- /usr/X11R6/bin/${XBINARY}\
                              ${DISP}                     \
                              -xf86config ${XFCFG}        \
                              vt${TTY} >/dev/null 2>&1
else
    /usr/X11R6/bin/xinit      /usr/bin/vncdesktop.wrapper           \
                              -u ""                       \
                              ${VNCDESKTOP_OPTIONS}         \
                              -- /usr/X11R6/bin/${XBINARY}\
                              ${DISP}                     \
                              -xf86config ${XFCFG}        \
                              vt${TTY}
fi

I also modified the /opt/ltsp/i386/usr/bin/rdesktop.wrapper script by copying it to /opt/ltsp/i386/usr/bin/vncdesktop.wrapper and changing the rdesktop line within to the vncviewer path. I copied the /enhanced_tightvnc_viewer/bin/Linux.i686/vncviewer static binary from the enhanced_tightvnc_viewer_no_windows package to /opt/ltsp/i386/usr/bin/ and put this in the lts.conf file:

        SCREEN_04          = vnc
        VNC_SERVER         = vnc.i-nex.de::5900
        VNC_OPTIONS        = "-depth 24"
I hope I didn't forget anything and "Works for me (TM)" wink

-- UdoPuetz - 28 Aug 2006

Related pages

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r3 < r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback