#!/bin/sh -e

# The clock might be wrong and we know that we need to update the icon
# cache so we just force it.

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 enigma.desktop
  fi
fi

if [ "$OSSO_PRODUCT_RELEASE_NAME" == "Maemo 5" ]; then
echo -n "Maemo 5"
MMC_PATH=/home/user/MyDocs/
MMC_DIR=.enigma
else
echo -n "Maemo pre-5"
MMC_PATH=/media/mmc2/
MMC_DIR=enigma
fi
echo " memcard location: $MMC_PATH"

# make sure that there's enough free disk space
NEED=13000
FREE=`df $MMC_PATH | grep -vE '^Filesystem' | awk '{ print $4 }'`
if [ $FREE -ge $NEED ]; then
    if maemo-confirm-text "Memory usage" /usr/share/doc/enigma/install_memcard.txt; then
	echo "Moving data files from /usr/share to $MMC_PATH$MMC_DIR"
	mv /usr/share/enigma $MMC_PATH$MMC_DIR
    fi
fi

exit 0
