blob: 7f10c336d14f5edd3d91e2cea16836c14facfd7e [file] [log] [blame]
Renuka Apte4c889342012-03-08 13:15:03 -08001#!/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 Garbuttdaadf742012-04-27 18:28:28 +01006## This is not an officially supported guest OS on XenServer 6.0.2
Renuka Apte4c889342012-03-08 13:15:03 -08007
Renuka Apte668d9cb2012-04-11 11:42:54 -07008BASE_DIR=$(cd $(dirname "$0") && pwd)
9source $BASE_DIR/../../../localrc
10
John Garbutt37826bc2012-05-25 12:55:29 +010011LENNY=$(xe template-list name-label=Debian\ Squeeze\ 6.0\ \(32-bit\) --minimal)
Renuka Apte4c889342012-03-08 13:15:03 -080012
13if [[ -z $LENNY ]] ; then
John Garbutt37826bc2012-05-25 12:55:29 +010014 echo "Cant find Squeeze 32bit template."
Renuka Apte4c889342012-03-08 13:15:03 -080015 exit 1
16fi
17
John Garbuttdaadf742012-04-27 18:28:28 +010018distro="Ubuntu 11.10 for DevStack"
Renuka Apte4c889342012-03-08 13:15:03 -080019arches=("32-bit" "64-bit")
20
Renuka Apte360e29b2012-04-09 16:24:53 -070021preseedurl=${1:-"http://images.ansolabs.com/devstackubuntupreseed.cfg"}
Renuka Apte4c889342012-03-08 13:15:03 -080022
John Garbuttdaadf742012-04-27 18:28:28 +010023NETINSTALL_LOCALE=${NETINSTALL_LOCALE:-en_US}
24NETINSTALL_KEYBOARD=${NETINSTALL_KEYBOARD:-us}
25NETINSTALL_IFACE=${NETINSTALL_IFACE:-eth3}
26
Renuka Apte4c889342012-03-08 13:15:03 -080027for 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 Apte668d9cb2012-04-11 11:42:54 -070032 if [ -z $NETINSTALLIP ]
33 then
34 echo "NETINSTALLIP not set in localrc"
35 exit 1
36 fi
John Garbuttdaadf742012-04-27 18:28:28 +010037 # 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 Apte668d9cb2012-04-11 11:42:54 -070042 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 Apte4c889342012-03-08 13:15:03 -080047 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 Apte668d9cb2012-04-11 11:42:54 -070050 PV-args="$pvargs" \
Renuka Apte4c889342012-03-08 13:15:03 -080051 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
61done
62
63echo "Done"