#!/bin/sh
#
TMP=/tmp/.skin
echo "syncing disk"
sync

if [ `df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | tail -n1 | wc -l` -eq 1 ]; then
	SPACE=`df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | tail -n1`
	FREE=`expr $SPACE - 100`
	SIZE=141 
	echo "checking freespace"
	echo packege size $SIZE kb
	echo freespace size $FREE kb
	if  [ "$FREE" -lt "$SIZE" ]; then
		echo "sorry not enought freespace to install the new default skin"
		exit 1
	else
		echo ok
	fi
fi
echo "checking OS"
if  [ `cat /etc/motd | grep AAF | grep M | grep rev | wc -l` -eq 0 ]; then                      
	echo ---------------------------
	echo DONT USE this IPK Package!!
	echo ---
	echo Only for AAF Image!!
	echo ---------------------------
	exit 1
fi
echo "removing default skin in flash..."
rm -r /usr/local/share/enigma2/skin.xml
rm -r /usr/local/share/enigma2/skin_default.xml
rm -r /usr/local/share/enigma2/skin_default
#rm -r /usr/local/share/enigma2/prev.png
echo "syncing disk..."
sync
exit 0