1#!/bin/sh 2 3linenum=LINENUMBERPLACEHOLDER 4 5UNPACKDIR=/var/tmp/unpack_PRODUCTNAMEPLACEHOLDER 6diskSpaceRequired=DISCSPACEPLACEHOLDER 7checksum=CHECKSUMPLACEHOLDER 8 9EXTRACTONLY="no" 10if [ "$1" = "-x" ] 11then 12 EXTRACTONLY=yes 13fi 14 15# Determining current platform 16 17platform=`uname -s` 18 19case $platform in 20SunOS) 21 tail_prog="tail" 22 ;; 23Linux) 24 tail_prog="tail -n" 25 ;; 26*) 27 tail_prog="tail" 28 ;; 29esac 30 31# Asking for the unpack directory 32 33echo 34echo "Select the directory in which to save the unpacked files. [$UNPACKDIR] " 35read reply leftover 36if [ "x$reply" != "x" ] 37then 38 UNPACKDIR="$reply" 39fi 40 41if [ -d $UNPACKDIR ]; then 42 printf "Directory $UNPACKDIR already exists.\n" 43 printf "Please select a new directory name.\n" 44 exit 1 45fi 46 47# Unpacking 48 49mkdir -m 700 $UNPACKDIR 50 51diskSpace=`df -k $UNPACKDIR | $tail_prog -1 | awk '{if ( $4 ~ /%/) { print $3 } else { print $4 } }'` 52if [ $diskSpace -lt $diskSpaceRequired ]; then 53 printf "The selected drive does not have enough disk space available.\n" 54 printf "PRODUCTNAMEPLACEHOLDER requires at least %s kByte.\n" $diskSpaceRequired 55 exit 1 56fi 57 58trap 'rm -rf $UNPACKDIR; exit 1' HUP INT QUIT TERM 59 60if [ -x /usr/bin/sum ] ; then 61 echo "File is being checked for errors ..." 62 63 sum=`$tail_prog +$linenum $0 | /usr/bin/sum` 64 sum=`echo $sum | awk '{ print $1 }'` 65 66 if [ $sum != $checksum ]; then 67 echo "The download file appears to be corrupted. Please download PRODUCTNAMEPLACEHOLDER again." 68 exit 1 69 fi 70fi 71 72echo "Unpacking ..." 73 74$tail_prog +$linenum $0 | (cd $UNPACKDIR; tar xf -) 75 76echo "All files have been successfully unpacked." 77 78if [ "$EXTRACTONLY" != "yes" ] 79then 80 if [ -f $UNPACKDIR/setup ] 81 then 82 chmod 775 $UNPACKDIR/setup 83 $UNPACKDIR/setup 84 fi 85fi 86 87exit 0 88