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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/sh
  2. set -e
  3. SUITE=lucid
  4. ARCH=amd64
  5. MIRROR=http://${MIRROR_HOST:-`hostname`}:3142/archive.ubuntu.com/ubuntu
  6. SECURITY_MIRROR=http://${MIRROR_HOST:-`hostname`}:3142/security.ubuntu.com/ubuntu
  7. usage() {
  8. echo "Usage: ${0##*/} [OPTION]... <command>"
  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).
  18. EOF
  19. }
  20. if [ $# != 0 ] ; then
  21. while true ; do
  22. case "$1" in
  23. --help|-h)
  24. usage
  25. exit 0
  26. ;;
  27. --suite|-s)
  28. SUITE="$2"
  29. shift 2
  30. ;;
  31. --arch|-a)
  32. ARCH="$2"
  33. shift 2
  34. ;;
  35. --*)
  36. echo "unrecognized option $1"
  37. exit 1
  38. ;;
  39. *)
  40. break
  41. ;;
  42. esac
  43. done
  44. fi
  45. mkdir -p var
  46. if [ ! -e var/id_dsa ]; then
  47. ssh-keygen -t dsa -f var/id_dsa -N ""
  48. fi
  49. OUT=base-$SUITE-$ARCH
  50. if [ -e $OUT.qcow2 ]; then
  51. echo $OUT.qcow2 already exists, please remove it first
  52. exit 1
  53. fi
  54. rm -rf $OUT
  55. 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
  56. mv $OUT/*.qcow2 $OUT.qcow2
  57. rm -rf $OUT