#!/bin/sh
#
#  Configure the new image to be a GDM VNC server.
#
# Steve
# --
# http://www.steve.org.uk/
#
# $Id: gdm,v 1.1 2006/01/07 21:54:44 steve Exp $


prefix=$1


#
#  This function installs a single package into the chroot, forcing
# the installation to be non-interactive.
#
function install_package
{
    package=$1
    
    DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install $package

}





#
#  Update APT lists.
#
chroot ${prefix} /usr/bin/apt-get update

#
#  Install the packages
#
install_package xserver-xfree86
install_package vncserver
install_package xfonts-100dpi
install_package xfonts-75dpi
install_package xfonts-base
install_package rxvt
install_package gdm
install_package icewm-experimental

#
#  Add a new section to the GDM configuration file.
#
cat <<EOF >> ${prefix}/etc/X11/gdm/gdm.conf
[server-VNC]
name=VNC server
command=/usr/bin/Xvnc -geometry 800x600 -depth 24
flexible=true
EOF


#
#  Make the new section the default
#
perl -pi.bak -e 's/^0=Standard/0=VNC/g' ${prefix}/etc/X11/gdm/gdm.conf