| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 | #!/bin/bashDIR=$(dirname `readlink -f $0`). $DIR/../testing.conf. $DIR/function.sh[ `id -u` -eq 0 ] || die "You must be root to run $0"running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"[ -n "$1" ] || die "$0 <image to mount: base|root|<guest>>"check_commands partprobe qemu-nbdload_qemu_nbdmkdir -p $LOOPDIRmkdir -p $IMGDIRmkdir -p $SHAREDDIRecho "Mounting image"case "$1" inbase)	[ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"	log_action "Connecting base image to NBD device $NBDEV"	execute "qemu-nbd -c $NBDEV $BASEIMG"	affected="root and guest"	;;root)	[ -f "$ROOTIMG" ] || die "Root image $ROOTIMG not found"	log_action "Connecting root image to NBD device $NBDEV"	execute "qemu-nbd -c $NBDEV $ROOTIMG"	affected="guest"	;;*)	echo $STRONGSWANHOSTS | grep -q "\b$1\b" || die "Guest $1 not found"	GUESTIMG="$IMGDIR/$1.$IMGEXT"	[ -f "$GUESTIMG" ] || die "Guest image $GUESTIMG not found"	log_action "Connecting guest image to NBD device $NBDEV"	execute "qemu-nbd -c $NBDEV $GUESTIMG"	;;esacdo_on_exit qemu-nbd -d $NBDEVpartprobe $NBDEVlog_action "Mounting $NBDPARTITION to $LOOPDIR"execute "mount $NBDPARTITION $LOOPDIR"do_on_exit umount $LOOPDIRlog_action "Mounting proc filesystem to $LOOPDIR/proc"execute "mount -t proc none $LOOPDIR/proc"do_on_exit umount $LOOPDIR/procmkdir -p $LOOPDIR/root/sharedlog_action "Mounting $SHAREDDIR as /root/shared"execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared"do_on_exit umount $LOOPDIR/root/sharedif [ -n "$affected" ]; thenechoecho "Rebuild the $affected images after making changes to this image!"echofiexport debian_chroot="$1"chroot $LOOPDIR /bin/bash -i
 |