Commit Graph

114 Commits

Author SHA1 Message Date
Simon Deziel
df7216f664 Create the apt proxy in the cache instead of the 1st container
This addresses https://github.com/lxc/lxc/issues/280.

Signed-off-by: Simon Deziel <simon@sdeziel.info>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-10-27 17:39:24 -04:00
Stéphane Graber
206a255e17
ubuntu: Check that btrfs is actually available
Before calling btrfs and playing with subvolumes, let's make sure the
btrfs command is available.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-08-15 19:59:45 -04:00
Serge Hallyn
68c36a303f ubuntu templates: don't check for $rootfs/run/shm
/dev/shm must be turned from a directory into a symlink to /run/shm.
The templates do this only if they find -d $rootfs/run/shm.  Since /run
will be a tmpfs, checking for it in the rootfs is silly.  It also is
currently broken as ubuntu cloud images have an empty /run.

(this should fix https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1353734)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-08-08 11:40:03 -04:00
Trần Ngọc Quân
04cda6d1d3 add help string for ubuntu templete
Signed-off-by: Trần Ngọc Quân <vnwildman@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-07-29 08:34:23 -05:00
José Martínez
5652d61020 lxc-ubuntu: update coding style
Signed-off-by: José Martínez <xosemp@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-07-07 10:49:12 -04:00
José Martínez
b6e07af7c2 lxc-ubuntu: fix btrfs when rootfs == realrootfs
Fix btrfs support when lxc-create does not bind-mount the rootfs.

Signed-off-by: José Martínez <xosemp@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-07-07 10:49:09 -04:00
José Martínez
654bf1af09 lxc-ubuntu: use btrfs subvolumes and snapshots
Try to create the cache rootfs as a btrfs subvolume, and use btrfs
snapshots to copy the rootfs if btrfs is selected as backing store.

Signed-off-by: José Martínez <xosemp@gmail.com>
2014-06-17 23:01:33 +02:00
Stéphane Graber
96283b5460
templates: Fix bashisms in common code
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-02-19 10:45:14 -05:00
Stéphane Graber
207bf0e475 templates: Make sure usual locations are in PATH
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-02-06 17:14:03 -05:00
TAMUKI Shoichi
c63c04fcaf templates: improve refusing to run unprivileged
For all templates except lxc-ubuntu-cloud and lxc-download, detect not
only --mapped-uid but also --mapped-gid and error out.  Detecting will
not be done after -- parameter because of non-option parameters.

Also, change the mode of lxc-archlinux.in 100755 to 100644.

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-02-06 11:05:20 -05:00
Stéphane Graber
8ec981fc8b templates: Refuse to run unprivileged
Only the download and ubuntu-cloud templates work with unprivileged
containers, for all others, detect --mapped-uid and error out as early
as possible, recommending the use of the download template.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-02-04 14:30:51 -05:00
Stéphane Graber
8a3c76b24d ubuntu/ubuntu-cloud: Add support for arm64 and ppc64el
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-29 11:43:22 +00:00
Stéphane Graber
3fefd6e6d5 ubuntu: Don't fail on invalid locale
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-15 23:48:59 -05:00
Stéphane Graber
07219a02df ubuntu: Fix path to openssh-server's postinst
The path isn't relative to @LOCALSTATEDIR@

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-15 10:04:40 -05:00
Chris Glass
4213a747e8 Make ubuntu templates squid-deb-proxy-client aware
This makes the ubuntu and ubuntu-cloud templates automatically aware of apt
proxy settings when the LXC host has "squid-deb-proxy-client" installed. This
makes installations *much* faster when a suitable squid-deb-proxy is
found on the network (or installed on the host).

Signed-off-by: Chris Glass <tribaal@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-14 16:20:52 -05:00
Elan Ruusamäe
17abf2784d handle simple bashisms:
- [[ ]] -> [ ]
- == -> =
- source -> .
- redirect of fd 200 is error in mksh, use fd 9
- &> /dev/null -> > /dev/null 2>&1
- useless function keyword
- echo -e -> printf

still left bash shebang which did not validate with checkbashism, mostly
due 'type' being reported as bashism

Signed-Off-By: Elan Ruusamäe <glen@delfi.ee>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-14 16:16:00 -05:00
Stéphane Graber
3f5f5d99b0 Fix some typos
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-12 19:21:36 -05:00
Stéphane Graber
e8eab8b6d4
ubuntu: Fix initial container creation
The list of packages must be comma separated, not space separated.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-13 17:56:13 -05:00
Stéphane Graber
d2305c4cde
ubuntu: Make vim part of base template
This moves vim back to the default list of packages, drops the duplicate
ssh entry which means that unless extra packages are passed through
--packages, container creation won't invoke apt-get anymore.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-10 18:26:58 -05:00
S.Çağlar Onur
802f869f40 use $LOCALSTATEDIR/lock/subsys/lxc-ubuntu$release as lock filename
Otherwise one cannot create two containers with different releases
(let's say saucy [cached] and raring [not caced]) if both are not
cached on the local filesystem already. The lock blocks cached
one to move forward until not cached one finishes it's downloads.

Fix that by seperating locks using release names

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-09 15:04:46 -05:00
Stéphane Graber
f2a95ee1bf Move some common Ubuntu config
This introduces a new /usr/share/lxc/config directory containing common
configuration snippets.

The two Ubuntu templates are then simplified to just include the
relevant entries avoiding a whole lot of hardcoded cgroup, capabilities
and mount points configuration.

An extra comment is also added at the top of all generated configuration
files telling the user to look at lxc.conf(5) for more information.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-06 11:21:46 -05:00
Stéphane Graber
c5d32181c5 lxc-ubuntu: Replace the hostname in ssh pubkey
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-03 16:47:48 -05:00
Stéphane Graber
0a3673e807
Some tweak on previous change (timezone)
This adds the same code to the Debian-based templates (Ubuntu and Ubuntu
Cloud) and also avoids a needless fork.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-02 17:42:48 -05:00
Stéphane Graber
5ff337745e ubuntu: Actually attempt to remove /dev/shm
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-02 12:36:57 -05:00
Stéphane Graber
7ed86e4486
ubuntu: Fix regression in post-process
THe recent reorg of lxc-ubuntu introduced some package installation in
post-process but without first disabling service startup.

As a result, if the cache is a bit out of date and a ssh update is
available, post-process will apply that update (as it does apt-get
install ssh vim) which in turn will attemp to start sshd. This will
either lead to ssh on the host being restarted or if there's no sshd on
the host, will fail the container creation as the postinst will get an
error from upstart.

The fix is very simply to add the same policy-rc.d trick when running
post-process.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-27 19:46:18 -05:00
Stéphane Graber
8cd80b50ef
Convert all files to utf-8
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 12:59:07 -05:00
Guilhem Lettron
703d065d52 lxc-ubuntu: Factorize @LOCALSTATEDIR@ variable
Signed-off-by: Guilhem Lettron <guilhem.lettron@optiflows.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:29:55 -05:00
Guilhem Lettron
5eb28ae492 lxc-ubuntu: Add mirror and security-mirror options
Signed-off-by: Guilhem Lettron <guilhem.lettron@optiflows.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:29:46 -05:00
Guilhem Lettron
28b62856db lxc-ubuntu: Move package install to post-process
Signed-off-by: Guilhem Lettron <guilhem.lettron@optiflows.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:29:30 -05:00
Guilhem Lettron
2004e7da82 lxc-ubuntu: Add extra options
This adds support for "packages", "user" and "password"

Signed-off-by: Guilhem Lettron <guilhem.lettron@optiflows.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:28:47 -05:00
Elan Ruusamäe
853d58fdf5 use awk, instead of 'grep | awk'
Signed-off-by: Elan Ruusamäe <glen@delfi.ee>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:15:12 -05:00
Stéphane Graber
d59feca3be lxc-ubuntu*: Mark non-essential mounts optional
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-12 14:45:53 -06:00
Stéphane Graber
2ef89d565c lxc-ubuntu: Remove trim option
Container trimming is a bad idea in general, Ubuntu since 12.04 allows
standard systems to run in containers and we've got separate code to
deal with 10.04, so let's just drop trim.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-10-04 08:45:25 -05:00
Serge Hallyn
4d7bcfb638 ubuntu templates: make pstore fstab entry optional
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-16 11:48:38 -05:00
Serge Hallyn
84bce17b8b add pstore to container fstab
Otherwise user-namespace containers will hang on mountall.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-13 15:55:08 -05:00
Stéphane Graber
d08c3aaebc
ubuntu: iproute is now called iproute2
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-09-03 11:36:09 -04:00
Serge Hallyn
acbb59f50d fix license text in ubuntu and ubuntu-cloud templates
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-30 14:51:43 -05:00
Serge Hallyn
6f259716e7 ubuntu templates: add some kernel filesystems to container fstab
The debugfs, fusectl, and securityfs may not be mounted inside a
non-init userns.  But mountall hangs waiting for them to be
mounted.  So just pre-mount them using $lxcpath/$name/fstab as
bind mounts, which will prevent mountall from trying to mount
them.

If the kernel doesn't provide them, then the bind mount failure
will be ignored, and mountall in the container will proceed
without the mount since it is 'optional'.  But without these
bind mounts, starting a container inside a user namespace
hangs.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-07-17 09:56:57 -05:00
Stéphane Graber
9313e1e628
ubuntu: Tweak layout of the config
Just add an extra white line to both templates.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-07-09 18:30:52 -04:00
Stéphane Graber
6cda3f5ac1
ubuntu: Fix openssh postinst call in >= saucy
The new openssh uses a different mechanism to start/stop the daemon
which in turn requires a few tweaks in our template to deal with both
the new and old ways of doing that.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-07-08 16:41:08 -04:00
Serge Hallyn
1897e3bcd3 Move container creation fully into the api
1. implement bdev->create:

python and lua: send NULL for bdevtype and bdevspecs.
They'll want to be updated to pass those in in a way that makes
sense, but I can't think about that right now.

2. templates: pass --rootfs

If the container is backed by a device which must be mounted (i.e.
lvm) then pass the actual rootfs mount destination to the
templates.

Note that the lxc.rootfs can be a mounted block device.  The template
should actually be installing the rootfs under the path where the
lxc.rootfs is *mounted*.

Still, some people like to run templates by hand and assume purely
directory backed containers, so continue to support that use case
(i.e. if no --rootfs is listed).

Make sure the templates don't re-write lxc.rootfs if it is
already in the config.  (Most were already checking for that)

3. Replace lxc-create script with lxc_create.c program.

Changelog:
May 24: when creating a container, create $lxcpath/$name/partial,
and flock it.  When done, close that file and unlink it.  In
lxc_container_new() and lxcapi_start(), check for this file.  If
it is locked, create is ongoing.  If it exists but is not locked,
create() was killed - remove the container.

May 24: dont disk-lock during lxcapi_create.  The partial lock
is sufficient.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-05-25 19:27:07 -05:00
Serge Hallyn
b85ab7989e ubuntu templates: add comments to show how to enable nesting
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-05-02 16:28:10 -05:00
Serge Hallyn
eee3ba81c8 templates: deny writes to host's clock (v2)
Don't allow write to /dev/rtc0, and remove sys_time.

Thanks, Christoph.

v2: drop sys_time, sys_module, mac_admin and mac_override in
all templates.

Reported-by: Christoph Mitasch <cmitasch@thomas-krenn.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-05-01 14:00:41 -05:00
Stéphane Graber
dc7f65454e
ubuntu: Don't break when the locale is C.*
Update the code to also match C.* so that C.UTF-8 doesn't make the
container creation fail.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-25 01:31:11 +02:00
Serge Hallyn
cf0f903326
detect APT_PROXY from host apt.conf
Introduce a new HTTP_PROXY variable in /etc/default/lxc.  If unset or
set to none, then behavior continues as before.  If set to 'apt', then
any http::proxy set in apt.conf will be used as http_proxy for
debootstrap, and specified in the container's
/etc/apt/apt.conf.d/70proxy.  If set to something else, then the
value of HTTP_PROXY will be used as http_proxy for debootstrap and
specified in the container's 70proxy.

Changelog: (apr 23) merge the two apt proxy detection functions.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-24 00:57:18 +02:00
Stéphane Graber
a2abaa9ec6
ubuntu: Various fixes
- Drop disabled entries from allowed devices list
 - Improve generated config layout a bit
 - Drop redundant uname call
 - Re-generate the SSH host keys on container creation

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-22 08:59:53 +02:00
Christian Bühler
ed4616b1cf Use "uname -m" instead of "arch"
According to "arch"'s manpage, it's identical to "uname -m".

Some distros ship uname but don't ship arch, however all distros ship uname,
therefore it makes sense to use "uname -m" whenever possible.

Signed-off-by: Christian Bühler <christian@cbuehler.de>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-21 20:23:40 +02:00
Dwight Engen
75129865d4 ubuntu template: fix installation when LANG=C
The ubuntu template will silently fail (because it is set -e) on
the locale-gen command when LANG=C

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-10 23:11:05 +02:00
Stéphane Graber
8a63c0a9d9 ubuntu: Tweak architecture support
This updates the various checks to match the grid below:

== lxc-ubuntu support per architecture ==
amd64: amd64, i386, armel, armhf, powerpc
i386: i386, armel, armhf, powerpc
armel: armel, armhf
armhf: armhf, armel
powerpc: powerpc

== lxc-ubuntu-cloud support per architecture ==
amd64: amd64, i386
i386: i386
armel: armel, armhf
armhf: armhf, armel

Note that most of the foreign architectures on x86 are supported
through the use of qemu-user-static. This one however isn't yet
support for cloud images (I'll send a patch for 1.0).

Also, qemu-user-static is technically able to emulate amd64 on i386
but qemu-debootstrap doesn't appear to know that and fails quite miserably.

We may also want to add a test for amd64 kernel but i386 userspace, which
is a valid combination that allows running an amd64 container on an i386
host without requiring emulation, but that's for another patch.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-03-27 09:19:42 -04:00
Stéphane Graber
daaf41b367 lxc-ubuntu{-cloud}: Config layout tweaking
This commit tweaks the layout of the config file for the Ubuntu templates.

With this, we now get a clear network config group, then a path related group,
then a bunch of random config options and the end of the config is apparmor,
capabilities and cgroups.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-02-19 14:51:09 -05:00