aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-02-20 10:35:06 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-02-20 13:16:38 -0700
commitb66eb156bf0f7a4d1595e6fa7b46dda66db69790 (patch)
treef000a3253f4c4072cbfa7a9c7cb02feb5d4e7c38 /src
parentea60c341174e12f8880b97d2b490d0c0e5e85975 (diff)
downloadconsfigurator-b66eb156bf0f7a4d1595e6fa7b46dda66db69790.tar.gz
add LXC:USER-CONTAINER-STOPPED
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src')
-rw-r--r--src/package.lisp1
-rw-r--r--src/property/lxc.lisp9
2 files changed, 9 insertions, 1 deletions
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 <spwhitton@spwhitton.name>
+;;; Copyright (C) 2021, 2023 Sean Whitton <spwhitton@spwhitton.name>
;;; 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."