install gawk by default (required for gcc49 build)
[unleashed-kayak.git] / build_xen.sh
blob352f2c4472c54228a0efef4baa844d96ca632580
1 #!/bin/bash
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
21 # CDDL HEADER END
23 # Copyright 2013 by Andrzej Szeszo. All rights reserved.
25 # Copyright 2013 OmniTI Computer Consulting, Inc. All rights reserved.
26 # Use is subject to license terms.
29 [[ $(id -u) != 0 ]] && echo Please run this script as root && exit 1
31 . install_help.sh 2>/dev/null
32 . net_help.sh
33 . xen_help.sh
35 set -e
37 DISK=c0t2d0
38 ZFSSEND=/var/kayak/kayak/r151006.zfs.bz2
39 PVGRUB=pv-grub.gz.d3950d8
41 RPOOL=syspool
42 BENAME=omnios
43 ALTROOT=/mnt
44 UNIX=/platform/i86xpv/kernel/unix
46 zpool destroy $RPOOL 2>/dev/null || true
48 SetupPart
49 SetupPVGrub
50 SetupZPool
51 ZFSRecvBE
53 MountBE
55 # we need custom PV kernel because of this:
56 # https://www.illumos.org/issues/3172
57 if [[ -f $UNIX ]]; then
58 cp $UNIX $ALTROOT/platform/i86xpv/kernel/unix
59 chown root:sys $ALTROOT/platform/i86xpv/kernel/unix
62 PrepareBE
63 ApplyChanges
64 SetTimezone UTC
66 Postboot '/sbin/ipadm create-if xnf0'
67 Postboot '/sbin/ipadm create-addr -T dhcp xnf0/v4'
68 Postboot 'for i in 0 1 2 3 4 5 6 7 8 9; do curl -f http://169.254.169.254/ >/dev/null 2>&1 && break; sleep 1; done'
69 Postboot 'HOSTNAME=$(/usr/bin/curl http://169.254.169.254/latest/meta-data/hostname)'
70 Postboot '[[ -z $HOSTNAME ]] || (/usr/bin/hostname $HOSTNAME && echo $HOSTNAME >/etc/nodename)'
72 UmountBE
74 zpool export ${RPOOL}