Home | History | Annotate | Download | only in build_scripts
      1 #!/bin/bash
      2 
      3 # Builds bonnie++
      4 
      5 # Copyright (C) 2003-2006 IBM
      6 #
      7 # This program is free software; you can redistribute it and/or
      8 # modify it under the terms of the GNU General Public License as
      9 # published by the Free Software Foundation; either version 2 of the
     10 # License, or (at your option) any later version.
     11 #
     12 # This program is distributed in the hope that it will be useful, but
     13 # WITHOUT ANY WARRANTY; without even the implied warranty of
     14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15 # General Public License for more details.
     16 #
     17 # You should have received a copy of the GNU General Public License
     18 # along with this program; if not, write to the Free Software
     19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
     20 # 02111-1307, USA.
     21 
     22 
     23 PKGNAME=bonnie++-1.03e
     24 TARNAME="$PKGNAME.tgz"
     25 PROGNAME=bonnie++
     26 
     27 # How much RAM do we have?
     28 RAM=`cat /proc/meminfo | grep MemTotal | awk -F " " '{print $2}'`
     29 SPACE_REQUIRED=`expr $RAM \* 4`
     30 
     31 # Now figure out where we have mounted filesystems
     32 MOUNTS=`egrep "(ext|reiser)" /proc/mounts | awk -F " " '{print $2}'`
     33 
     34 RET=$(
     35 	echo $MOUNTS | sed -e 's/ /\n/g' | while read f; do
     36 
     37         	# Do we have enough space? (assume 4x RAM is enough)
     38         	FREE_SPACE=`df -k -P "$f" | tail -n 1 | awk -F " " '{print $4}'`
     39 
     40         	if [ "$FREE_SPACE" -lt "$SPACE_REQUIRED" ]; then
     41 			break
     42         	fi
     43 	done
     44 )
     45 
     46 if [ ! -z $RET ]; then
     47         echo "[bonnie++] Insufficient space. Free space: $FREE_SPACE kB. Space required: $SPACE_REQUIRED kB. Not building bonnie."
     48 	exit 1
     49 fi
     50 
     51 # Is it already installed?
     52 PROG=`which $PROGNAME`
     53 if [ ! -z "$PROG" ]; then
     54 	exit 0
     55 fi
     56 
     57 # Retrieve binary, if necessary
     58 cd "$POUNDER_OPTDIR"
     59 if [ ! -f "$TARNAME" ]; then
     60 	if [ $USE_CACHE -eq 1 ]; then
     61 		wget "${POUNDER_CACHE}${TARNAME}"
     62 	fi
     63 	if [ ! -f "$TARNAME" ]; then
     64 		wget "http://www.coker.com.au/bonnie++/$TARNAME"
     65 	fi
     66 fi
     67 
     68 # Unpack if req'd
     69 if [ ! -d "$PKGNAME" ]; then
     70 	tar -xzf "$TARNAME"
     71 fi
     72 
     73 # Build
     74 cd "$PKGNAME"
     75 ./configure
     76 make $*
     77