blob: e399b05944ee389308d958f9fdf2164acd73c365 (
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
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
|
#!/bin/sh
linenum=LINENUMBERPLACEHOLDER
UNPACKDIR=/var/tmp/unpack_PRODUCTNAMEPLACEHOLDER
diskSpaceRequired=DISCSPACEPLACEHOLDER
checksum=CHECKSUMPLACEHOLDER
EXTRACTONLY="no"
if [ "$1" = "-x" ]
then
EXTRACTONLY=yes
fi
# Determining current platform
platform=`uname -s`
case $platform in
SunOS)
tail_prog="tail"
;;
Linux)
tail_prog="tail -n"
;;
*)
tail_prog="tail"
;;
esac
# Asking for the unpack directory
echo
echo "Select the directory in which to save the unpacked files. [$UNPACKDIR] "
read reply leftover
if [ "x$reply" != "x" ]
then
UNPACKDIR="$reply"
fi
if [ -d $UNPACKDIR ]; then
printf "Directory $UNPACKDIR already exists.\n"
printf "Please select a new directory name.\n"
exit 1
fi
# Unpacking
mkdir -m 700 $UNPACKDIR
diskSpace=`df -k $UNPACKDIR | $tail_prog -1 | awk '{if ( $4 ~ /%/) { print $3 } else { print $4 } }'`
if [ $diskSpace -lt $diskSpaceRequired ]; then
printf "The selected drive does not have enough disk space available.\n"
printf "PRODUCTNAMEPLACEHOLDER requires at least %s kByte.\n" $diskSpaceRequired
exit 1
fi
trap 'rm -rf $UNPACKDIR; exit 1' HUP INT QUIT TERM
if [ -x /usr/bin/sum ] ; then
echo "File is being checked for errors ..."
sum=`$tail_prog +$linenum $0 | /usr/bin/sum`
sum=`echo $sum | awk '{ print $1 }'`
if [ $sum != $checksum ]; then
echo "The download file appears to be corrupted. Please download PRODUCTNAMEPLACEHOLDER again."
exit 1
fi
fi
echo "Unpacking ..."
$tail_prog +$linenum $0 | (cd $UNPACKDIR; tar xf -)
echo "All files have been successfully unpacked."
if [ "$EXTRACTONLY" != "yes" ]
then
if [ -f $UNPACKDIR/setup ]
then
chmod 775 $UNPACKDIR/setup
$UNPACKDIR/setup
fi
fi
exit 0
|