Renuka Apte | 4c88934 | 2012-03-08 13:15:03 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | ## makeubuntu.sh, this creates Ubuntu server 11.10 32 and 64 bit templates |
| 3 | ## on Xenserver 6.0.2 Net install only |
| 4 | ## Original Author: David Markey <david.markey@citrix.com> |
| 5 | ## Author: Renuka Apte <renuka.apte@citrix.com> |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 6 | ## This is not an officially supported guest OS on XenServer 6.0.2 |
Renuka Apte | 4c88934 | 2012-03-08 13:15:03 -0800 | [diff] [blame] | 7 | |
Renuka Apte | 668d9cb | 2012-04-11 11:42:54 -0700 | [diff] [blame] | 8 | BASE_DIR=$(cd $(dirname "$0") && pwd) |
| 9 | source $BASE_DIR/../../../localrc |
| 10 | |
John Garbutt | 37826bc | 2012-05-25 12:55:29 +0100 | [diff] [blame] | 11 | LENNY=$(xe template-list name-label=Debian\ Squeeze\ 6.0\ \(32-bit\) --minimal) |
Renuka Apte | 4c88934 | 2012-03-08 13:15:03 -0800 | [diff] [blame] | 12 | |
| 13 | if [[ -z $LENNY ]] ; then |
John Garbutt | 37826bc | 2012-05-25 12:55:29 +0100 | [diff] [blame] | 14 | echo "Cant find Squeeze 32bit template." |
Renuka Apte | 4c88934 | 2012-03-08 13:15:03 -0800 | [diff] [blame] | 15 | exit 1 |
| 16 | fi |
| 17 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 18 | distro="Ubuntu 11.10 for DevStack" |
Renuka Apte | 4c88934 | 2012-03-08 13:15:03 -0800 | [diff] [blame] | 19 | arches=("32-bit" "64-bit") |
| 20 | |
Renuka Apte | 360e29b | 2012-04-09 16:24:53 -0700 | [diff] [blame] | 21 | preseedurl=${1:-"http://images.ansolabs.com/devstackubuntupreseed.cfg"} |
Renuka Apte | 4c88934 | 2012-03-08 13:15:03 -0800 | [diff] [blame] | 22 | |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 23 | NETINSTALL_LOCALE=${NETINSTALL_LOCALE:-en_US} |
| 24 | NETINSTALL_KEYBOARD=${NETINSTALL_KEYBOARD:-us} |
| 25 | NETINSTALL_IFACE=${NETINSTALL_IFACE:-eth3} |
| 26 | |
Renuka Apte | 4c88934 | 2012-03-08 13:15:03 -0800 | [diff] [blame] | 27 | for arch in ${arches[@]} ; do |
| 28 | echo "Attempting $distro ($arch)" |
| 29 | if [[ -n $(xe template-list name-label="$distro ($arch)" params=uuid --minimal) ]] ; then |
| 30 | echo "$distro ($arch)" already exists, Skipping |
| 31 | else |
Renuka Apte | 668d9cb | 2012-04-11 11:42:54 -0700 | [diff] [blame] | 32 | if [ -z $NETINSTALLIP ] |
| 33 | then |
| 34 | echo "NETINSTALLIP not set in localrc" |
| 35 | exit 1 |
| 36 | fi |
John Garbutt | daadf74 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 37 | # Some of these settings can be found in example preseed files |
| 38 | # however these need to be answered before the netinstall |
| 39 | # is ready to fetch the preseed file, and as such must be here |
| 40 | # to get a fully automated install |
| 41 | pvargs="-- quiet console=hvc0 partman/default_filesystem=ext3 locale=${NETINSTALL_LOCALE} console-setup/ask_detect=false keyboard-configuration/layoutcode=${NETINSTALL_KEYBOARD} netcfg/choose_interface=${NETINSTALL_IFACE} netcfg/get_hostname=os netcfg/get_domain=os auto url=${preseedurl}" |
Renuka Apte | 668d9cb | 2012-04-11 11:42:54 -0700 | [diff] [blame] | 42 | if [ "$NETINSTALLIP" != "dhcp" ] |
| 43 | then |
| 44 | netcfgargs="netcfg/disable_autoconfig=true netcfg/get_nameservers=${NAMESERVERS} netcfg/get_ipaddress=${NETINSTALLIP} netcfg/get_netmask=${NETMASK} netcfg/get_gateway=${GATEWAY} netcfg/confirm_static=true" |
| 45 | pvargs="${pvargs} ${netcfgargs}" |
| 46 | fi |
Renuka Apte | 4c88934 | 2012-03-08 13:15:03 -0800 | [diff] [blame] | 47 | NEWUUID=$(xe vm-clone uuid=$LENNY new-name-label="$distro ($arch)") |
| 48 | xe template-param-set uuid=$NEWUUID other-config:install-methods=http,ftp \ |
| 49 | other-config:install-repository=http://archive.ubuntu.net/ubuntu \ |
Renuka Apte | 668d9cb | 2012-04-11 11:42:54 -0700 | [diff] [blame] | 50 | PV-args="$pvargs" \ |
Renuka Apte | 4c88934 | 2012-03-08 13:15:03 -0800 | [diff] [blame] | 51 | other-config:debian-release=oneiric \ |
| 52 | other-config:default_template=true |
| 53 | |
| 54 | if [[ "$arch" == "32-bit" ]] ; then |
| 55 | xe template-param-set uuid=$NEWUUID other-config:install-arch="i386" |
| 56 | else |
| 57 | xe template-param-set uuid=$NEWUUID other-config:install-arch="amd64" |
| 58 | fi |
| 59 | echo "Success" |
| 60 | fi |
| 61 | done |
| 62 | |
| 63 | echo "Done" |