Use febootstrap-run properly.
[febootstrap.git] / examples / guestfs-test.sh
index b45c1f4..8092ff2 100755 (executable)
@@ -13,6 +13,8 @@
 # This is a realistic example for 'libguestfs', which contains a
 # selection of command-line tools, LVM, NTFS and an NFS server.
 
+set -e
+
 if [ $(id -u) -eq 0 ]; then
     echo "Don't run this script as root.  Read instructions in script first."
     exit 1
@@ -39,7 +41,9 @@ echo -n "After minimization:  "; du -sh guestfs
 
 # Create the /init which will scan for and enable all LVM volume groups.
 
-( cd guestfs && cat > init <<'__EOF__'
+create_init ()
+{
+  cat > /init <<'__EOF__'
 #!/bin/sh
 PATH=/sbin:/usr/sbin:$PATH
 MAKEDEV mem null port zero core full ram tty console fd \
@@ -52,8 +56,10 @@ lvm vgscan --ignorelockingfailure
 lvm vgchange -ay --ignorelockingfailure
 /bin/bash -i
 __EOF__
-chmod +x init
-)
+  chmod +x init
+}
+export -f create_init
+../febootstrap-run ./guestfs -- bash -c create_init
 
 # Convert the filesystem to an initrd image.
 
@@ -62,6 +68,6 @@ chmod +x init
 # Now run qemu to boot this guestfs system.
 
 qemu-system-$(arch) \
-  -m 128 \
+  -m 256 \
   -kernel vmlinuz -initrd guestfs-initrd.img \
   -hda guest-image -boot c