update dev300-m57
[ooovba.git] / setup_native / scripts / downloadscript.sh
blobe399b05944ee389308d958f9fdf2164acd73c365
1 #!/bin/sh
3 linenum=LINENUMBERPLACEHOLDER
5 UNPACKDIR=/var/tmp/unpack_PRODUCTNAMEPLACEHOLDER
6 diskSpaceRequired=DISCSPACEPLACEHOLDER
7 checksum=CHECKSUMPLACEHOLDER
9 EXTRACTONLY="no"
10 if [ "$1" = "-x" ]
11 then
12 EXTRACTONLY=yes
15 # Determining current platform
17 platform=`uname -s`
19 case $platform in
20 SunOS)
21 tail_prog="tail"
23 Linux)
24 tail_prog="tail -n"
27 tail_prog="tail"
29 esac
31 # Asking for the unpack directory
33 echo
34 echo "Select the directory in which to save the unpacked files. [$UNPACKDIR] "
35 read reply leftover
36 if [ "x$reply" != "x" ]
37 then
38 UNPACKDIR="$reply"
41 if [ -d $UNPACKDIR ]; then
42 printf "Directory $UNPACKDIR already exists.\n"
43 printf "Please select a new directory name.\n"
44 exit 1
47 # Unpacking
49 mkdir -m 700 $UNPACKDIR
51 diskSpace=`df -k $UNPACKDIR | $tail_prog -1 | awk '{if ( $4 ~ /%/) { print $3 } else { print $4 } }'`
52 if [ $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
58 trap 'rm -rf $UNPACKDIR; exit 1' HUP INT QUIT TERM
60 if [ -x /usr/bin/sum ] ; then
61 echo "File is being checked for errors ..."
63 sum=`$tail_prog +$linenum $0 | /usr/bin/sum`
64 sum=`echo $sum | awk '{ print $1 }'`
66 if [ $sum != $checksum ]; then
67 echo "The download file appears to be corrupted. Please download PRODUCTNAMEPLACEHOLDER again."
68 exit 1
72 echo "Unpacking ..."
74 $tail_prog +$linenum $0 | (cd $UNPACKDIR; tar xf -)
76 echo "All files have been successfully unpacked."
78 if [ "$EXTRACTONLY" != "yes" ]
79 then
80 if [ -f $UNPACKDIR/setup ]
81 then
82 chmod 775 $UNPACKDIR/setup
83 $UNPACKDIR/setup
87 exit 0