Skip to content

Commit

Permalink
lxd-stophook: Adds stop hook wrapper for the lxd command
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
tomponline committed Oct 9, 2024
1 parent 34dd519 commit 4d10cbd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
8 changes: 8 additions & 0 deletions snapcraft/wrappers/lxd-stophook
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit 4d10cbd

Please sign in to comment.