#!/bin/sh
# load brutally an addon
# do not use in a ramdisk system!

#set -x

while [ 1 ] ; do
if [ "$1" ] ; then
	source=$1
else
	read -p "Enter the full archive name " source
fi

[ -f $source ] && break
done

echo -n "Uncompressing the addon ... "
fastdd $source 0 | bzip2 -ds | (cd /; tar -xvf- >/tmp/list  ) 
echo "done."

echo -n "Searching for a suitable INIT script ..."

INIT=`cat /tmp/list | rgrep bin/prolog`

if [ "$INIT" ] ; then
	echo "found $INIT."
	echo "Executing the INIT script ..."
	cd /; sh +x $INIT
fi
echo "Done."

# End 
