3 sysconfdir
="@SYSCONFDIR@"
4 distrosysconfdir
="@LXC_DISTRO_SYSCONF@"
6 localstatedir
="@LOCALSTATEDIR@"
8 # These can be overridden in @LXC_DISTRO_SYSCONF@/lxc
10 # Autostart containers?
13 # BOOTGROUPS - What groups should start on bootup?
14 # Comma separated list of groups.
15 # Leading comma, trailing comma or embedded double
16 # comma indicates when the NULL group should be run.
17 # Example (default): boot the onboot group first then the NULL group
20 # SHUTDOWNDELAY - Wait time for a container to shut down.
21 # Container shutdown can result in lengthy system
22 # shutdown times. Even 5 seconds per container can be
26 # OPTIONS can be used for anything else.
27 # If you want to boot everything then
28 # options can be "-a" or "-a -A".
31 # STOPOPTS are stop options. The can be used for anything else to stop.
32 # If you want to kill containers fast, use -k
35 if [ -d "$localstatedir"/lock
/subsys
]
37 lockdir
="$localstatedir"/lock
/subsys
39 lockdir
="$localstatedir"/lock
42 # Source any configurable options
43 [ ! -f "$distrosysconfdir"/lxc
] || .
"$distrosysconfdir"/lxc
45 # Check for needed utility program
46 [ -x "$bindir"/lxc-autostart
] ||
exit 1
48 # If libvirtd is providing the bridge, it might not be
49 # immediately available, so wait a bit for it before starting
50 # up the containers or else any that use the bridge will fail
54 [ "x$USE_LXC_BRIDGE" = "xtrue" ] ||
{ return 0; }
56 local BRNAME try flags br
57 [ -f "$sysconfdir"/lxc
/default.conf
] ||
{ return 0; }
59 BRNAME
=`grep '^[ ]*lxc.net.0.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
60 if [ -z "$BRNAME" ]; then
64 for try
in `seq 1 30`; do
65 for br
in ${BRNAME}; do
66 [ -r /sys
/class
/net
/${br}/flags
] ||
{ sleep 1; continue 2; }
67 read flags
< /sys
/class
/net
/${br}/flags
68 [ $
((flags
& 0x1)) -eq 1 ] ||
{ sleep 1; continue 2; }
74 # See how we were called.
77 [ "x$LXC_AUTO" = "xtrue" ] ||
{ exit 0; }
79 [ ! -f "$lockdir"/lxc
] ||
{ exit 0; }
81 if [ -n "$BOOTGROUPS" ]; then
82 BOOTGROUPS
="-g $BOOTGROUPS"
88 # Start autoboot containers first then the NULL group "onboot,".
89 "$bindir"/lxc-autostart
$OPTIONS $BOOTGROUPS
94 if [ -n "$SHUTDOWNDELAY" ]; then
95 SHUTDOWNDELAY
="-t $SHUTDOWNDELAY"
98 # The stop is serialized and can take excessive time. We need to avoid
99 # delaying the system shutdown / reboot as much as we can since it's not
100 # parallelized... Even 5 second timout may be too long.
101 "$bindir"/lxc-autostart
$STOPOPTS $SHUTDOWNDELAY
104 restart|reload|force-reload
)
110 echo "Usage: $0 {start|stop|restart|reload|force-reload}"