2004-12-16 03:49:14 -06:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
linenum=LINENUMBERPLACEHOLDER
|
|
|
|
|
|
|
|
UNPACKDIR=/var/tmp/unpack_PRODUCTNAMEPLACEHOLDER
|
2005-01-31 03:38:50 -06:00
|
|
|
diskSpaceRequired=DISCSPACEPLACEHOLDER
|
|
|
|
checksum=CHECKSUMPLACEHOLDER
|
|
|
|
|
2006-05-08 09:34:13 -05:00
|
|
|
EXTRACTONLY="no"
|
|
|
|
if [ "$1" = "-x" ]
|
|
|
|
then
|
|
|
|
EXTRACTONLY=yes
|
|
|
|
fi
|
|
|
|
|
2005-01-31 03:38:50 -06:00
|
|
|
# Determining current platform
|
|
|
|
|
|
|
|
platform=`uname -s`
|
|
|
|
|
|
|
|
case $platform in
|
|
|
|
SunOS)
|
|
|
|
tail_prog="tail"
|
|
|
|
;;
|
|
|
|
Linux)
|
|
|
|
tail_prog="tail -n"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
tail_prog="tail"
|
|
|
|
;;
|
|
|
|
esac
|
2004-12-16 03:49:14 -06:00
|
|
|
|
|
|
|
# Asking for the unpack directory
|
|
|
|
|
|
|
|
echo
|
2005-01-31 03:38:50 -06:00
|
|
|
echo "Select the directory in which to save the unpacked files. [$UNPACKDIR] "
|
2004-12-16 03:49:14 -06:00
|
|
|
read reply leftover
|
|
|
|
if [ "x$reply" != "x" ]
|
|
|
|
then
|
|
|
|
UNPACKDIR="$reply"
|
|
|
|
fi
|
|
|
|
|
2005-01-31 03:38:50 -06:00
|
|
|
if [ -d $UNPACKDIR ]; then
|
|
|
|
printf "Directory $UNPACKDIR already exists.\n"
|
|
|
|
printf "Please select a new directory name.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2004-12-16 03:49:14 -06:00
|
|
|
# Unpacking
|
|
|
|
|
2006-09-27 05:01:31 -05:00
|
|
|
mkdir -m 700 $UNPACKDIR
|
2004-12-16 03:49:14 -06:00
|
|
|
|
2005-04-04 04:11:14 -05:00
|
|
|
diskSpace=`df -k $UNPACKDIR | $tail_prog -1 | awk '{if ( $4 ~ /%/) { print $3 } else { print $4 } }'`
|
2005-01-31 03:38:50 -06:00
|
|
|
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
|
2004-12-16 03:49:14 -06:00
|
|
|
|
|
|
|
trap 'rm -rf $UNPACKDIR; exit 1' HUP INT QUIT TERM
|
|
|
|
|
2005-01-31 03:38:50 -06:00
|
|
|
if [ -x /usr/bin/sum ] ; then
|
|
|
|
echo "File is being checked for errors ..."
|
2004-12-16 03:49:14 -06:00
|
|
|
|
2005-01-31 03:38:50 -06:00
|
|
|
sum=`$tail_prog +$linenum $0 | /usr/bin/sum`
|
|
|
|
sum=`echo $sum | awk '{ print $1 }'`
|
2004-12-16 03:49:14 -06:00
|
|
|
|
2005-01-31 03:38:50 -06:00
|
|
|
if [ $sum != $checksum ]; then
|
|
|
|
echo "The download file appears to be corrupted. Please download PRODUCTNAMEPLACEHOLDER again."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2004-12-16 03:49:14 -06:00
|
|
|
|
2005-01-31 03:38:50 -06:00
|
|
|
echo "Unpacking ..."
|
2004-12-16 03:49:14 -06:00
|
|
|
|
2005-02-24 09:16:51 -06:00
|
|
|
$tail_prog +$linenum $0 | (cd $UNPACKDIR; tar xf -)
|
2004-12-16 03:49:14 -06:00
|
|
|
|
2005-01-31 03:38:50 -06:00
|
|
|
echo "All files have been successfully unpacked."
|
2004-12-16 03:49:14 -06:00
|
|
|
|
2006-05-08 09:34:13 -05:00
|
|
|
if [ "$EXTRACTONLY" != "yes" ]
|
2004-12-16 03:49:14 -06:00
|
|
|
then
|
2006-05-08 09:34:13 -05:00
|
|
|
if [ -f $UNPACKDIR/setup ]
|
|
|
|
then
|
|
|
|
chmod 775 $UNPACKDIR/setup
|
|
|
|
$UNPACKDIR/setup
|
|
|
|
fi
|
2004-12-16 03:49:14 -06:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|