#!/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=1 
	echo "checking freespace"
	echo packege size $SIZE kb
	echo freespace size $FREE kb
	if  [ "$FREE" -lt "$SIZE" ]; then
		echo "sorry not enought freespace to backup default skin..."
		echo "removing IPK aborted..."
		killall -9 ipkg
	else
		echo "ok"
	fi
fi
echo "syncing disk..."
sync
exit 0