Skip to content
This repository
tree: c9836cff2c
Fetching contributors…

Cannot retrieve contributors at this time

executable file 82 lines (66 sloc) 2.339 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#!/bin/bash
#
# Copyright (c) 2009-2012 VMware, Inc.

srcdir=$(dirname $(readlink -nf $0))
basedir=$(dirname $(readlink -nf ${srcdir/..}))
stemcelldir=$(dirname $(readlink -nf "${srcdir}/.."))
libdir=$basedir/lib
skeleton=$basedir/skeleton
kernel="lts-backport-natty"

. ${libdir}/helpers.sh

if [ $# -ne 2 ]
then
  echo "Usage: env `basename $0` [chroot_target] [instance_dir]"
  exit 1
fi

if [ `id -u` -ne "0" ]
then
  echo "Sorry, you need to be root"
  exit 1
fi

target=$1
instance_dir=$2

if [ ! -d $instance_dir ]
then
  echo "Instance directory $instance_dir doesn't exist or isn't a directory"
  exit 1
fi

debs='scsitools tshark mg htop module-assistant debhelper runit'

# Disable daemon startup
disable_daemon_startup $target $skeleton
add_on_exit "enable_daemon_startup $target"

# Set up mounts
mount --bind /dev $target/dev
mount --bind /dev/pts $target/dev/pts
chroot $target mount -t proc proc /proc
add_on_exit "umount ${target}/proc $target/dev/pts $target/dev"

# Custom kernel
echo "Installing kernel: $kernel"
run_in_chroot $target "env DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes --no-install-recommends linux-image-virtual-${kernel} linux-headers-virtual-${kernel}"

# Set up users/groups
run_in_chroot $target "addgroup --system admin
adduser --disabled-password --gecos Ubuntu vcap
echo vcap:ca\\\$hc0w | chpasswd
echo root:ca\\\$hc0w | chpasswd
"
for grp in admin adm audio cdrom dialout floppy video plugdev dip
do
  run_in_chroot $target "adduser vcap $grp"
done
cp $skeleton/etc/sudoers $target/etc/sudoers

# BOSH Specific configuration
mkdir -p $target/var/vcap/bosh
cp -r $instance_dir $target/var/vcap/bosh/src
cp $libdir/configure_bosh.sh $target/var/vcap/bosh/src
chmod 0755 $target/var/vcap/bosh/src

# open-vm-tools needed to be backported to work with the 2.6.38 kernel
# https://bugs.launchpad.net/ubuntu/+source/open-vm-tools/+bug/746152
run_in_chroot $target "dpkg -i /var/vcap/bosh/src/open-vm-*.deb"
# Fix missing dependencies for the open-vm debs
run_in_chroot $target "apt-get -f -y --force-yes --no-install-recommends install"

# Install packages
run_in_chroot $target "apt-get install -y --force-yes --no-install-recommends $debs"
run_in_chroot $target "apt-get clean"

chroot $target /var/vcap/bosh/src/configure_bosh.sh

# Clean up
run_in_chroot $target "apt-get clean"
Something went wrong with that request. Please try again.