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

model=`cat /etc/model`
echo ""
echo "Checking your Boxtype...."
echo "Some Plugins will not work correctly on your $model!"
echo ""
if [ "$model" = "" ]; then
	echo "Sorry! This Plugin is not available for your $model because it will not work correctly!!!"
	echo "Aborting installation..."
	exit 1
else
	echo "Boxtype: $model OK"
fi

if [ -e /etc/.usbimage ]; then
	echo "detected USB Image...."
	echo "ok..."
elif [ "$model" = "ufs912" ] || [ "$model" = "at7500" ] || [ "$model" = "at7000" ] || [ "$model" = "at700" ]; then
	echo "detected Boxtype : $model...."
	echo "ok..."
	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=4272
		echo "checking freespace in flash"
		echo packege size $SIZE kb
		echo freespace size $FREE kb
		if  [ "$FREE" -lt "$SIZE" ]; then
			echo "sorry no freespace left on device"
			echo "ERROR: this package will not fit in your flash..."
			echo "...you need a swapstick to install the package on your $model...!"
			echo "aborting installation..."
			exit 1
			else
			echo freespace ok
		fi
	fi
else
	echo "ERROR: this package will not fit in your flash..."
	echo "...you need a swapstick to install the package on your $model...!"
	echo "aborting installation..."
	exit 1
fi

echo "installing Picons for Neutrino..."
buildgroup=`cat /etc/.buildgroup`
echo "checking OS"	 
if  [ `cat /etc/motd | grep $buildgroup | grep M | grep rev | wc -l` -eq 0 ]; then 	 	 
	echo --------------------------- 	 	 
	echo DONT USE this IPK Package!! 	 	 
	echo --- 	 	 
	echo Only for $buildgroup Image!! 	 	 
	echo --------------------------- 	 	 
	exit 1 	 	 
fi

rm -rf /var/usr/local/share/neutrino/icons/logo
				
exit 0
