IBM Data Server DB2 User Manual
Page 175
Chapter 4. Deploying applications with DB2
161
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_FILE|egrep -i '\.gz *$' > /dev/null
if [ "$?" == 0 ]; then
# for .tar.gz
CMD="gunzip -c $CLIDRV_FILE"
else
echo $CLIDRV_FILE|egrep -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 $fpath|sed '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 - $CLIROOT|gzip -c > $OUTPUT_FILE.tar.gz
# show summary
COUNT=`wc -l $FLIST|awk '{print $1}'`
echo "Totally "$COUNT" files added to new package "$OUTPUT_FILE.tar.gz"."
# clean up
rm -Rf $FLIST $CLIROOT