File: postinst

package info (click to toggle)
uvscan 3-3
  • links: PTS
  • area: contrib
  • in suites: slink
  • size: 56 kB
  • ctags: 1
  • sloc: sh: 235; makefile: 31
file content (142 lines) | stat: -rwxr-xr-x 3,665 bytes parent folder | download
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/sh
# Based roughly off of Brian White's <bcwhite@pobox.com> netscape4
# installer script.
# -- Robert Woodcock <rcw@oz.net>

function tempcleanup {
	if [ -e "$uvscantmpdir" ]; then
		cd $tmp
#		echo -n - Deleting temp dir $uvscantmpdir...
		rm -rf $uvscantmpdir
		echo
	fi
}	

#
# Avoid unnecessary "postinst" if the next version's "preinst" fails
#
if [ "$0" = "abort-upgrade" ]; then
	exit 0;
fi

# Don't run this if we're not installing
if [ "$1" = "configure" ] && [ "$2" != "" ]; then
	# HOWEVER work around a bug in 3-2 where a reinstall *is* needed
	# because of a bug in its prerm.
	if [ "$2" != "3-2" ]; then
	        exit 0;
	fi
fi

#
# Find the tmp directory
#
tmp=${TMPDIR-/tmp}

#
# If uvscan is already available, then skip rest of setup!
#
if [ -e "/usr/lib/neta/uvscan" ]; then
	echo "- Old uvscan files found -- no need to reinstall them"
	echo "- If you want to force a reinstall, first do: dpkg --purge uvscan"
	exit 0
fi


#
# Unpack the uvscan archive
#
uvscantmpdir=$tmp/uvscan-unpacked.$$
# Double-check that noone is trying to be 3r33t in /tmp
if [ -e "$uvscantmpdir" ]; then
	# Our temp directory already exists - eeeek!
	echo - Temp unpack directory $uvscantmpdir exists\! Exiting...
	exit 1
fi

mkdir $uvscantmpdir
if [ "$?" != "0" ]; then
	echo - Could not create $uvscantmpdir. Exiting...
	exit 1
fi

if [ "`echo $tmp/nlxb*[le].tar`" = "$tmp/nlxb*[le].tar" ]; then
	# No matching files found
	cat << EOF
- Error! No McAfee Virusscan archives have been found in /tmp.
- You can download the 30-day trial version of Virusscan from:
- ftp://ftp.nai.com/pub/antivirus/unix/linux/
- This installer will not run without them. Exiting...
EOF
	# Here is where we should probably offer to download the
        # evaluation version
	tempcleanup
	exit 1
fi

# Doublecheck the filename we wanna use, if there's more than one

if [ "`echo $tmp/nlxb*[le].tar | awk '{print($2)}'`" != "" ]; then
	# We have multiple files to pick from - ask user which one
	echo - Multiple possible Virusscan files found in /tmp.
	i=0;
	for possible in $tmp/nlxb*[le].tar
	do
		i=`expr $i + 1`
		echo - $i\) `ls -l $possible`
	done
	read -p "Please enter the number of the one you wish to use [1-$i]: " choice
	# Check that $choice is valid
	if [ -e "`echo $tmp/nlxb*[le].tar | cut -d' ' -f$choice`" ]; then
		uvscantounpack=`echo $tmp/nlxb*[le].tar | cut -d' ' -f$choice`
		echo - Using $uvscantounpack...
	else
		echo "- Invalid selection!"
		tempcleanup
		exit 1
	fi
else
	# Just one, so use it without asking
	uvscantounpack=`echo $tmp/nlxb*[le].tar`
	echo - Using $uvscantounpack...
fi

# Check file to make sure it's what we want

# Is it owned by us?
if [ -O "$uvscantounpack" ] && [ -G "$uvscantounpack" ]; then
	: # Do nothing, truthfully
else
	read -p "$uvscantounpack is NOT owned by you. Proceed? [y/n]: " proceed
	if [ "$proceed" != "y" ]; then
		echo - Exiting...
		tempcleanup
		exit 1
	fi
fi

# File is owned by us, ass-u-me that it's safe to proceed

cd $uvscantmpdir

tar xOf $uvscantounpack linux-elf.'*'.tar.Z | gzip -dc | tar xf -

if [ "$?" != "0" ]; then
	echo - Unpacking failed\!
	tempcleanup
	exit 1
fi

install -o 0 -g 0 -m 755 -d /usr/lib/neta
install -o 0 -g 0 -m 755 -s uvscan /usr/lib/neta
install -o 0 -g 0 -m 644 clean.dat /usr/lib/neta
install -o 0 -g 0 -m 644 names.dat /usr/lib/neta
install -o 0 -g 0 -m 644 scan.dat /usr/lib/neta
gzip -9 uvscan.1
install -o 0 -g 0 -m 644 uvscan.1.gz /usr/man/man1
install -o 0 -g 0 -m 644 Packing.lst /usr/doc/uvscan
install -o 0 -g 0 -m 644 Readme.1st /usr/doc/uvscan
install -o 0 -g 0 -m 644 Reseller.txt /usr/doc/uvscan
install -o 0 -g 0 -m 644 Whatsnew.txt /usr/doc/uvscan

tempcleanup