#!/bin/sh

## live-config(7) - System Configuration Scripts
## Copyright (C) 2006-2011 Daniel Baumann <daniel@debian.org>
##
## live-config comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.


Gdm ()
{
	# Checking if package is installed or already configured
	if [ ! -e /var/lib/dpkg/info/gdm.list ]
	then
		return
	fi

	if [ -e /var/lib/live/config/gdm ]
	then
		# Avoid xinit
		_X11="true"
		export _X11

		return
	fi

	echo -n " gdm"

	Configure_gdm
}

Configure_gdm ()
{
	# Checking if if package is already configured differently
	if grep -qs AutomaticLoginEnable /etc/gdm/gdm.conf
	then
		return
	fi

	_GDM_OPTIONS="AutomaticLoginEnable=true\n\
AutomaticLogin=${LIVE_USERNAME}\n\
TimedLoginEnable=true\n\
TimedLogin=${LIVE_USERNAME}\n\
TimedLoginDelay=10"

	sed -i -e "s|\[daemon\]|\[daemon\]\n${_GDM_OPTIONS}|" /etc/gdm/gdm.conf

	# Avoid xinit
	_X11="true"
	export _X11

	# Creating state file
	touch /var/lib/live/config/gdm
}

Gdm
