#!/bin/sh
#
TMP=/tmp/.oscam
INSTDIR="$1"

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

echo "checking install path"
if [ ! -d "$INSTDIR/bin/" ]; then
  echo "--------------------------"
	echo "no install path found...."
	echo "--------------------------"
	exit 1
fi
echo "install path found...."

if [ "/var/swap" == "$INSTDIR" ]; then
	echo "syncing disk"
	sync
else	
	SPACE=`getfreespace "$INSTDIR"`
	FREE=`expr $SPACE - 100`
	SIZE=936
	echo "checking freespace"
	echo packege size $SIZE kb
	echo freespace size $FREE kb
	if  [ "$FREE" -lt "$SIZE" ]; then
		echo "sorry no freespace left on device"
		exit 1
	else
		echo ok		
	fi
fi

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 TPK Package!! 	 	 
	echo --- 	 	 
	echo Only for $buildgroup Image!! 	 	 
	echo --------------------------- 	 	 
	exit 1 	 	 
fi
echo "installing Oscam Build 6089..."

exit 0
