mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-06-16 07:53:44 +00:00
Export LXC_TARGET env variable in stop hook
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
114387972a
commit
c154af98c1
@ -1566,7 +1566,19 @@ mknod errno 0
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<option>LXC_TARGET</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Only for the stop hook. Is set to "stop" for a container
|
||||||
|
shutdown or "reboot" for a container reboot.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
</refsect2>
|
</refsect2>
|
||||||
<refsect2>
|
<refsect2>
|
||||||
<title>Logging</title>
|
<title>Logging</title>
|
||||||
|
@ -522,8 +522,17 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
namespaces[namespace_count] = NULL;
|
namespaces[namespace_count] = NULL;
|
||||||
|
|
||||||
|
if (handler->conf->reboot && setenv("LXC_TARGET", "reboot", 1)) {
|
||||||
|
SYSERROR("failed to set environment variable for stop target");
|
||||||
|
}
|
||||||
|
if (!handler->conf->reboot && setenv("LXC_TARGET", "stop", 1)) {
|
||||||
|
SYSERROR("failed to set environment variable for stop target");
|
||||||
|
}
|
||||||
|
|
||||||
if (run_lxc_hooks(name, "stop", handler->conf, handler->lxcpath, namespaces))
|
if (run_lxc_hooks(name, "stop", handler->conf, handler->lxcpath, namespaces))
|
||||||
ERROR("failed to run stop hooks for container '%s'.", name);
|
ERROR("failed to run stop hooks for container '%s'.", name);
|
||||||
|
|
||||||
while (namespace_count--)
|
while (namespace_count--)
|
||||||
free(namespaces[namespace_count]);
|
free(namespaces[namespace_count]);
|
||||||
for (i = 0; i < LXC_NS_MAX; i++) {
|
for (i = 0; i < LXC_NS_MAX; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user