echo $HOSTNAME
on_exit() {
  echo "Cleaning up"
  bin/pg_ctl -D /tmp/data stop -m immediate
  rm -r /tmp/data/
  exit 0
}

trap 'on_exit' USR2;
trap 'on_exit' INT;


rm -r /tmp/data/
cd /home/jjanes/pgsql_xlog_crash_test || exit
bin/initdb -D /tmp/data >& /dev/null|| exit
bin/pg_ctl -D /tmp/data start -o "--fsync=off --wal_buffers=2MB --shared_buffers=200MB" -w
bin/createdb
bin/psql -c 'create table foo(index int, count int); create unique index adlfkjdf on foo(index);'
#bin/pg_ctl -D /tmp/data restart -o "--JJ_torn_page=400 --fsync=off" -w
bin/pg_ctl -D /tmp/data restart -o "--JJ_torn_page=400" -w
for f in `seq 1 100`; do perl /home/jjanes/torn_write_test/count.pl; done;
on_exit
