##########################################################################
#!/bin/sh
#
# pkgadd - adds trinux packages  (c) 1999 OpenSEC under GPL
#
# Author: Matthew Franz <mfranz@cisco.com>
#
# $1 = name of package
#
##########################################################################

if [ $# -ne 0  ]
then
	rm /*.tgz 2> /dev/null; rm /*.md5 2> /dev/null

	# accepting package name with/without tarball extension

	if echo $1 | grep -v tgz > /dev/null
	then
		FILE="$1.tgz"
	else
		FILE=$1
	fi

	PREFIX=`echo $FILE | cut -d"." -f1`

	if [ -f $FILE ]
	then
		echo "Adding $FILE"
		cp $FILE /; cd /
		
		gunzip $FILE
		base=`echo $FILE | cut -d"." -f1`
		tar xf $base.tar
		rm $base.tar

		# ldconfig 2> /dev/null

		[ -x /etc/pkg/$PREFIX ] && ./etc/pkg/$PREFIX
	else
		echo "$FILE not found!" ; echo
	fi

else                        # no parameters !!
	echo "Usage: "
	echo '      pkgadd filename[.tgz] '
	echo
fi


