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 23PKGNAME=bonnie++-1.03e 24TARNAME="$PKGNAME.tgz" 25PROGNAME=bonnie++ 26 27# How much RAM do we have? 28RAM=`cat /proc/meminfo | grep MemTotal | awk -F " " '{print $2}'` 29SPACE_REQUIRED=`expr $RAM \* 4` 30 31# Now figure out where we have mounted filesystems 32MOUNTS=`egrep "(ext|reiser)" /proc/mounts | awk -F " " '{print $2}'` 33 34RET=$( 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 46if [ ! -z $RET ]; then 47 echo "[bonnie++] Insufficient space. Free space: $FREE_SPACE kB. Space required: $SPACE_REQUIRED kB. Not building bonnie." 48 exit 1 49fi 50 51# Is it already installed? 52PROG=`which $PROGNAME` 53if [ ! -z "$PROG" ]; then 54 exit 0 55fi 56 57# Retrieve binary, if necessary 58cd "$POUNDER_OPTDIR" 59if [ ! -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 66fi 67 68# Unpack if req'd 69if [ ! -d "$PKGNAME" ]; then 70 tar -xzf "$TARNAME" 71fi 72 73# Build 74cd "$PKGNAME" 75./configure 76make $* 77