From 0547b48cb47bbcb19e8e3c30e68ba5452bc017eb Mon Sep 17 00:00:00 2001 From: cam Date: Fri, 11 Aug 2023 18:46:03 +1200 Subject: [PATCH] Added option to overwrite lepton module in use. Create output dir. --- .goreleaser.yml | 2 ++ cmd/thermal-recorder/config.go | 15 +++++++++++++++ cmd/thermal-recorder/main.go | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/.goreleaser.yml b/.goreleaser.yml index 561f7c1..b4216b8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -15,6 +15,7 @@ builds: - linux goarch: - arm + - arm64 goarm: - "7" ldflags: -s -w -X main.version={{.Version}} @@ -25,6 +26,7 @@ builds: - linux goarch: - arm + - arm64 goarm: - "7" ldflags: -s -w -X main.version={{.Version}} diff --git a/cmd/thermal-recorder/config.go b/cmd/thermal-recorder/config.go index 145232a..342c77a 100644 --- a/cmd/thermal-recorder/config.go +++ b/cmd/thermal-recorder/config.go @@ -17,6 +17,10 @@ package main import ( + "log" + "os" + "strings" + goconfig "github.com/TheCacophonyProject/go-config" "github.com/TheCacophonyProject/thermal-recorder/motion" "github.com/TheCacophonyProject/thermal-recorder/recorder" @@ -42,6 +46,17 @@ func (c *Config) LoadMotionConfig(cameraModel string) error { if err != nil { return err } + + // Module override, just a temp fix for now. + overrideFile := "/etc/cacophony/lepton-module" + content, err := os.ReadFile(overrideFile) + if err == nil { + cameraModel = strings.TrimSpace(string(content)) + log.Println("Camera model override: " + cameraModel) + } else if !os.IsNotExist(err) { + return err + } + motionConfig, err := motion.NewConfig(configRW, cameraModel) if err != nil { return err diff --git a/cmd/thermal-recorder/main.go b/cmd/thermal-recorder/main.go index 03ca456..c3c99c9 100644 --- a/cmd/thermal-recorder/main.go +++ b/cmd/thermal-recorder/main.go @@ -161,6 +161,10 @@ func runMain() error { return nil } + if _, err := os.Stat(conf.OutputDir); os.IsNotExist(err) { + return os.MkdirAll(conf.OutputDir, 0755) + } + log.Println("starting d-bus service") err = startService(conf.OutputDir) if err != nil {