summaryrefslogtreecommitdiffstats
path: root/urunlevel/my_linux/Trinux/pkgadd
blob: f04834b1eb21669e19c5233d48c3587ba7501a51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/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"
		PF=`pwd`
		#cp $FILE /; cd /
		cd /
		gunzip -c $PF/${FILE} | tar xf -

        if [ -f /etc/init.d/${PREFIX} ]
        then
            chmod a+x /etc/init.d/${PREFIX} 2> /dev/null
            echo; echo "Initializing package: $PREFIX"
            /etc/init.d/${PREFIX} 2> /dev/null
	elif [ -f /etc/init.m/${PREFIX} ]
        then
            chmod a+x /etc/init.m/${PREFIX} 2> /dev/null
            echo; echo "Initializing module: $PREFIX"
            /etc/init.m/${PREFIX} 2>  /dev/null
        fi

#		base=`echo $FILE | cut -d"." -f1`
#		tar xf $base.tar

		#rm $FILE

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

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