From b66eb156bf0f7a4d1595e6fa7b46dda66db69790 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 20 Feb 2023 10:35:06 -0700 Subject: add LXC:USER-CONTAINER-STOPPED Signed-off-by: Sean Whitton --- debian/copyright | 2 +- doc/news.rst | 2 ++ src/package.lisp | 1 + src/property/lxc.lisp | 9 ++++++++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/debian/copyright b/debian/copyright index c2222ad..a40266c 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,7 +1,7 @@ Consfigurator Lisp declarative configuration management system -Copyright (C)2015-2018, 2020-2022 Sean Whitton +Copyright (C)2015-2018, 2020-2023 Sean Whitton Copyright (C)2021-2022 David Bremner This program is free software: you can redistribute it and/or diff --git a/doc/news.rst b/doc/news.rst index 72fc8e6..29951ab 100644 --- a/doc/news.rst +++ b/doc/news.rst @@ -30,6 +30,8 @@ you should review this document and see if your consfig needs updating. lists. On Debian bullseye and older this will cause apt updates to emit harmless warnings. +- Add LXC:USER-CONTAINER-STOPPED. + 1.2.0 (2022-11-29) ------------------ diff --git a/src/package.lisp b/src/package.lisp index a576d3c..856d75a 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -951,6 +951,7 @@ (#:systemd #:consfigurator.property.systemd)) (:export #:installed #:user-container-started + #:user-container-stopped #:when-user-container-running #:user-containers-autostart #:usernet-veth-usable-by diff --git a/src/property/lxc.lisp b/src/property/lxc.lisp index 19b2c2d..bd4bf43 100644 --- a/src/property/lxc.lisp +++ b/src/property/lxc.lisp @@ -1,6 +1,6 @@ ;;; Consfigurator -- Lisp declarative configuration management system -;;; Copyright (C) 2021 Sean Whitton +;;; Copyright (C) 2021, 2023 Sean Whitton ;;; This file is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by @@ -45,6 +45,13 @@ HOST is a HOST value, start the container whose name is HOST's hostname.)" (:check (or (service:no-services-p) (user-container-active-p host owner))) (:apply (lxc-cmd owner "lxc-unpriv-start" "-n" (get-hostname host)))) +(defprop user-container-stopped :posix (host &optional owner) + "Ensure the LXC unprivileged container for the host designated by HOST owned +by OWNER, defaulting to the current user, is stopped." + (:desc #?"LXC container ${(get-hostname host)} stopped") + (:check (not (user-container-active-p host owner))) + (:apply (lxc-cmd owner "lxc-stop" "-n" (get-hostname host)))) + (defmacro when-user-container-running ((host &key owner) &body propapps) "Apply PROPAPPS only when the unprivileged LXC for the host designated by HOST and owned by OWNER, defaulting to the current user, is already started." -- cgit v1.2.3