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 # Source function library.
36 test ! -r "$sysconfdir"/rc.d
/init.d
/functions ||
37 .
"$sysconfdir"/rc.d
/init.d
/functions
39 # provide action() fallback
40 if ! type action
>/dev
/null
2>&1; then
41 # Real basic fallback for sysvinit "action" verbage.
44 "$@" && echo "OK" ||
echo "Failed"
48 if [ -d "$localstatedir"/lock
/subsys
]
50 lockdir
="$localstatedir"/lock
/subsys
52 lockdir
="$localstatedir"/lock
55 # Source any configurable options
56 [ ! -f "$distrosysconfdir"/lxc
] || .
"$distrosysconfdir"/lxc
58 # Check for needed utility program
59 [ -x "$bindir"/lxc-autostart
] ||
exit 1
61 # If libvirtd is providing the bridge, it might not be
62 # immediately available, so wait a bit for it before starting
63 # up the containers or else any that use the bridge will fail
67 [ -f "$sysconfdir"/lxc
/default.conf
] ||
{ return 0; }
69 which ifconfig
>/dev
/null
2>&1
73 which ip
>/dev
/null
2>&1
78 [ -n cmd
] ||
{ return 0; }
80 BRNAME
=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
81 if [ -z "$BRNAME" ]; then
85 for try
in `seq 1 30`; do
86 eval $cmd |
grep "^$BRNAME" >/dev
/null
2>&1
94 # See how we were called.
97 [ "x$LXC_AUTO" = "xtrue" ] ||
{ exit 0; }
99 [ ! -f "$lockdir"/lxc
] ||
{ exit 0; }
101 if [ -n "$BOOTGROUPS" ]; then
102 BOOTGROUPS
="-g $BOOTGROUPS"
108 # Start autoboot containers first then the NULL group "onboot,".
109 action $
"Starting LXC autoboot containers: " "$bindir"/lxc-autostart
$OPTIONS $BOOTGROUPS
114 if [ -n "$SHUTDOWNDELAY" ]; then
115 SHUTDOWNDELAY
="-t $SHUTDOWNDELAY"
118 # The stop is serialized and can take excessive time. We need to avoid
119 # delaying the system shutdown / reboot as much as we can since it's not
120 # parallelized... Even 5 second timout may be too long.
121 action $
"Stopping LXC containers: " "$bindir"/lxc-autostart
$STOPOPTS $SHUTDOWNDELAY
125 restart|reload|force-reload
)
131 echo "Usage: $0 {start|stop|restart|reload|force-reload}"