#!/bin/sh

APP_DIR=/dso/app
ETC_DIR=/dso/etc
APP_REL_NAME=phoenix

#create dirs needed
if [ ! -d /config/home/USB ]
then
	ln -s /mnt/udisk/ /config/home/USB
fi

if [ ! -d /config/home/SD ]
then
	ln -s /mnt/sd/ /config/home/SD
fi

if [ ! -d $APP_DIR/mnt ]
then
	ln -s /mnt $APP_DIR/mnt
fi

if [ ! -d $APP_DIR/home ]
then
	ln -s /config/home/ $APP_DIR/home
fi

if [ ! -d $APP_DIR/home/mask ]
then
	mkdir $APP_DIR/home/mask
fi

if [ ! -d $APP_DIR/home/wave ]
then
	mkdir $APP_DIR/home/wave
fi

if [ ! -d $APP_DIR/home/ref ]
then
	mkdir $APP_DIR/home/ref
fi

if [ ! -d $APP_DIR/home/setup ]
then
	mkdir $APP_DIR/home/setup
fi

if [ ! -d $APP_DIR/root ]
then
	ln -s /config/root/ $APP_DIR/root
fi

if [ ! -d $APP_DIR/etc ]
then
	ln -s $ETC_DIR $APP_DIR/etc
fi

#do something
if [ -f /do_something ]
then 
	chmod +x /do_something 
	/do_something 
	rm -rf /do_something 
fi

#dbus prepare
if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
	eval `/dso/bin/dbus-launch --sh-syntax --exit-with-session`
	echo $DBUS_SESSION_BUS_ADDRESS >/tmp/dbus_session_bus_address
fi

#run app
cd $APP_DIR
./$APP_REL_NAME&
