From 4d10cbd366cd4e9d0bc05c7f12073f620e20941d Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Tue, 8 Oct 2024 15:45:01 +0100 Subject: [PATCH] lxd-stophook: Adds stop hook wrapper for the lxd command This command is intended to replace the `lxd` command in the snap so that existing running containers that are stopping will call this script as part of their stop hooks. This will then "route" the command to the `lxd-user` command that will be statically compiled so that it can connect to the running LXD daemon via the unix socket to indicate the container is stopping, even after refreshing the LXD snap to a different core base snap. Signed-off-by: Thomas Parrott --- snapcraft.yaml | 1 + snapcraft/wrappers/lxd-stophook | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100755 snapcraft/wrappers/lxd-stophook diff --git a/snapcraft.yaml b/snapcraft.yaml index 285f66d84..3d6edfae5 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1602,6 +1602,7 @@ parts: organize: commands/snap-query: bin/ hooks/: snap/hooks/ + wrappers/lxd-stophook: bin/lxd wrappers/gpu-2404-custom-wrapper: bin/ wrappers/editor: bin/ wrappers/remote-viewer: bin/ diff --git a/snapcraft/wrappers/lxd-stophook b/snapcraft/wrappers/lxd-stophook new file mode 100755 index 000000000..55dc33177 --- /dev/null +++ b/snapcraft/wrappers/lxd-stophook @@ -0,0 +1,8 @@ +#!/bin/sh +# Use exec so that this script process is replaced. +# This avoids polluting the process tree with this wrapper script. +if [ "$1" = "callhook" ]; then + exec /snap/lxd/current/bin/lxd-user "$@" +fi + +exec lxd "$@"