#!/bin/sh
#
# Start the PiBox UI....
#

UIHOME=/root
SESSIONDIR=.matchbox
DEFAULTDIR=/etc/matchbox
export HOME=$UIHOME

# Check for default seesion configuraiton
cd $UIHOME
if [ ! -d $SESSIONDIR ]
then
    mkdir $SESSIONDIR
    cp -ar $DEFAULTDIR/* $SESSIONDIR/
fi

export TZ=`cat /etc/TZ`

case "$1" in
  start)
    echo "Starting PiBox UI..."
    cd $UIHOME
    /usr/bin/xinit /etc/X11/xinitrc &
    ;;

  stop)
    echo "Stopping PiBox UI..."
    killall xinit 
    ;;

  restart|reload)
    "$0" stop
    "$0" start
    ;;

  *)
    echo $"Usage: $0 {start|stop|restart}"
    exit 1
esac

exit $?

