#!/bin/sh

plugin_size=1700
plugin_short="tobayer01"
plugin_type="skin"
plugin_target="/var/usr/local/share/titan/skin"

plugin_dir="$plugin_target/$plugin_short"
plugin="$plugin_short $plugin_type"


### MAIN ###

# Is this check for anything useful???
#model=`cat /etc/model`
#echo -n "Checking box type..."
#if [ "$model" = "" ]; then
#	echo "......[FAILED]"
#	echo
#	echo "Sorry, $plugin is not available for the $model!"
#	echo "Aborting installation..."
#	exit 1
#else
#	echo "......[OK]"
#fi


echo -n "Checking installation directory..."
if [ ! -d $plugin_target ]; then
	echo "......[FAILED]"
	echo
	echo "'$plugin_target' not found!"
	echo "Aborting installation..."
	exit 1
else
#	echo "......[OK]"
	echo
fi


sync
SPACE=`getfreespace $plugin_target`
FREE=`expr $SPACE - 100`
echo -n "Checking free space (${plugin_size}/${FREE}kB)..."
if [ "$FREE" -lt "$plugin_size" ]; then
	echo "......[FAILED]"
	echo
	echo "Not enough free space in $plugin_target!"
	echo "Aborting installation..."
	exit 1
else
#	echo "......[OK]"
	echo
fi


# Is this check for anything useful???
#buildgroup=`cat /etc/.buildgroup`
#echo -n "Checking image type..."
#if [ `cat /etc/version | grep $buildgroup | wc -l` -eq 0 ]; then
#	echo "......[FAILED]"
#	echo
#	echo "Sorry, $plugin is not available for this image type!"
#	echo "Aborting installation..."
#	exit 1
#else
#	echo "......[OK]"
#fi


rm -rf $plugin_dir

#echo -n "Installing $plugin..."
#echo "......[OK]"

exit 0
