#!/bin/bash -

# Enable core dumps.
ulimit -c unlimited

# Location of self-compiled Curl (from git):
export LD_LIBRARY_PATH=~/d/curl/lib/.libs

# Location of self-compiled qemu (from git):
export LIBGUESTFS_QEMU=~/d/qemu/qemu.wrapper
export PATH=~/d/qemu:$PATH

# Set up libguestfs to run qemu directly instead of using libvirt:
export LIBGUESTFS_BACKEND=direct

# Enable libguestfs debugging (optional):
export LIBGUESTFS_DEBUG=1
export LIBGUESTFS_TRACE=1

# Location of remote disk image over http:
#disk="http://192.168.0.249/scratch/plan9.iso"
#disk="http://mirrorservice.org/sites/dl.fedoraproject.org/pub/fedora/linux/releases/18/Fedora/x86_64/iso/Fedora-18-x86_64-DVD.iso"
disk="http://libguestfs.org/plan9.iso"
format="raw"

# For ISOs:
args="-m /dev/sda"
# For regular OS disks:
#args="-i"

# Location of libguestfs directory (compiled from git):
cd ~/d/libguestfs

# Run guestfish script.
./run ./fish/guestfish --ro --format="$format" -a "$disk" $args <<EOF
  find /
EOF
