aboutsummaryrefslogtreecommitdiff
path: root/src/property/hostname.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-05-28 11:34:13 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-05-29 08:43:35 -0700
commit451b63e0481090813d060d231a0fee30c125eb30 (patch)
tree32105a55a58430a73f807347925bc5df9914c497 /src/property/hostname.lisp
parentd551549936347ec06656f3e9063a32cac1ad327e (diff)
downloadconsfigurator-451b63e0481090813d060d231a0fee30c125eb30.tar.gz
ensure implicitly defined hosts have a hostname & add HOSTNAME:IS
Previously, the hosts representing chroots defined inline using dotted propapp notation did not have any hostname in their hostattrs, but many properties assume that every HOST object has a hostname. HOSTNAME:IS can be used to override the default value we provide in MAKE-CHILD-HOST. This approach avoids adding a hostname parameter to properties like CHROOT:OS-BOOTSTRAPPED, which would be less convenient because many chroots do not need a hostname different from their parent's. Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/hostname.lisp')
-rw-r--r--src/property/hostname.lisp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/property/hostname.lisp b/src/property/hostname.lisp
index 3930b96..5a93431 100644
--- a/src/property/hostname.lisp
+++ b/src/property/hostname.lisp
@@ -21,8 +21,15 @@
(defun domain (hostname)
(subseq hostname (min (length hostname) (1+ (position #\. hostname)))))
+(defprop is :posix (hostname)
+ "Specify that the hostname of this host is HOSTNAME.
+Useful for hosts implicitly defined inline using dotted propapp notation.
+Unlikely to be useful for hosts defined using DEFHOST."
+ (:hostattrs (push-hostattrs :hostname hostname)))
+
(defpropspec configured :posix
- (&optional (hostname (get-hostname)) (domain (domain hostname))
+ (&optional (hostname (get-hostname) hostname-supplied-p)
+ (domain (domain hostname))
&aux (short (car (split-string hostname :separator "."))))
"Set the hostname in the standard Debian way.
When HOSTNAME is an FQDN, DOMAIN is the domain part of the hostname,
@@ -30,6 +37,7 @@ defaulting to everything after the first dot. (For some hosts, the domain
should rather be the whole hostname.)"
(:desc "Hostname configured")
`(seqprops
+ ,@(and hostname-supplied-p `((is ,hostname)))
(on-change (file:has-content "/etc/hostname" ,short)
(container:when-contained (:hostname)
(cmd:single ,(strcat "hostname " short))))