mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 06:21:08 +00:00

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>
72 lines
2.0 KiB
Plaintext
72 lines
2.0 KiB
Plaintext
description "lxc"
|
|
author "Serge Hallyn <serge.hallyn@canonical.com>"
|
|
|
|
start on runlevel [2345]
|
|
stop on starting rc RUNLEVEL=[016]
|
|
|
|
env LXC_AUTO="false"
|
|
|
|
# These can be overridden in /etc/default/lxc
|
|
|
|
# BOOTGROUPS - What groups should start on bootup?
|
|
# Comma separated list of groups.
|
|
# Leading comma, trailing comma or embedded double
|
|
# comma indicates when the NULL group should be run.
|
|
# Example (default): boot the onboot group first then the NULL group
|
|
env BOOTGROUPS="onboot,"
|
|
|
|
# SHUTDOWNDELAY - Wait time for a container to shut down.
|
|
# Container shutdown can result in lengthy system
|
|
# shutdown times. Even 5 seconds per container can be
|
|
# too long.
|
|
env SHUTDOWNDELAY=5
|
|
|
|
# OPTIONS can be used for anything else.
|
|
# If you want to boot everything then
|
|
# options can be "-a" or "-a -A".
|
|
env OPTIONS=
|
|
|
|
# STOPOPTS are stop options. The can be used for anything else to stop.
|
|
# If you want to kill containers fast, use -k
|
|
env STOPOPTS="-a -A -s"
|
|
|
|
pre-start script
|
|
[ -f /etc/default/lxc ] && . /etc/default/lxc
|
|
|
|
# don't load profiles if mount mediation is not supported
|
|
SYSF=/sys/kernel/security/apparmor/features/mount/mask
|
|
if [ -f $SYSF ]; then
|
|
if [ -x /lib/init/apparmor-profile-load ]; then
|
|
/lib/init/apparmor-profile-load usr.bin.lxc-start
|
|
/lib/init/apparmor-profile-load lxc-containers
|
|
fi
|
|
fi
|
|
|
|
[ "x$LXC_AUTO" = "xtrue" ] || exit 0
|
|
|
|
if [ -n "$BOOTGROUPS" ]
|
|
then
|
|
BOOTGROUPS="-g $BOOTGROUPS"
|
|
fi
|
|
|
|
# Process the "onboot" group first then the NULL group.
|
|
lxc-autostart -L $OPTIONS $BOOTGROUPS | while read line; do
|
|
set -- $line
|
|
(start lxc-instance NAME=$1 && sleep $2) || true
|
|
done
|
|
end script
|
|
|
|
# The stop is serialized and can take excessive time. We need to avoid
|
|
# delaying the system shutdown / reboot as much as we can since it's not
|
|
# parallelized... Even 5 second timout may be too long.
|
|
post-stop script
|
|
[ -f /etc/default/lxc ] && . /etc/default/lxc
|
|
|
|
if [ -n "$SHUTDOWNDELAY" ]
|
|
then
|
|
SHUTDOWNDELAY="-t $SHUTDOWNDELAY"
|
|
fi
|
|
|
|
lxc-autostart $STOPOPTS $SHUTDOWNDELAY || true
|
|
end script
|