Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion beszel/cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"os"
"strings"
"io/ioutil"
)

func main() {
Expand All @@ -25,7 +26,16 @@ func main() {
if pubKeyEnv, exists := os.LookupEnv("KEY"); exists {
pubKey = []byte(pubKeyEnv)
} else {
log.Fatal("KEY environment variable is not set")
keyFile := os.Getenv("KEY_FILE")
if keyFile != "" {
if keyData, err := ioutil.ReadFile(keyFile); err == nil {
pubKey = keyData
} else {
log.Fatalf("Failed to read key from file '%s': %v", keyFile, err)
}
} else {
log.Fatal("KEY environment variable is not set, and KEY_FILE environment variable is not set")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think should be changed to : KEY environment variable is not set or KEY_FILE environment variable is not set

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to "Must set KEY or KEY_FILE environment variable." Slightly more concise.

}
}

addr := ":45876"
Expand Down