#!/bin/sh # Yes, that's POSIX sh, not bash! if [ -z "$TMPDIR" ] then TMPDIR=/tmp fi REALPATH=$(which realpath) if [ -z "$REALPATH" ] then REALPATH="readlink -f" fi tmpdir=`mktemp -d $TMPDIR/tmp.XXXXXX` conffile=${tmpdir}/nbd.conf pidfile=${tmpdir}/nbd.pid tmpnam=${tmpdir}/nbd.dd mydir=$(dirname $0) certdir=$($REALPATH ${mydir}/certs) cleanup="$2" PID="" DELAY=${DELAY:-1} set -e cleanup() { if [ -f ${pidfile} ] then kill `cat ${pidfile}` || true else if [ ! -z "$PID" ] then kill $PID || true fi fi if [ -z "$cleanup" ] then rm -rf $tmpdir else echo "Setup in $tmpdir" fi } abort() { cleanup trap - INT kill -INT $$ } trap -- cleanup EXIT trap -- abort INT # Create a one-meg device dd if=/dev/zero of=$tmpnam bs=1024 count=4096 >/dev/null 2>&1 echo $1 case $1 in */cfgsize) # Test oversized requests cat > ${conffile} < ${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <$tmpdir/confdir/exp1.conf <${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <${conffile} <