lxc-debian.in revision 6a082d5a1370cd57ed05cf24aa800ae73112e818
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# lxc: linux Container library
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# Daniel Lezcano <daniel.lezcano@free.fr>
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# This library is free software; you can redistribute it and/or
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# modify it under the terms of the GNU Lesser General Public
a2f250a332dfc1e6cd4ffd196c621eb9dbf7b8a1Timo Sirainen# License as published by the Free Software Foundation; either
2d49f150b4bce6f2f59a84e268e4777901c3e42cTimo Sirainen# version 2.1 of the License, or (at your option) any later version.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# This library is distributed in the hope that it will be useful,
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# but WITHOUT ANY WARRANTY; without even the implied warranty of
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# Lesser General Public License for more details.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# You should have received a copy of the GNU Lesser General Public
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# License along with this library; if not, write to the Free Software
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# Detect use under userns (unsupported)
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen if [ "$arg" = "--mapped-uid" -o "$arg" = "--mapped-gid" ]; then
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen echo "This template can't be used for unprivileged containers." 1>&2
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen echo "You may want to try the \"download\" template instead." 1>&2
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# Make sure the usual locations are in PATH
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenexport PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/bin
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo SirainenMIRROR=${MIRROR:-http://http.debian.net/debian}
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo SirainenSECURITY_MIRROR=${SECURITY_MIRROR:-http://security.debian.org/}
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# Allows the lxc-cache directory to be set by environment variable
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo SirainenLXC_CACHE_PATH=${LXC_CACHE_PATH:-"$LOCALSTATEDIR/cache/lxc"}
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # squeeze only has /dev/tty and /dev/tty0 by default,
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # therefore creating missing device nodes for tty1-4.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen if [ ! -e $rootfs/dev/tty$tty ]; then
7ded22760598b78ee29f9418eacc0abe3fb51055Timo Sirainenid:3:initdefault:
7ded22760598b78ee29f9418eacc0abe3fb51055Timo Sirainensi::sysinit:/etc/init.d/rcS
7ded22760598b78ee29f9418eacc0abe3fb51055Timo Sirainenl0:0:wait:/etc/init.d/rc 0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenl1:1:wait:/etc/init.d/rc 1
7ded22760598b78ee29f9418eacc0abe3fb51055Timo Sirainenl2:2:wait:/etc/init.d/rc 2
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenl3:3:wait:/etc/init.d/rc 3
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenl4:4:wait:/etc/init.d/rc 4
8ababf3e7b15f793370d1dedf85825d38b42633fTimo Sirainenl5:5:wait:/etc/init.d/rc 5
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainenl6:6:wait:/etc/init.d/rc 6
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainen# Normally not reached, but fallthrough in case of emergency.
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainenz6:6:respawn:/sbin/sulogin
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainen1:2345:respawn:/sbin/getty 38400 console
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainenc1:12345:respawn:/sbin/getty 38400 tty1 linux
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenc2:12345:respawn:/sbin/getty 38400 tty2 linux
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainenc3:12345:respawn:/sbin/getty 38400 tty3 linux
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainenc4:12345:respawn:/sbin/getty 38400 tty4 linux
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainenp6::ctrlaltdel:/sbin/init 6
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenp0::powerfail:/sbin/init 0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen [ -e "$rootfs/etc/mtab" ] && rm $rootfs/etc/mtab
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Siraineniface lo inet loopback
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Siraineniface eth0 inet dhcp
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen chroot $rootfs /usr/sbin/update-rc.d -f checkroot.sh disable
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen chroot $rootfs /usr/sbin/update-rc.d -f umountfs disable
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh disable
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh disable
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen if [ -x $rootfs/var/lib/dpkg/info/openssh-server.postinst ]; then
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen if [ -f $rootfs/etc/init/ssh.conf ]; then
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen mv $rootfs/etc/init/ssh.conf $rootfs/etc/init/ssh.conf.disabled
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen DPKG_MAINTSCRIPT_PACKAGE=openssh DPKG_MAINTSCRIPT_NAME=postinst chroot $rootfs /var/lib/dpkg/info/openssh-server.postinst configure
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen sed -i "s/root@$(hostname)/root@$hostname/g" $rootfs/etc/ssh/ssh_host_*.pub
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen if [ -f "$rootfs/etc/init/ssh.conf.disabled" ]; then
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen mv $rootfs/etc/init/ssh.conf.disabled $rootfs/etc/init/ssh.conf
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen if [ -f /etc/timezone ]; then
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen elif [ -f /etc/sysconfig/clock ]; then
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen echo "Timezone in container is not configured. Adjust it manually."
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen echo "Root password is 'root', please change !"
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen cat >> "${rootfs}/etc/apt/sources.list" << EOF
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen${prefix} $MIRROR ${release} main contrib non-free
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen if [ "$release" != "unstable" -a "$release" != "sid" ]; then
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen cat >> "${rootfs}/etc/apt/sources.list" << EOF
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen${prefix} $SECURITY_MIRROR ${release}/updates main contrib non-free
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen chroot ${rootfs} apt-get install --force-yes -y --no-install-recommends ${packages}
6c9699d37fbe4d8af3682ee7f341ede8d54faa87Timo Sirainen # this only works if we have getty@.service to manipulate
6c9699d37fbe4d8af3682ee7f341ede8d54faa87Timo Sirainen if [ -f ${rootfs}/lib/systemd/system/getty\@.service ]; then
6c9699d37fbe4d8af3682ee7f341ede8d54faa87Timo Sirainen sed -e 's/^ConditionPathExists=/# ConditionPathExists=/' \
6c9699d37fbe4d8af3682ee7f341ede8d54faa87Timo Sirainen < ${rootfs}/lib/systemd/system/getty\@.service \
6c9699d37fbe4d8af3682ee7f341ede8d54faa87Timo Sirainen > ${rootfs}/etc/systemd/system/getty\@.service
ed50658501d9ae8c85f6264831056b1debed11c3Timo Sirainen mkdir -p ${rootfs}/etc/systemd/system/getty.target.wants
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # Fix getty-static-service as debootstrap does not install dbus
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen if [ -e $rootfs//lib/systemd/system/getty-static.service ] ; then
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen sed 's/ getty@tty[5-9].service//g' $rootfs/lib/systemd/system/getty-static.service | sed 's/\(tty2-tty\)[5-9]/\14/g' > $rootfs/etc/systemd/system/getty-static.service
b0be0bead3d6963149f7f2a9504b8ab5aced9af5Timo Sirainen # This function has been copied and adapted from lxc-fedora
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen rm -f ${rootfs}/etc/systemd/system/default.target
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen chroot ${rootfs} ln -s /dev/null /etc/systemd/system/udev.service
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen chroot ${rootfs} ln -s /dev/null /etc/systemd/system/systemd-udevd.service
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen chroot ${rootfs} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen chroot ${rootfs} ln -s /lib/systemd/system/halt.target /etc/systemd/system/sigpwr.target
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # Setup getty service on the 4 ttys we are going to allow in the
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen ( cd ${rootfs}/etc/systemd/system/getty.target.wants
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen for i in 1 2 3 4 ; do ln -sf ../getty\@.service getty@tty${i}.service; done )
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # check the mini debian was not already downloaded
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen if [ $? -ne 0 ]; then
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen echo "Failed to create '$cache/partial-$release-$arch' directory"
1fd0d511885c30028aba388588151acf4ee85e75Timo Sirainen debootstrap --verbose --variant=minbase --arch=$arch \
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen "$release" "$cache/partial-$release-$arch" $MIRROR
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen if [ $? -ne 0 ]; then
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen echo "Failed to download the rootfs, aborting."
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen mv "$1/partial-$release-$arch" "$1/rootfs-$release-$arch"
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen rsync -Ha "$cache/rootfs-$release-$arch"/ $rootfs/ || return 1
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen if [ $? -ne 0 ]; then
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen echo "Checking cache download in $cache/rootfs-$release-$arch ... "
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen if [ ! -e "$cache/rootfs-$release-$arch" ]; then
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen if [ $? -ne 0 ]; then
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen if [ $? -ne 0 ]; then
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen # if there is exactly one veth network entry, make sure it has an
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l`
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen if [ $nics -eq 1 ]; then
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen grep -q "^lxc.network.hwaddr" $path/config || sed -i -e "/^lxc\.network\.type[ \t]*=[ \t]*veth/a lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen if [ -e "${LXC_TEMPLATE_CONFIG}/debian.common.conf" ]; then
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen echo "lxc.include = ${LXC_TEMPLATE_CONFIG}/debian.common.conf" >> $path/config
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen if [ -e "${LXC_TEMPLATE_CONFIG}/debian.${release}.conf" ]; then
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen echo "lxc.include = ${LXC_TEMPLATE_CONFIG}/debian.${release}.conf" >> $path/config
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen echo "# Container specific configuration" >> $path/config
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen grep -q "^lxc.rootfs" $path/config 2> /dev/null || echo "lxc.rootfs = $rootfs" >> $path/config
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainenlxc.utsname = $hostname
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainenlxc.arch = $arch
2bd2ca14d18819b77201ab2b46910d9ae6858abeTimo Sirainen if [ $? -ne 0 ]; then
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # If the container isn't running a native architecture, setup multiarch
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen echo "foreign-architecture ${hostarch}" > ${rootfs}/etc/dpkg/dpkg.cfg.d/lxc-multiarch
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # Write a new sources.list containing both native and multiarch entries
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen write_sourceslist ${rootfs} ${release} ${arch}
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen local pack_list="`echo ${packages} | sed 's/,/ /g'`"
2d49f150b4bce6f2f59a84e268e4777901c3e42cTimo Sirainenen_US.UTF-8 UTF-8
2d49f150b4bce6f2f59a84e268e4777901c3e42cTimo Sirainen chroot $rootfs sed -e "s/^# \(${LANG} ${encoding}\)/\1/" \
2d49f150b4bce6f2f59a84e268e4777901c3e42cTimo Sirainen$LANG $encoding
50031a6b36a6051512bd18f39e4bbabe54acf565Timo Sirainen cache=${LXC_CACHE_PATH:-"$LOCALSTATEDIR/cache/lxc/debian"}
50031a6b36a6051512bd18f39e4bbabe54acf565Timo Sirainen if [ ! -e $cache ]; then
50031a6b36a6051512bd18f39e4bbabe54acf565Timo Sirainen # lock, so we won't purge while someone is creating a repository
b0be0bead3d6963149f7f2a9504b8ab5aced9af5Timo Sirainen if [ $? != 0 ]; then
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
7eff76882487ef39803446f75a709a97a3cafc53Timo SirainenTemplate specific options can be passed to lxc-create after a '--' like this:
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen lxc-create --name=NAME [-lxc-create-options] -- [-template-options]
2aa3ac8bfb8fea49fd0ab6d56afcb3af3375d22cTimo SirainenUsage: $1 -h|--help -p|--path=<path> [-c|--clean] [-a|--arch=<arch>] [-r|--release=<release>]
2aa3ac8bfb8fea49fd0ab6d56afcb3af3375d22cTimo Sirainen [--mirror=<mirror>] [--security-mirror=<security mirror>]
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen [--package=<package_name1,package_name2,...>]
50031a6b36a6051512bd18f39e4bbabe54acf565Timo Sirainen -h, --help print this help text
50031a6b36a6051512bd18f39e4bbabe54acf565Timo Sirainen -p, --path=PATH directory where config and rootfs of this VM will be kept
3e559edb905bb57d1f1fbfda3431b339f45ea791Timo Sirainen -a, --arch=ARCH The container architecture. Can be one of: i686, x86_64,
608ae99c5b03989df263d72e49aa83e1f9d8a50eTimo Sirainen amd64, armhf, armel, powerpc. Defaults to host arch.
608ae99c5b03989df263d72e49aa83e1f9d8a50eTimo Sirainen -r, --release=RELEASE Debian release. Can be one of: squeeze, wheezy, jessie, sid.
608ae99c5b03989df263d72e49aa83e1f9d8a50eTimo Sirainen Defaults to current stable.
608ae99c5b03989df263d72e49aa83e1f9d8a50eTimo Sirainen --mirror=MIRROR Debian mirror to use during installation. Overrides the MIRROR
50031a6b36a6051512bd18f39e4bbabe54acf565Timo Sirainen environment variable (see below).
50031a6b36a6051512bd18f39e4bbabe54acf565Timo Sirainen --security-mirror=SECURITY_MIRROR
50031a6b36a6051512bd18f39e4bbabe54acf565Timo Sirainen Debian mirror to use for security updates. Overrides the
50031a6b36a6051512bd18f39e4bbabe54acf565Timo Sirainen SECURITY_MIRROR environment variable (see below).
50031a6b36a6051512bd18f39e4bbabe54acf565Timo Sirainen --packages=PACKAGE_NAME1,PACKAGE_NAME2,...
3e559edb905bb57d1f1fbfda3431b339f45ea791Timo Sirainen List of additional packages to install. Comma separated, without space.
1d3f7c1278168d5b1cbfa9a2cc9929a0909056b4Timo Sirainen -c, --clean only clean up the cache and terminate
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo SirainenEnvironment variables:
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen MIRROR The Debian package mirror to use. See also the --mirror switch above.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen Defaults to '$MIRROR'
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen SECURITY_MIRROR The Debian package security mirror to use. See also the --security-mirror switch above.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen Defaults to '$SECURITY_MIRROR'
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenoptions=$(getopt -o hp:n:a:r:c -l arch:,clean,help,mirror:,name:,packages:,path:,release:,rootfs:,security-mirror: -- "$@")
b0be0bead3d6963149f7f2a9504b8ab5aced9af5Timo Sirainen --) shift 1; break ;;
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen --security-mirror) SECURITY_MIRROR=$2; shift 2;;
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenif [ $hostarch = "i386" -a $arch = "amd64" ]; then
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen echo "can't create $arch container on $hostarch"
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenif [ $hostarch = "armhf" -o $hostarch = "armel" ] && \
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen [ $arch != "armhf" -a $arch != "armel" ]; then
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen echo "can't create $arch container on $hostarch"
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenif [ $hostarch = "powerpc" -a $arch != "powerpc" ]; then
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen echo "can't create $arch container on $hostarch"
2aa3ac8bfb8fea49fd0ab6d56afcb3af3375d22cTimo Sirainen echo "'debootstrap' command is missing"
2aa3ac8bfb8fea49fd0ab6d56afcb3af3375d22cTimo Sirainenif [ -z "$path" ]; then
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen echo "'path' parameter is required"
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen echo "This script should be run as 'root'"
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainencurrent_release=`wget ${MIRROR}/dists/stable/Release -O - 2> /dev/null | head |awk '/^Codename: (.*)$/ { print $2; }'`
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainenvalid_releases=('squeeze' 'wheezy' 'jessie' 'stretch' 'sid')
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainenif [[ ! "${valid_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen echo "Invalid release ${release}, valid ones are: ${valid_releases[*]}"
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen# detect rootfs
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenif [ -z "$rootfs" ]; then
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen if grep -q '^lxc.rootfs' $config 2> /dev/null ; then
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $config)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Siraineninstall_debian $rootfs $release $arch $LXC_CACHE_PATH
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen echo "failed to install debian"
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen echo "failed to configure debian for a container"
b0be0bead3d6963149f7f2a9504b8ab5aced9af5Timo Sirainen echo "failed write configuration file"
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenpost_process ${rootfs} ${release} ${arch} ${hostarch} ${packages}
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenif [ ! -z "$clean" ]; then