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.4KB

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