lxc-ubuntu.in revision 39aa5856f03898a84684c074ffb35bd0fa538b23
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# template script for generating ubuntu container for LXC
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# This script consolidates and extends the existing lxc ubuntu scripts
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Copyright � 2011 Serge Hallyn <serge.hallyn@canonical.com>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Copyright � 2010 Wilhelm Meier
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Author: Wilhelm Meier <wilhelm.meier@fh-kl.de>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# This program is free software; you can redistribute it and/or modify
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# it under the terms of the GNU General Public License version 2, as
b0e26ca77b3bb9908dda4a27504e805f1b8b5ee0KATOH Yasufumi# published by the Free Software Foundation.
3220ecebfc2822a55b9848b002a5495d30f479b9KATOH Yasufumi# This program is distributed in the hope that it will be useful,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# but WITHOUT ANY WARRANTY; without even the implied warranty of
842948e4162d89ffce0e8cd292702598d736489aKATOH Yasufumi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# GNU General Public License for more details.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# You should have received a copy of the GNU General Public License along
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# with this program; if not, write to the Free Software Foundation, Inc.,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiiface lo inet loopback
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiiface eth0 inet dhcp
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi127.0.0.1 localhost $hostname
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi # remove jobs for consoles 5 and 6 since we only create 4 consoles in
case $2 in
MIRROR=${MIRROR:-http://archive.ubuntu.com/ubuntu}
MIRROR=${MIRROR:-http://archive.ubuntu.com/ubuntu}
cache=$1
arch=$2
release=$3
packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,dhcp3-client,ssh,lsb-release,gnupg
packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,dhcp3-client,ssh,lsb-release,gnupg,netbase
packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,isc-dhcp-client,isc-dhcp-common,ssh,lsb-release,gnupg,netbase
packages=dialog,apt,apt-utils,iproute,inetutils-ping,vim,isc-dhcp-client,isc-dhcp-common,ssh,lsb-release,gnupg,netbase,ubuntu-keyring
if [ $? -ne 0 ]; then
qemu-debootstrap --verbose --components=main,universe --arch=$arch --include=$packages $release $cache/partial-$arch $MIRROR
debootstrap --verbose --components=main,universe --arch=$arch --include=$packages $release $cache/partial-$arch $MIRROR
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
ret=$?
if [ $? -ne 0 ]; then
ret=$?
cache=$1
arch=$2
rootfs=$3
rootfs=$1
release=$2
flushcache=$3
flock -n -x 200
if [ $? -ne 0 ]; then
if [ $flushcache -eq 1 ]; then
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
path=$1
rootfs=$2
name=$3
arch=$4
release=$5
if [ $? -ne 0 ]; then
rootfs=$1
release=$2
rootfs=$1
release=$2
if [ $trim_container -eq 1 ]; then
cat /etc/resolv.conf > ${cresolvonf}
rm -f ${cresolvonf}
mv ${cresolvonf}.lxcbak ${cresolvonf}
mkdir -p ${rootfs}/etc/dpkg/dpkg.cfg.d
> ${rootfs}/etc/apt/sources.list
chroot $rootfs apt-get install --force-yes -y --no-install-recommends upstart:${hostarch} mountall:amd64 iproute:amd64 isc-dhcp-client:amd64
rootfs=$1
user=$2
cat <<EOF
options=$(getopt -o a:b:hp:r:xn:FS:d -l arch:,bindhome:,help,path:,release:,trim,name:,flush-cache,auth-key:,debug -- "$@")
eval set -- "$options"
echo "Error: no password entry found for $bindhome"
type debootstrap
if [ -z "$path" ]; then
echo "failed to install ubuntu $release"
echo "failed to configure ubuntu $release for a container"
if [ ! -z $bindhome ]; then