Skip to content

Commit

Permalink
Added option to overwrite lepton module in use. Create output dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronRP committed Aug 11, 2023
1 parent 1d76ec9 commit 0547b48
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ builds:
- linux
goarch:
- arm
- arm64
goarm:
- "7"
ldflags: -s -w -X main.version={{.Version}}
Expand All @@ -25,6 +26,7 @@ builds:
- linux
goarch:
- arm
- arm64
goarm:
- "7"
ldflags: -s -w -X main.version={{.Version}}
Expand Down
15 changes: 15 additions & 0 deletions cmd/thermal-recorder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions cmd/thermal-recorder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0547b48

Please sign in to comment.