/usr/lib/x86_64-linux-gnu/lxc/lxc-containers is in lxc-utils 3.0.0-0ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | #!/bin/sh
sysconfdir="/etc"
distrosysconfdir="/etc/default"
bindir="/usr/bin"
localstatedir="/var"
# These can be overridden in /etc/default/lxc
# Autostart containers?
LXC_AUTO="true"
# 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
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.
SHUTDOWNDELAY=5
# OPTIONS can be used for anything else.
# If you want to boot everything then
# options can be "-a" or "-a -A".
OPTIONS=
# STOPOPTS are stop options. The can be used for anything else to stop.
# If you want to kill containers fast, use -k
STOPOPTS="-a -A -s"
if [ -d "$localstatedir"/lock/subsys ]
then
lockdir="$localstatedir"/lock/subsys
else
lockdir="$localstatedir"/lock
fi
# Source any configurable options
[ ! -f "$distrosysconfdir"/lxc ] || . "$distrosysconfdir"/lxc
# Check for needed utility program
[ -x "$bindir"/lxc-autostart ] || exit 1
# If libvirtd is providing the bridge, it might not be
# immediately available, so wait a bit for it before starting
# up the containers or else any that use the bridge will fail
# to start
wait_for_bridge()
{
[ "x$USE_LXC_BRIDGE" = "xtrue" ] || { return 0; }
local BRNAME try flags br
[ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
BRNAME=`grep '^[ ]*lxc.net.0.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
if [ -z "$BRNAME" ]; then
return 0
fi
for try in `seq 1 30`; do
for br in ${BRNAME}; do
[ -r /sys/class/net/${br}/flags ] || { sleep 1; continue 2; }
read flags < /sys/class/net/${br}/flags
[ $((flags & 0x1)) -eq 1 ] || { sleep 1; continue 2; }
done
return 0
done
}
# See how we were called.
case "$1" in
start)
[ "x$LXC_AUTO" = "xtrue" ] || { exit 0; }
[ ! -f "$lockdir"/lxc ] || { exit 0; }
if [ -n "$BOOTGROUPS" ]; then
BOOTGROUPS="-g $BOOTGROUPS"
fi
touch "$lockdir"/lxc
# Start containers
wait_for_bridge
# Start autoboot containers first then the NULL group "onboot,".
"$bindir"/lxc-autostart $OPTIONS $BOOTGROUPS
rm -f "$lockdir"/lxc
;;
stop)
if [ -n "$SHUTDOWNDELAY" ]; then
SHUTDOWNDELAY="-t $SHUTDOWNDELAY"
fi
# 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.
"$bindir"/lxc-autostart $STOPOPTS $SHUTDOWNDELAY
;;
restart|reload|force-reload)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}"
exit 2
;;
esac
exit $?
|