1#!/bin/sh 2# ************************************************************* 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the 9# "License"); you may not use this file except in compliance 10# with the License. You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, 15# software distributed under the License is distributed on an 16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17# KIND, either express or implied. See the License for the 18# specific language governing permissions and limitations 19# under the License. 20# 21# ************************************************************* 22 23linenum=LINENUMBERPLACEHOLDER 24 25UNPACKDIR=/var/tmp/unpack_PRODUCTNAMEPLACEHOLDER 26diskSpaceRequired=DISCSPACEPLACEHOLDER 27checksum=CHECKSUMPLACEHOLDER 28 29EXTRACTONLY="no" 30if [ "$1" = "-x" ] 31then 32 EXTRACTONLY=yes 33fi 34 35# Determining current platform 36 37platform=`uname -s` 38 39case $platform in 40SunOS) 41 tail_prog="tail" 42 ;; 43Linux) 44 tail_prog="tail -n" 45 ;; 46*) 47 tail_prog="tail" 48 ;; 49esac 50 51# Asking for the unpack directory 52 53echo 54echo "Select the directory in which to save the unpacked files. [$UNPACKDIR] " 55read reply leftover 56if [ "x$reply" != "x" ] 57then 58 UNPACKDIR="$reply" 59fi 60 61if [ -d $UNPACKDIR ]; then 62 printf "Directory $UNPACKDIR already exists.\n" 63 printf "Please select a new directory name.\n" 64 exit 1 65fi 66 67# Unpacking 68 69mkdir -m 700 $UNPACKDIR 70 71diskSpace=`df -k $UNPACKDIR | $tail_prog -1 | awk '{if ( $4 ~ /%/) { print $3 } else { print $4 } }'` 72if [ $diskSpace -lt $diskSpaceRequired ]; then 73 printf "The selected drive does not have enough disk space available.\n" 74 printf "PRODUCTNAMEPLACEHOLDER requires at least %s kByte.\n" $diskSpaceRequired 75 exit 1 76fi 77 78trap 'rm -rf $UNPACKDIR; exit 1' HUP INT QUIT TERM 79 80if [ -x /usr/bin/sum ] ; then 81 echo "File is being checked for errors ..." 82 83 sum=`$tail_prog +$linenum $0 | /usr/bin/sum` 84 sum=`echo $sum | awk '{ print $1 }'` 85 86 if [ $sum != $checksum ]; then 87 echo "The download file appears to be corrupted. Please download PRODUCTNAMEPLACEHOLDER again." 88 exit 1 89 fi 90fi 91 92echo "Unpacking ..." 93 94$tail_prog +$linenum $0 | (cd $UNPACKDIR; tar xf -) 95 96echo "All files have been successfully unpacked." 97 98if [ "$EXTRACTONLY" != "yes" ] 99then 100 if [ -f $UNPACKDIR/setup ] 101 then 102 chmod 775 $UNPACKDIR/setup 103 $UNPACKDIR/setup 104 fi 105fi 106 107exit 0 108