r)REDIS_LIST=$OPTARG ;;

o)OUTPUT_FILE=$OPTARG ;;

?) echo "invalid command line option $*" syntax

exit 1;;

esac done

;;

esac

#temp file FLIST="filelist.$$"

#build command line for different file format

echo $CLIDRV_FILEegrep -i '\.gz *$' > /dev/null if [ "$?" == 0 ]; then

#for .tar.gz

CMD="gunzip -c $CLIDRV_FILE" else

echo $CLIDRV_FILEegrep -i '\.Z *$' > /dev/null if [ "$?" == 0 ]; then

# for .tar.Z

CMD="zcat $CLIDRV_FILE" fi

fi

#list the contents of ODBC and CLI driver

#and then add redistributable file names to temp file

$CMD tar -tf -sed '/^ *$/d'awk '{print $1}'egrep -v '/$'\ while read fpath

do

BNAME=`basename $fpathsed 's/\./\\\./g'`

egrep '^ *'"$BNAME"' *$' "$REDIS_LIST" > /dev/null 2>&1 if [ $? == 0 ]; then

echo $fpath >> $FLIST

fi

done

#get the root path of ODBC and CLI driver CLIROOT=`head -n 1 $FLIST sed 's/\/.*//'`

#extract redistributable files from ODBC and CLI driver

#and then make a new package

$CMD tar -xf - `cat $FLIST`

tar -cf - $CLIROOTgzip -c > $OUTPUT_FILE.tar.gz

# show summary

COUNT=`wc -l $FLISTawk '{print $1}'`

echo "Totally "$COUNT" files added to new package "$OUTPUT_FILE.tar.gz"."

# clean up

rm -Rf $FLIST $CLIROOT

Chapter 4. Deploying applications with DB2 161

Page 175
Image 175
IBM manual Deploying applications with DB2