#!/bin/sh
#
# livecd-virtualbox-noglx	A kludge for vboxdrv in livecd
#
# chkconfig: 345 05 95
# description:	aimed at livecd use

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

LOCKFILE=/var/lock/subsys/livecd-virtualbox-noglx
RETVAL=0

prefix="/etc/X11/xorg.conf.d"

start()
{
	if [ -n "`lspci -d 80ee:beef`" ]; then
		mkdir -p "$prefix"
		cat >"$prefix/virtualbox-noglx.conf" <<-EOF
		Section "ServerFlags"
		        Option "AIGLX" "false"
		EndSection
		EOF
	fi
	return 0
}

# See how we were called.
case "$1" in
	start|restart|reload)
		start
		;;
	stop)
		;;
	condstop)
		;;
	condrestart|condreload)
		if [ -e "$LOCKFILE" ]; then
			start
		fi
		;;
	status)
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
		RETVAL=1
esac

exit $RETVAL
