From efc8cdc444ab9c5129252a70789c41d996a1412f Mon Sep 17 00:00:00 2001 From: Evan Jarrett Date: Tue, 9 Dec 2025 14:01:03 -0600 Subject: [PATCH] spindle/config: add abilility to override motd Signed-off-by: Evan Jarrett --- spindle/config/config.go | 1 + spindle/server.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/spindle/config/config.go b/spindle/config/config.go index ea310a6d..800d8833 100644 --- a/spindle/config/config.go +++ b/spindle/config/config.go @@ -20,6 +20,7 @@ type Server struct { LogDir string `env:"LOG_DIR, default=/var/log/spindle"` QueueSize int `env:"QUEUE_SIZE, default=100"` MaxJobCount int `env:"MAX_JOB_COUNT, default=2"` // max number of jobs that run at a time + MOTDFile string `env:"MOTD_FILE"` // optional path to custom MOTD file } func (s Server) Did() syntax.DID { diff --git a/spindle/server.go b/spindle/server.go index 6ce9464d..c09243d0 100644 --- a/spindle/server.go +++ b/spindle/server.go @@ -8,6 +8,7 @@ import ( "log/slog" "maps" "net/http" + "os" "github.com/go-chi/chi/v5" "tangled.org/core/api/tangled" @@ -246,6 +247,13 @@ func (s *Spindle) Router() http.Handler { mux := chi.NewRouter() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + if s.cfg.Server.MOTDFile != "" { + if content, err := os.ReadFile(s.cfg.Server.MOTDFile); err == nil { + w.Write(content) + return + } + s.l.Warn("failed to read custom MOTD file, using default", "path", s.cfg.Server.MOTDFile) + } w.Write(motd) }) mux.HandleFunc("/events", s.Events) -- 2.43.0