build-certs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. DIR="$(dirname `readlink -f $0`)/.."
  3. . $DIR/testing.conf
  4. . $DIR/scripts/function.sh
  5. [ `id -u` -eq 0 ] || die "You must be root to run $0"
  6. [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
  7. [ -f "$ROOTIMG" ] || die "Root image $ROOTIMG not found"
  8. running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
  9. SRCUID=${SUDO_UID:-$(id -u)}
  10. SRCGID=${SUDO_GID:-$(id -g)}
  11. check_commands partprobe qemu-img qemu-nbd bindfs
  12. load_qemu_nbd
  13. mkdir -p $LOOPDIR
  14. mkdir -p $IMGDIR
  15. log_action "Connecting root image to NBD device $NBDEV"
  16. execute "qemu-nbd -c $NBDEV $ROOTIMG"
  17. do_on_exit qemu-nbd -d $NBDEV
  18. partprobe $NBDEV
  19. log_action "Mounting $NBDPARTITION to $LOOPDIR"
  20. execute "mount $NBDPARTITION $LOOPDIR"
  21. do_on_exit umount $LOOPDIR
  22. log_action "Mounting proc filesystem to $LOOPDIR/proc"
  23. execute "mount -t proc none $LOOPDIR/proc"
  24. do_on_exit umount $LOOPDIR/proc
  25. mkdir -p $LOOPDIR/root/testing
  26. log_action "Mounting ${DIR} as /root/testing"
  27. execute "bindfs -u $SRCUID -g $SRCGID --create-for-user=$SRCUID --create-for-group=$SRCGID ${DIR} $LOOPDIR/root/testing"
  28. do_on_exit umount $LOOPDIR/root/testing
  29. log_action "Building certificates"
  30. execute_chroot "/root/testing/scripts/build-certs-chroot"
  31. # rebuild the guest images to generate the CRLs on winnetou
  32. if [ -z "$2" ]; then
  33. # cleanup before mounting guest images
  34. on_exit
  35. $DIR/scripts/build-guestimages
  36. fi