#!/bin/sh

# 1: locate the place where Qtopia is installed
if [ "$QPEDIR" = "" ]
then
    if [ -d /opt/Qtopia ]
    then
	QPEDIR=/opt/Qtopia
    else
	if [ -d /opt/QtPalmtop ]
	then
	    QPEDIR=/opt/QtPalmtop
	else
	    # err, better quit than doing some damage
	    exit 1
	fi
    fi
fi

# 2: update the mime.types
# prz
PROZ=`/bin/cat "$QPEDIR/etc/mime.types" | /bin/grep "application/prozect"`
if [ "$PROZ" = "" ]
then
#    echo -n -e "\nText_Files/prozect		proz\n" >>"$QPEDIR/etc/mime.types"
    echo -n -e "\napplication/prozect		proz\n" >>"$QPEDIR/etc/mime.types"
fi

# 3: put the tutorial in home Docs
if [ -d /home/zaurus ]
then
    BASE=/home/zaurus
    USR=zaurus:qpe
else 
    if [ -d /home/root ]
    then 
	BASE=/home/root
	USR=root:root
    else 
	# new os?
	exit 1
    fi
fi

if [ ! -d $BASE/Documents/application ]
then 
    mkdir $BASE/Documents/application
    chown $USR $BASE/Documents/application
fi
if [ ! -d $BASE/Documents/application/prozect ]
then 
    mkdir $BASE/Documents/application/prozect
    chown $USR $BASE/Documents/application/prozect
fi

SRC=/tmp/tutorial.proz

if [ ! -e $SRC ]
then
    if [ -e /mnt/cf/$SRC ]
    then
	SRC=/mnt/cf/$SRC
    elif [ -e /mnt/sd/$SRC ]
    then
	SRC=/mnt/sd/$SRC
    elif [ -e /mnt/ram/$SRC ]
    then
	SRC=/mnt/ram/$SRC
    fi
fi

mv $SRC $BASE/Documents/application/prozect/
chown $USR $BASE/Documents/application/prozect/tutorial.proz

exit 0
