Commit Graph

61 Commits

Author SHA1 Message Date
Josh Soref
da43e9e51a spelling: timeout
Signed-off-by: Josh Soref <jsoref@gmail.com>
2018-10-30 08:14:58 +00:00
fliiiix
1b459eded4 Rename ifup/down and remove usless parameter passing
Signed-off-by: Felix <de-ch@hotmail.de>
2018-03-22 17:11:17 +01:00
Jonathan Calmels
bbb8e190f1 lxc-net: add LXC_DHCP_PING boolean option
Excerpt from dnsmasq(8):
By default, the DHCP server will attempt to ensure that an address in not
in use before allocating it to a host. It does this by sending an ICMP echo
request (aka "ping") to the address in question. If it gets a reply, then the
address must already be in use, and another is tried. This flag disables this check.

This is useful if one expects all the containers to get an IP address
from the LXC authoritative DHCP server and wants to speed up the process
of getting a lease.

Signed-off-by: Jonathan Calmels <jcalmels@nvidia.com>
2017-12-19 15:18:28 -08:00
adrian5
09a4c38063 Fix typo in lxc-net script
Signed-off-by: adrian5 <adrian5@users.noreply.github.com>
2017-10-27 20:29:50 +02:00
0x0916
7fa3f2e9eb replace all lxc.network* with lxc.net*
This patch wipe all references to lxc.network{[i]}.*
and replace with lxc.net.{[i]}.* in templates, documentation
and configuration files.

Signed-off-by: 0x0916 <w@laoqinren.net>
2017-06-29 13:18:41 +08:00
JD Friedrikson
c08d29b6d1
Use lxc-stop to stop systemd service
Ever since 8eb62c2, systemd has not been able to cleanly stop lxc
containers (via lxc@) because it's still using SIGPWR for systemd-based
containers.

We should now use the nice logic in 330ae3d to stop the containers
instead.

Signed-off-by: JD Friedrikson <yours@decompo.site>
2017-05-31 18:04:37 -04:00
Torsten Fohrer
723d30f7ff Avoid waiting for bridge interface if disabled in sysconfig/lxc | lxc-net via USE_LXC_BRIDGE
Signed-off-by: Torsten Fohrer <tfohrer@googlemail.com>
2017-03-30 11:57:14 +02:00
Stéphane Graber
bd657b44e9
Fix mixed tab/spaces in previous patch
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2017-03-14 12:44:35 +00:00
Harald Dunkel
8fc698019c
Fix lxc-containers to support multiple bridges
Signed-off-by: Harald Dunkel <harald.dunkel@aixigo.de>
2017-03-14 12:42:15 +00:00
Carsten Brandt
4f4e7141dd
Make lxc-net return non-zero on failure
I found that even though the service lxc-net failed to start because I made some wrong configuration
settings the command exists zero.
So systemd reports the status of the service as good even though it failed:

    # service lxc-net status
    ● lxc-net.service - LXC network bridge setup
       Loaded: loaded (/lib/systemd/system/lxc-net.service; enabled)
       Active: active (exited) since Wed 2017-02-08 08:17:32 EST; 21min ago
      Process: 529 ExecStart=/usr/lib/x86_64-linux-gnu/lxc/lxc-net start (code=exited, status=0/SUCCESS)
     Main PID: 529 (code=exited, status=0/SUCCESS)
       CGroup: /system.slice/lxc-net.service

    Feb 08 08:17:30 dvm2 systemd[1]: Starting LXC network bridge setup...
    Feb 08 08:17:32 dvm2 lxc-net[529]: dnsmasq: failed to create listening socket for 10.2.2.1: Address already in use
    Feb 08 08:17:32 dvm2 lxc-net[529]: Failed to setup lxc-net.
    Feb 08 08:17:32 dvm2 systemd[1]: Started LXC network bridge setup.

Adding `exit 1` here makes it exit non-zero to make systemd recognize the failure.

Signed-off-by: Carsten Brandt <mail@cebe.cc>
2017-02-08 14:54:02 +01:00
Evgeni Golov
2704c1ccdd add cgroupfs-mount to Should-Start/Stop sysvinit LSB headers
otherwise init might try to start the containers before cgroupfs was
mounted.

Debian-Bug: https://bugs.debian.org/850212

Signed-off-by: Evgeni Golov <evgeni@debian.org>
2017-01-12 12:51:55 +01:00
Cam Cope
84432621ed
Configure a static MAC address on the LXC bridge
Signed-off-by: Cam Cope <cam@dropbox.com>
2016-11-22 15:16:32 -08:00
Evgeni Golov
79c07e4b11 also stop lxc-net in runlevels 0 and 6
there is no reason to not do this :)

Signed-off-by: Evgeni Golov <evgeni@debian.org>
2016-11-12 12:29:26 +01:00
Evgeni Golov
6a27d555e7 add Documentation entries to lxc and lxc@ units
Signed-off-by: Evgeni Golov <evgeni@debian.org>
2016-10-08 14:09:17 +02:00
AnrDaemon
abf28de1e6 Force lxc-instance to behave like a good Upstart client
Remove unnecessary shell wrap around job start.
Force foreground execution to allow job monitoring and control.

Signed-off-by Andrey Repin <anrdaemon@yandex.ru>
2016-06-24 06:19:51 +03:00
Stéphane Graber
7c76d6b7b7 Drop lxc-devsetup as unneeded by current autodev
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2016-06-07 15:11:07 -04:00
Evgeni Golov
c4e50f1d41 start containers in foreground when using the lxc@.service
lxc-start started to default to daemonize the container when starting
this conflicts with type=simple of the systemd unit

call lxc-start with -F and thus force execution in foreground
that way we can feed the log to journald properly and keep type=simple

Debian-Bug: https://bugs.debian.org/826100
Signed-off-by: Evgeni Golov <evgeni@golov.de>
2016-06-02 15:42:25 +02:00
Evgeni Golov
3083782cf8 don't make sysv init scripts dependant on distribution specifics
- /etc(/rc.d)?/init.d/functions does not exist on all distributions
- LSB does not define a message function without an explicit status
- Debian-derived systems add a log_daemon_msg for that

lets define an own log_daemon_msg as echo and try to load LSB init
functions afterwards, which might overload it with a nicer version

that way the init scripts should work on any system, without hard
dependencies on neither LSB nor /etc/init.d/functions

Closes #309 #310 #311

Signed-off-by: Evgeni Golov <evgeni@debian.org>
2016-04-15 21:23:57 +02:00
Evgeni Golov
a5747ee708 drop obsolete syslog.target from lxc.service.in
the target is obsolete since systemd v38 which everybody should have.

original patch by Daniel Baumann

Signed-off-by: Evgeni Golov <evgeni@debian.org>
2016-04-14 18:03:29 +02:00
Evgeni Golov
26ca5e5bcf add missing lsb headers to sysvinit scripts
original patch by Daniel Baumann

closes #308

Signed-off-by: Evgeni Golov <evgeni@debian.org>
2016-04-13 17:55:48 +02:00
Aleksandr Mezin
a5c28c86f5 Fix installation of out-of-tree (VPATH) builds
Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
2016-03-25 19:30:49 +06:00
Stéphane Graber
892560848d
Fix dist tarball to include lxc-devsetup
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2016-03-07 18:31:27 -05:00
Carlos Alberto Lopez Perez
a8c7106328 Execute script lxc-devsetup also with sysvinit and upstart.
* This script sets /dev/.lxc which is needed for autodev containers.
  * Previously was only executed with systemd. Execute it also with
    the other init systems (sysvinit and upstart)

Signed-off-by: Carlos Alberto Lopez Perez <clopez@igalia.com>
2016-03-04 18:37:27 +01:00
TAMUKI Shoichi
cdcae1034c Fold dnsmasq command line in lxc-net.in
Fold dnsmasq command line at about 80 chars because the line is too
long.

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-12-09 22:56:59 -05:00
Serge Hallyn
4ed565e51a lxc-net: switch After target to network-online.target
Otherwise it may start too early and end up taking 10.0.3.1 even
though eth0 was eventually going to end up on 10.0.3.x.

https://bugs.launchpad.net/juju-core/+bug/1510619

Reported-by: Ryan Harper <ryan.harper@ubuntu.com>
Cc: Martin Pitt <martin.pitt@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-10-29 17:56:33 -04:00
Stéphane Graber
d2111444dd init: Support older apparmor
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-08-27 15:35:01 -04:00
Stéphane Graber
f2a7f2a080 Merge pull request #577 from CameronNemo/systemd-instanced
Add instanced systemd service
2015-08-13 16:03:33 -04:00
Alex Punco
e145bd47c6 fix container creation from ansible lxc_containers module
Signed-off-by: Alex Punco <punco@selectel.ru>
2015-07-13 17:42:45 +03:00
Cameron Norman
de2b7e655f Add instanced systemd service
Signed-off-by: Cameron Norman <camerontnorman@gmail.com>
2015-07-01 14:18:35 -07:00
Serge Hallyn
8e13cca944 systemd: fix lxc-containers vs lxc-net ordering (v3)
Per pitti's suggestion, use After= to force lxc to wait for lxc-net to finish
running.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Reviewed-By: Martin Pitt <martin.pitt@ubuntu.com>
2015-06-30 09:34:09 -05:00
Stéphane Graber
dfb5edcac0 lxc-net: Use iproute and relative paths everywhere (V2)
V2 changes:
 - Keep using /var/lib for the lease file, but making it respect localstatedir
 - Don't pass an empty --conf-file as that confuses dnsmasq when
   /etc/dnsmasq.conf doesn't exist or isn't readable.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-06-29 13:36:55 -04:00
Martin Pitt
580f58c79b Call /lib/apparmor/profile-load directly instead of the wrapper
AppArmor ships /lib/apparmor/profile-load. /lib/init/apparmor-profile-load is
merely a wrapper which calls the former, so just call it directly to avoid the
dependency on the wrapper.

LP: #1432683
2015-05-07 13:38:50 +02:00
Stéphane Graber
47fcda9926
Fix lxc-net regression on missing restorecon
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2015-04-28 09:01:40 +02:00
Stéphane Graber
370f2e811c lxc-net: Rework/cleanup
This updates lxc-net with the following changes:
 - Better recover from crashes/partial runs
 - Better error detection and reporting
 - Less code duplication (use the stop code on crash)
 - Better state tracking
 - Allow for restart of all of lxc-net except for the bridge itself
 - Only support iproute from this point on (ifconfig's been deprecated
   for years)

V2: Use template variables everywhere

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-04-28 08:23:17 +02:00
Stéphane Graber
d47961ebd6 Add IPv6 support to lxc-net
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-04-24 11:00:32 -04:00
Stéphane Graber
50066f4f7e Prefer iproute over ifconfig
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-03-11 12:25:05 -04:00
Jörg Thalheim
6a9390e349 systemd: enable delegate in service file
Signed-off-by: Jörg Thalheim <joerg@higgsboson.tk>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-01-24 16:50:56 -05:00
S.Çağlar Onur
5fdd4b0c11 restore the dropped bits of 1c1bb85ad2 and also implement the logic
suggested at
https://lists.linuxcontainers.org/pipermail/lxc-devel/2014-December/010985.html

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-01-20 16:40:41 -05:00
Dwight Engen
f3b8088dd8 systemd/selinux init scripts fixups
- RHEL/OL 7 doesn't have the ifconfig command by default so have the
  lxc-net script check for its existence before use, and fall back
  to using the ip command if ifconfig is not available

- When lxc-net is run from systemd on a system with selinux enabled,
  the mkdir -p ${varrun} will create /run/lxc as init_var_run_t which
  dnsmasq can't write its pid into, so we restorecon it
  after creation (to var_run_t)

- The lxc-net systemd .service file needs an [Install] section so that
  "systemctl enable lxc-net" will work

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2014-10-08 17:57:33 -04:00
Joshua Brunner
f422613e69 fix: grep not match interface listed by ip link list
Interfaces listed by `ip link list` are prefixed with the index
identifier. The pattern "^$BRNAME" does not match.

 - dependencies to ifconfig and ip removed
 - wait until interface flagged with IFF_UP

Ref: https://github.com/torvalds/linux/blob/master/include/uapi/linux/if.h

Signed-off-by: Joshua Brunner <j.brunner@nexbyte.com>
2014-10-06 12:06:27 -04:00
Dwight Engen
fce070c815 fixups to init script rework
- move action() from common to sysvinit wrapper since its only really
  applicable for sysvinit and not the other init systems

- fix bug in action() fallback, need to shift away msg before executing action

- make lxc-net 98 so it starts before lxc-container (99), otherwise the lxcbr0
  won't be available when containers are autostarted

- make the default RUNTIME_PATH be /var/run instead of /run. On older
  distros (like ol6.5) /run doesn't exist. lxc-net will create this directory
  and attempt to create the dnsmasq.pid file in it, but this will fail when
  SELinux is enabled because the directory will have the default_t type.
  Newer systems have /var/run symlinked to /run so you get to the same place
  in that case.

- add %postun to remove lxc-dnsmasq user when pkgs are removed

- fix bug in lxc-oracle template that was creating /var/lock/subsys/lxc as
  a dir and interfering with the init scripts

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-09-29 12:17:11 -04:00
Michael H. Warfield
0af993195c Rework init scripts
This commit is based on the work of:
    Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>

A generic changelog would be:
 - Bring support for lxcbr0 to all distributions
 - Share the container startup and network configuration logic across
   distributions and init systems.
 - Have all the init scripts call the helper script.
 - Support for the various different distro-specific configuration
   locations to configure lxc-net and container startup.

Changes on top of Mike's original version:
 - Remove sysconfig/lxc-net as it's apparently only there as a
   workaround for an RPM limitation and is breaking Debian systems by
   including a useless file which will get registered as a package provided
   conffile in the dpkg database and will therefore cause conffile prompts
   on upgrades...
 - Go with a consistant coding style in the various init scripts.
 - Split out the common logic from the sysvinit scripts and ship both in
   their respective location rather than have them be copies.
 - Fix the upstart jobs so they actually work (there's no such thing as
   libexec on Debian systems).

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-09-26 10:55:11 -04:00
Martin Pitt
2b24e2ff84 systemd: Load AppArmor profiles if necessary/supported
On Ubuntu we need to set up the AppArmor profiles also under systemd.
Add a new helper "lxc-apparmor-load" and integrate it into lxc.service.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-08-04 15:24:39 -04:00
Martin Pitt
84b3775a09 systemd: Ensure action() is defined
If /etc/rc.d/init.d/functions is not present or does not define an action()
function, provide a simple fallback using "echo".

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-08-04 15:24:20 -04:00
Martin Pitt
65b27d845f Add systemd unit for lxc.net
This is the equivalent of the upstart lxc-net.conf to set up the LXC bridge.

This also drops "lxc.service" from tarballs. It is built source which depends
on configure options, so the statically shipped file will not work on most
systems.

https://launchpad.net/bugs/1312532

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-08-04 15:24:17 -04:00
Martin Pitt
213b0fe063 Get systemd unit dir from pkg-config
Don't install systemd unit files into $(prefix), they won't work there.
Instead, get them from systemd's pkg-config file.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-08-04 15:24:13 -04:00
Martin Pitt
2ed776214a Move lxcbr0 setup logic into lxc.net script
Factor this out of the lxc-net.conf upstart job, so that it can be used by
init.d scripts and systemd units, too.

Part of https://launchpad.net/bugs/1312532

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-08-04 15:24:03 -04:00
Ansa89
31098f8b9d Sysvinit script fixes
Signed-off-by: Stefano Ansaloni <ansalonistefano@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-07-21 13:10:38 +02:00
Dwight Engen
d74b6771c0 fix the expansion of libexecdir when not explicitly passed to configure
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-20 14:32:25 -04:00
Michael H. Warfield
015f0dd792 lxc-autostart: rework boot and group handling
This adds new functionality to lxc-autostart.

*) The -g / --groups option is multiple cummulative entry.
	This may be mixed freely with the previous comma separated
	group list convention.  Groups are processed in the
	order they first appear in the aggregated group list.

*) The NULL group may be specified in the group list using either a
	leading comma, a trailing comma, or an embedded comma.

*) Booting proceeds in order of the groups specified on the command line
	then ordered by lxc.start.order and name collalating sequence.

*) Default host bootup is now specified as "-g onboot," meaning that first
	the "onboot" group is booted and then any remaining enabled
	containers in the NULL group are booted.

*) Adds documentation to lxc-autostart for -g processing order and
	combinations.

*) Parameterizes bootgroups, options, and shutdown delay in init scripts
	and services.

*) Update the various init scripts to use lxc-autostart in a similar way.

Reported-by: CDR <venefax@gmail.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 11:10:01 -04:00