]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc-autostart: Add a new --ignore-auto/-A flag
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 7 Mar 2014 18:32:16 +0000 (13:32 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 7 Mar 2014 22:18:44 +0000 (17:18 -0500)
When passed, this flag will cause lxc-autostart to ignore the value of
lxc.start.auto.

This then allows things like: lxc-autostart -s -a -A

Which will select all containers regardless of groups (-a), regardless
of whether they are actually marked as auto-started (-A) and will shut
them down (-s).

Update our init scripts to use the new feature.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
config/init/sysvinit/lxc
config/init/upstart/lxc.conf
doc/lxc-autostart.sgml.in
src/lxc/arguments.h
src/lxc/lxc_autostart.c

index 91281877a0711f2edc56ca474b8dc8b6ef07e448..436eef488e086d44c60b3ac80aa7193060b292ab 100755 (executable)
@@ -50,7 +50,7 @@ case "$1" in
        touch /var/lock/subsys/lxc
        ;;
   stop)
-       action $"Stopping LXC containers: " /usr/bin/lxc-autostart -s
+       action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
        rm -f /var/lock/subsys/lxc
        ;;
   restart|reload|force-reload)
index 1a5c5c99698f4b87f5be678c8ef494213730dc28..d5131adc4c3208232f4724eef432e5ab01177b4c 100644 (file)
@@ -25,3 +25,7 @@ pre-start script
                (start lxc-instance NAME=$1 && sleep $2) || true
        done
 end script
+
+post-stop script
+       lxc-autostart -a -A -s || true
+end script
index 985cbe43636de8356e8cbe974ba43708481f084f..3d423dde458267b093fa19f696a81e07dc2a8ff3 100644 (file)
@@ -51,6 +51,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
             <arg choice="opt">-r</arg>
             <arg choice="opt">-s</arg>
             <arg choice="opt">-a</arg>
+            <arg choice="opt">-A</arg>
             <arg choice="opt">-g <replaceable>groups</replaceable></arg>
             <arg choice="opt">-t <replaceable>timeout</replaceable></arg>
         </cmdsynopsis>
@@ -169,6 +170,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
                     </para>
                 </listitem>
             </varlistentry>
+
+            <varlistentry>
+                <term>
+                    <option>-A,--ignore-auto</option>
+                </term>
+                <listitem>
+                    <para>
+                        Ignore the lxc.start.auto flag. Combined with
+                        -a, will select all containers on the system.
+                    </para>
+                </listitem>
+            </varlistentry>
         </variablelist>
     </refsect1>
 
index 767bfcfc796a7723c0d04618f8009a64b8e5b94e..e5f06705a6fc2638ed875934e8d0d02d316895fe 100644 (file)
@@ -90,6 +90,7 @@ struct lxc_arguments {
 
        /* auto-start */
        int all;
+       int ignore_auto;
        int list;
        char *groups;
 
index cfb24d068b9e681ff9886431d46d877fb6e84633..ec9d9ba838eb609dfb4c5e55215b2b05234f01a4 100644 (file)
@@ -37,6 +37,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
        case 'r': args->reboot = 1; break;
        case 's': args->shutdown = 1; break;
        case 'a': args->all = 1; break;
+       case 'A': args->ignore_auto = 1; break;
        case 'g': args->groups = arg; break;
        case 't': args->timeout = atoi(arg); break;
        }
@@ -49,6 +50,7 @@ static const struct option my_longopts[] = {
        {"reboot", no_argument, 0, 'r'},
        {"shutdown", no_argument, 0, 's'},
        {"all", no_argument, 0, 'a'},
+       {"ignore-auto", no_argument, 0, 'A'},
        {"groups", required_argument, 0, 'g'},
        {"timeout", required_argument, 0, 't'},
        {"help", no_argument, 0, 'h'},
@@ -68,6 +70,7 @@ Options:\n\
   -s, --shutdown    shutdown the containers instead of starting them\n\
 \n\
   -a, --all         list all auto-started containers (ignore groups)\n\
+  -A, --ignore-auto ignore lxc.start.auto and select all matching containers\n\
   -g, --groups      list of groups (comma separated) to select\n\
   -t, --timeout=T   wait T seconds before hard-stopping\n",
        .options  = my_longopts,
@@ -246,7 +249,8 @@ int main(int argc, char *argv[])
                        continue;
                }
 
-               if (get_config_integer(c, "lxc.start.auto") != 1) {
+               if (!my_args.ignore_auto &&
+                   get_config_integer(c, "lxc.start.auto") != 1) {
                        lxc_container_put(c);
                        continue;
                }