You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

make-base-vm 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. set -e
  3. SUITE=lucid
  4. ARCH=amd64
  5. MIRROR=http://${MIRROR_HOST:-10.0.2.2}:3142/archive.ubuntu.com/ubuntu
  6. SECURITY_MIRROR=http://${MIRROR_HOST:-10.0.2.2}:3142/security.ubuntu.com/ubuntu
  7. usage() {
  8. echo "Usage: ${0##*/} [OPTION]..."
  9. echo "Make a base client."
  10. echo
  11. cat << EOF
  12. --help display this help and exit
  13. --suite=U build suite U instead of lucid
  14. --arch=A build architecture A (e.g. i386) instead of amd64
  15. The MIRROR_HOST environment variable can be used to change the
  16. apt-cacher host. It should be something that the target VM can
  17. resolve (not localhost). By default it is the IP address 10.0.2.2
  18. which is the host IP as visible from the guest.
  19. EOF
  20. }
  21. if [ $# != 0 ] ; then
  22. while true ; do
  23. case "$1" in
  24. --help|-h)
  25. usage
  26. exit 0
  27. ;;
  28. --suite|-s)
  29. SUITE="$2"
  30. shift 2
  31. ;;
  32. --arch|-a)
  33. ARCH="$2"
  34. shift 2
  35. ;;
  36. --*)
  37. echo "unrecognized option $1"
  38. exit 1
  39. ;;
  40. *)
  41. break
  42. ;;
  43. esac
  44. done
  45. fi
  46. mkdir -p var
  47. if [ ! -e var/id_dsa ]; then
  48. ssh-keygen -t dsa -f var/id_dsa -N ""
  49. fi
  50. OUT=base-$SUITE-$ARCH
  51. if [ -e $OUT.qcow2 ]; then
  52. echo $OUT.qcow2 already exists, please remove it first
  53. exit 1
  54. fi
  55. rm -rf $OUT
  56. sudo vmbuilder kvm ubuntu --arch=$ARCH --suite=$SUITE --addpkg=openssh-server,pciutils,build-essential,git-core,subversion --ssh-key=var/id_dsa.pub --ssh-user-key=var/id_dsa.pub --mirror=$MIRROR --security-mirror=$SECURITY_MIRROR --dest=$OUT --flavour=virtual
  57. mv $OUT/*.qcow2 $OUT.qcow2
  58. rm -rf $OUT