aboutsummaryrefslogtreecommitdiffhomepage
path: root/hst/fsdaemon.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-12-08 07:34:54 +0900
committerOphestra <cat@gensokyo.uk>2025-12-08 07:38:47 +0900
commit0c38fb7b6a17bed9392a4cf46fc752bc2de8eb18 (patch)
tree44a762beb44193693ada3c97c368e4f12a4ec054 /hst/fsdaemon.go
parent357cfcddeea14d6babacf7ae8f77e0bad7b24ee5 (diff)
hst: expose daemon as fs entry
This is slightly counterintuitive, but it turned out well under this framework since the daemon backs its target file. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'hst/fsdaemon.go')
-rw-r--r--hst/fsdaemon.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/hst/fsdaemon.go b/hst/fsdaemon.go
new file mode 100644
index 00000000..fd3f3758
--- /dev/null
+++ b/hst/fsdaemon.go
@@ -0,0 +1,48 @@
+package hst
+
+import (
+ "encoding/gob"
+
+ "hakurei.app/container/check"
+)
+
+func init() { gob.Register(new(FSDaemon)) }
+
+// FilesystemDaemon is the type string of a daemon.
+const FilesystemDaemon = "daemon"
+
+// FSDaemon represents a daemon to be started in the container.
+type FSDaemon struct {
+ // Pathname indicating readiness of daemon.
+ Target *check.Absolute `json:"dst"`
+ // Absolute pathname to daemon executable file.
+ Exec *check.Absolute `json:"path"`
+ // Arguments (excl. first) passed to daemon.
+ Args []string `json:"args"`
+}
+
+func (d *FSDaemon) Valid() bool { return d != nil && d.Target != nil && d.Exec != nil }
+
+func (d *FSDaemon) Path() *check.Absolute {
+ if !d.Valid() {
+ return nil
+ }
+ return d.Target
+}
+
+func (d *FSDaemon) Host() []*check.Absolute { return nil }
+
+func (d *FSDaemon) Apply(z *ApplyState) {
+ if !d.Valid() {
+ return
+ }
+ z.Daemon(d.Target, d.Exec, d.Args...)
+}
+
+func (d *FSDaemon) String() string {
+ if !d.Valid() {
+ return "<invalid>"
+ }
+
+ return "daemon:" + d.Target.String()
+}