#!/bin/sh

#del old bouquet entrys
oldbouquets=`cat /tmp/bouquets.cfg`
oldifs=$IFS
IFS='
'
for line in $oldbouquets; do
	file=`echo "$line" | cut -d "#" -f3`
	grep "#$file" /var/etc/titan/bouquets.cfg > /dev/null
	if [ $? -ne 0 ]; then
		rm "$file"
	fi
done
IFS=$oldifs
rm /tmp/bouquets.cfg

TMP=/tmp/.set
echo "successfully installed"
if [ `df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1 | wc -l` -eq 1 ]; then
	SPACE=`df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1`
	FREE=`expr $SPACE - 100`
	echo new freespace size $FREE kb
else
	echo "syncing disk"
	sync
fi
touch /tmp/.ipkg_needs_reboot
exit 0