#! /bin/sh

# Do we need to run this with -f ? The clock might be wrong,
# but forcing it slows the install...
gtk-update-icon-cache -f /usr/share/icons/hicolor

oldversion="$2"
if [ -z "$oldversion" ]; then
  if [ -f /usr/bin/maemo-select-menu-location ]; then
    maemo-select-menu-location osm2go.desktop
  fi
fi

echo "Environment:"
env

# determine path to use
if [ "$INTERNAL_MMC_MOUNTPOINT" != "" ]; then
  MMC_PATH=$INTERNAL_MMC_MOUNTPOINT
elif [ "$HOME" != "" ]; then
  MMC_PATH=$HOME
else
  MMC_PATH=/tmp
fi

# hide directory if we are working within a users home dir
if [ "`echo $MMC_PATH | cut -d / -f-2`" == "/home" ]; then
  MMC_PATH=$MMC_PATH/.osm2go
else
  MMC_PATH=$MMC_PATH/osm2go
fi

echo "Using data location at $MMC_PATH"

if [ -d $MMC_PATH ]; then
  echo "$MMC_PATH already exists, doing nothing."
else
  echo "$MMC_PATH doesn't exist yet. Installing demo project."
  mkdir $MMC_PATH
  mv /usr/share/osm2go/demo $MMC_PATH
fi

exit 0
