lxc-ubuntu-cloud.in revision 542939c31bb73bab55f2fd71243b98f5559597d1
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#!/bin/bash
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# template script for generating ubuntu container for LXC based on released cloud
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# images
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Copyright © 2012 Serge Hallyn <serge.hallyn@canonical.com>
aa797403d51ff047727b77d64532001d6b6cc21aTimo Sirainen#
aa797403d51ff047727b77d64532001d6b6cc21aTimo Sirainen# This program is free software; you can redistribute it and/or modify
dff32d11a411a24f3b76003c1ae22c5a960f180eTimo Sirainen# it under the terms of the GNU General Public License version 2, as
b6b9c99fefbbc662bd9a0006566133c4480bf0e8Timo Sirainen# published by the Free Software Foundation.
b6b9c99fefbbc662bd9a0006566133c4480bf0e8Timo Sirainen
b6b9c99fefbbc662bd9a0006566133c4480bf0e8Timo Sirainen# This program is distributed in the hope that it will be useful,
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen# but WITHOUT ANY WARRANTY; without even the implied warranty of
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dff32d11a411a24f3b76003c1ae22c5a960f180eTimo Sirainen# GNU General Public License for more details.
dff32d11a411a24f3b76003c1ae22c5a960f180eTimo Sirainen
aa797403d51ff047727b77d64532001d6b6cc21aTimo Sirainen# You should have received a copy of the GNU General Public License along
8c2b4a45f17a5cb13bb01058ca37798cf48d91baTimo Sirainen# with this program; if not, write to the Free Software Foundation, Inc.,
8c2b4a45f17a5cb13bb01058ca37798cf48d91baTimo Sirainen# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
8c2b4a45f17a5cb13bb01058ca37798cf48d91baTimo Sirainen#
8c2b4a45f17a5cb13bb01058ca37798cf48d91baTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenset -e
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenif [ -r /etc/default/lxc ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen . /etc/default/lxc
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenfi
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainencopy_configuration()
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen{
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen path=$1
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen rootfs=$2
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen name=$3
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen arch=$4
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen release=$5
00e7c3010f7da4a49881a7feb05e413af353af0aTimo Sirainen
00e7c3010f7da4a49881a7feb05e413af353af0aTimo Sirainen if [ $arch = "i386" ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen arch="i686"
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen fi
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen # if there is exactly one veth network entry, make sure it has an
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen # associated hwaddr.
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l`
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen if [ $nics -eq 1 ]; then
caae18c876f81e261350e4957471efa453c0ea9fTimo Sirainen grep -q "^lxc.network.hwaddr" $path/config || cat <<EOF >> $path/config
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainenlxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')
433f5c9cc560a8cbff47257513d0bacb1cf250f4Timo SirainenEOF
3ee8a7ee6912c7caa4e83d3ce5a5db1590a7ffcdTimo Sirainen fi
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
edd318d5866ac3fbc6e8df28fb24a4dfef93c884Timo Sirainen cat <<EOF >> $path/config
cf9d67e4a9bfee31cf3be05244555d51a3d1b9feTimo Sirainenlxc.utsname = $name
edd318d5866ac3fbc6e8df28fb24a4dfef93c884Timo Sirainen
edd318d5866ac3fbc6e8df28fb24a4dfef93c884Timo Sirainenlxc.tty = 4
edd318d5866ac3fbc6e8df28fb24a4dfef93c884Timo Sirainenlxc.pts = 1024
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.rootfs = $rootfs
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.mount = $path/fstab
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.arch = $arch
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cap.drop = sys_module mac_admin
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.deny = a
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen# Allow any mknod (but not using the node)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.allow = c *:* m
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.allow = b *:* m
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# /dev/null and zero
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.allow = c 1:3 rwm
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.allow = c 1:5 rwm
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen# consoles
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.allow = c 5:1 rwm
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainenlxc.cgroup.devices.allow = c 5:0 rwm
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#lxc.cgroup.devices.allow = c 4:0 rwm
aa797403d51ff047727b77d64532001d6b6cc21aTimo Sirainen#lxc.cgroup.devices.allow = c 4:1 rwm
b6b9c99fefbbc662bd9a0006566133c4480bf0e8Timo Sirainen# /dev/{,u}random
152db3f90f298b7fb2dbbd4276f0fc30a9bc30f6Timo Sirainenlxc.cgroup.devices.allow = c 1:9 rwm
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.allow = c 1:8 rwm
89d6cd658eabf46e07e40037b0e641ed9be1a2a3Timo Sirainenlxc.cgroup.devices.allow = c 136:* rwm
89d6cd658eabf46e07e40037b0e641ed9be1a2a3Timo Sirainenlxc.cgroup.devices.allow = c 5:2 rwm
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# rtc
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.allow = c 254:0 rwm
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#fuse
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.allow = c 10:229 rwm
242abe3ad2423776e9cf05e1304eb8fda4831b23Timo Sirainen#tun
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainenlxc.cgroup.devices.allow = c 10:200 rwm
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen#full
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.allow = c 1:7 rwm
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#hpet
1df39b899804fd1dbc560f75382364822935c857Timo Sirainenlxc.cgroup.devices.allow = c 10:228 rwm
1df39b899804fd1dbc560f75382364822935c857Timo Sirainen#kvm
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenlxc.cgroup.devices.allow = c 10:232 rwm
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo SirainenEOF
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen cat <<EOF > $path/fstab
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenproc proc proc nodev,noexec,nosuid 0 0
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainensysfs sys sysfs defaults 0 0
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo SirainenEOF
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # rmdir /dev/shm for containers that have /run/shm
c4900d31385344bfadaee53a897daeafdb3063d8Timo Sirainen # I'm afraid of doing rm -rf $rootfs/dev/shm, in case it did
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # get bind mounted to the host's /run/shm. So try to rmdir
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen # it, and in case that fails move it out of the way.
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if [ ! -L $rootfs/dev/shm ] && [ -d $rootfs/run/shm ] && [ -e $rootfs/dev/shm ]; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen mv $rootfs/dev/shm $rootfs/dev/shm.bak
4aab01f4eade3d278b61471516c062ce30a84b5fTimo Sirainen ln -s /run/shm $rootfs/dev/shm
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen fi
152db3f90f298b7fb2dbbd4276f0fc30a9bc30f6Timo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen return 0
aa797403d51ff047727b77d64532001d6b6cc21aTimo Sirainen}
aa797403d51ff047727b77d64532001d6b6cc21aTimo Sirainen
433f5c9cc560a8cbff47257513d0bacb1cf250f4Timo Sirainenusage()
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen{
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen cat <<EOF
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo SirainenLXC Container configuration for Ubuntu Cloud images.
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo SirainenGeneric Options
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen[ -r | --release <release> ]: Release name of container, defaults to host
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen[ -a | --arch ]: Arhcitecture of container, defaults to host arcitecture
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen[ -C | --cloud ]: Configure container for use with meta-data service, defaults to no
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen[ -T | --tarball ]: Location of tarball
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen[ -d | --debug ]: Run with 'set -x' to debug errors
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen[ -s | --stream]: Use specified stream rather than 'released'
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
5e9bb72de1209cd39fdf3e95bdb26e047cc5594eTimo SirainenOptions, mutually exclusive of "-C" and "--cloud":
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen [ -i | --hostid ]: HostID for cloud-init, defaults to random string
5e9bb72de1209cd39fdf3e95bdb26e047cc5594eTimo Sirainen [ -u | --userdata ]: Cloud-init user-data file to configure container on start
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen [ -S | --auth-key ]: SSH Public key file to inject into container
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen [ -L | --nolocales ]: Do not copy host's locales into container
b6b9c99fefbbc662bd9a0006566133c4480bf0e8Timo Sirainen
b6b9c99fefbbc662bd9a0006566133c4480bf0e8Timo SirainenEOF
b6b9c99fefbbc662bd9a0006566133c4480bf0e8Timo Sirainen return 0
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainen}
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainen
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainenoptions=$(getopt -o a:hp:r:n:Fi:CLS:T:ds: -l arch:,help,path:,release:,name:,flush-cache,hostid:,auth-key:,cloud,no_locales,tarball:,debug,stream:,userdata: -- "$@")
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainenif [ $? -ne 0 ]; then
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainen usage $(basename $0)
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainen exit 1
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Sirainenfi
15ab2452b0220a115f4351ad9d7fd5ec70ae7966Timo Siraineneval set -- "$options"
b6b9c99fefbbc662bd9a0006566133c4480bf0e8Timo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenrelease=lucid
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainenif [ -f /etc/lsb-release ]; then
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen . /etc/lsb-release
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen case "$DISTRIB_CODENAME" in
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen lucid|natty|oneiric|precise|quantal)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen release=$DISTRIB_CODENAME
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen ;;
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen esac
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainenfi
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainenarch=$(arch)
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen# Code taken from debootstrap
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenif [ -x /usr/bin/dpkg ] && /usr/bin/dpkg --print-architecture >/dev/null 2>&1; then
1df39b899804fd1dbc560f75382364822935c857Timo Sirainen arch=`/usr/bin/dpkg --print-architecture`
1df39b899804fd1dbc560f75382364822935c857Timo Sirainenelif type udpkg >/dev/null 2>&1 && udpkg --print-architecture >/dev/null 2>&1; then
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen arch=`/usr/bin/udpkg --print-architecture`
else
arch=$(arch)
if [ "$arch" = "i686" ]; then
arch="i386"
elif [ "$arch" = "x86_64" ]; then
arch="amd64"
elif [ "$arch" = "armv7l" ]; then
# note: arm images don't exist before oneiric; are called armhf in
# precise and later; and are not supported by the query, so we don't actually
# support them yet (see check later on). When Query2 is available,
# we'll use that to enable arm images.
arch="armel"
fi
fi
debug=0
hostarch=$arch
cloud=0
locales=1
flushcache=0
stream="released"
while true
do
case "$1" in
-h|--help) usage $0 && exit 0;;
-p|--path) path=$2; shift 2;;
-n|--name) name=$2; shift 2;;
-F|--flush-cache) flushcache=1; shift 1;;
-r|--release) release=$2; shift 2;;
-a|--arch) arch=$2; shift 2;;
-i|--hostid) host_id=$2; shift 2;;
-u|--userdata) userdata=$2; shift 2;;
-C|--cloud) cloud=1; shift 1;;
-S|--auth-key) auth_key=$2; shift 2;;
-L|--no_locales) locales=0; shift 2;;
-T|--tarball) tarball=$2; shift 2;;
-d|--debug) debug=1; shift 1;;
-s|--stream) stream=$2; shift 2;;
--) shift 1; break ;;
*) break ;;
esac
done
if [ $debug -eq 1 ]; then
set -x
fi
if [ "$arch" == "i686" ]; then
arch=i386
fi
if [ $hostarch = "i386" -a $arch = "amd64" ]; then
echo "can't create amd64 container on i386"
exit 1
fi
if [ $arch != "i386" -a $arch != "amd64" ]; then
echo "Only i386 and amd64 are supported by the ubuntu cloud template."
exit 1
fi
if [ "$stream" != "daily" -a "$stream" != "released" ]; then
echo "Only 'daily' and 'released' streams are supported"
exit 1
fi
if [ -n "$userdata" -a ! -f "$userdata" ]; then
echo "Userdata does not exist"
exit 1
fi
if [ -z "$path" ]; then
echo "'path' parameter is required"
exit 1
fi
if [ "$(id -u)" != "0" ]; then
echo "This script should be run as 'root'"
exit 1
fi
rootfs=$path/rootfs
type ubuntu-cloudimg-query
type wget
# determine the url, tarball, and directory names
# download if needed
cache="/var/cache/lxc/cloud-$release"
mkdir -p $cache
if [ -n "$tarball" ]; then
url2="$tarball"
else
url1=`ubuntu-cloudimg-query $release $stream $arch --format "%{url}\n"`
url2=`echo $url1 | sed -e 's/.tar.gz/-root\0/'`
fi
filename=`basename $url2`
wgetcleanup()
{
rm -f $filename
}
buildcleanup()
{
cd $rootfs
umount -l $cache/$xdir || true
rm -rf $cache
}
# if the release doesn't have a *-rootfs.tar.gz, then create one from the
# cloudimg.tar.gz by extracting the .img, mounting it loopback, and creating
# a tarball from the mounted image.
build_root_tgz()
{
url=$1
filename=$2
xdir=`mktemp -d -p .`
tarname=`basename $url`
imgname="$release-*-cloudimg-$arch.img"
trap buildcleanup EXIT SIGHUP SIGINT SIGTERM
if [ $flushcache -eq 1 -o ! -f $cache/$tarname ]; then
rm -f $tarname
echo "Downloading cloud image from $url"
wget $url || { echo "Couldn't find cloud image $url."; exit 1; }
fi
echo "Creating new cached cloud image rootfs"
tar --wildcards -zxf $tarname $imgname
mount -o loop $imgname $xdir
(cd $xdir; tar zcf ../$filename .)
umount $xdir
rm -f $tarname $imgname
rmdir $xdir
echo "New cloud image cache created"
trap EXIT
trap SIGHUP
trap SIGINT
trap SIGTERM
}
mkdir -p /var/lock/subsys/
(
flock -x 200
cd $cache
if [ $flushcache -eq 1 ]; then
echo "Clearing the cached images"
rm -f $filename
fi
trap wgetcleanup EXIT SIGHUP SIGINT SIGTERM
if [ ! -f $filename ]; then
wget $url2 || build_root_tgz $url1 $filename
fi
trap EXIT
trap SIGHUP
trap SIGINT
trap SIGTERM
echo "Extracting container rootfs"
mkdir -p $rootfs
cd $rootfs
tar -zxf $cache/$filename
if [ $cloud -eq 0 ]; then
echo "Configuring for running outside of a cloud environment"
echo "If you want to configure for a cloud evironment, please use '-- -C' to create the container"
seed_d=$rootfs/var/lib/cloud/seed/nocloud-net
rhostid=$(uuidgen | cut -c -8)
host_id=${hostid:-$rhostid}
mkdir -p $seed_d
cat > "$seed_d/meta-data" <<EOF
instance_id: lxc-$host_id
EOF
rm $rootfs/etc/hostname
if [ $locales -eq 1 ]; then
cp /usr/lib/locale/locale-archive $rootfs/usr/lib/locale/locale-archive
fi
if [ -n "$auth_key" -a -f "$auth_key" ]; then
u_path="/home/ubuntu/.ssh"
root_u_path="$rootfs/$u_path"
mkdir -p $root_u_path
cp $auth_key "$root_u_path/authorized_keys"
chroot $rootfs chown -R ubuntu: "$u_path"
echo "Inserted SSH public key from $auth_key into /home/ubuntu/.ssh/authorized_keys"
fi
if [ -f "$userdata" ]; then
echo "Using custom user-data"
cp $userdata $seed_d/user-data
else
if [ -z "$MIRROR" ]; then
MIRROR="http://archive.ubuntu.com/ubuntu"
fi
cat > "$seed_d/user-data" <<EOF
#cloud-config
output: {all: '| tee -a /var/log/cloud-init-output.log'}
apt-mirror: $MIRROR
manage_etc_hosts: localhost
locale: $(/usr/bin/locale | awk -F= '/LANG=/ {print$NF}')
EOF
fi
chroot $rootfs /usr/sbin/usermod -U ubuntu
echo "ubuntu:ubuntu" | chroot $rootfs chpasswd
echo "Please login as user ubuntu with password ubuntu."
else
echo "Configured for running in a cloud environment."
echo "If you do not have a meta-data service, this container will likely be useless."
fi
) 200>/var/lock/subsys/lxc-ubucloud
copy_configuration $path $rootfs $name $arch $release
echo "Container $name created."
exit 0