#!/bin/sh

[ -f /etc/profile.d/tslib.sh ] && . /etc/profile.d/tslib.sh
[ -f /etc/profile.d/microwindows.sh ] && . /etc/profile.d/microwindows.sh

export DISPLAY=:0

case "$1" in
start)
	# We don't want this script to block the rest of the boot process
    	if [ "$2" != "background" ]; then
      		$0 $1 background &
	else
	        while [  -f /var/run/starting_xserver ]
        	do
                	sleep 1;
	        done

		start-stop-daemon -m -p /var/run/mw-guf-demo.pid -b -a /usr/bin/mw-guf-demo -S
	fi
	;;
stop)
	start-stop-daemon -p /var/run/mw-guf-demo.pid -K
	;;
*)
	echo "Usage: /etc/init.d/mw-guf-demo {start|stop}" >&2
	exit 1
	;;
esac
