File tree Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package master
2
2
3
3
import (
4
4
"fmt"
5
+ "io/ioutil"
5
6
"os"
6
7
"path/filepath"
7
8
"runtime"
@@ -55,6 +56,16 @@ func (c *Config) Validate() error {
55
56
utils .SetEnv (baetyl .EnvMasterAPIKey , addr )
56
57
}
57
58
59
+ if c .SNFile != "" {
60
+ snByte , err := ioutil .ReadFile (c .SNFile )
61
+ if err != nil {
62
+ fmt .Printf ("failed to load SN file: %s" , err .Error ())
63
+ } else {
64
+ sn := strings .TrimSpace (string (snByte ))
65
+ utils .SetEnv (baetyl .EnvKeyHostSN , sn )
66
+ }
67
+ }
68
+
58
69
utils .SetEnv (baetyl .EnvKeyMasterAPIVersion , "v1" )
59
70
utils .SetEnv (baetyl .EnvKeyHostOS , runtime .GOOS )
60
71
utils .SetEnv (baetyl .EnvKeyServiceMode , c .Mode )
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ type Config struct {
16
16
Logger logger.LogInfo `yaml:"logger" json:"logger" default:"{\"path\":\"var/log/baetyl/baetyl.log\"}"`
17
17
OTALog logger.LogInfo `yaml:"otalog" json:"otalog" default:"{\"path\":\"var/db/baetyl/ota.log\",\"format\":\"json\"}"`
18
18
Grace time.Duration `yaml:"grace" json:"grace" default:"30s"`
19
+ SNFile string `yaml:"snfile" json:"snfile"`
19
20
20
21
// cache config file path
21
22
File string
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ type Config struct {
16
16
Logger logger.LogInfo `yaml:"logger" json:"logger" default:"{\"path\":\"var/log/baetyl/baetyl.log\"}"`
17
17
OTALog logger.LogInfo `yaml:"otalog" json:"otalog" default:"{\"path\":\"var/db/baetyl/ota.log\",\"format\":\"json\"}"`
18
18
Grace time.Duration `yaml:"grace" json:"grace" default:"30s"`
19
+ SNFile string `yaml:"snfile" json:"snfile"`
19
20
20
21
// cache config file path
21
22
File string
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ const (
60
60
// new envs
61
61
EnvKeyHostID = "BAETYL_HOST_ID"
62
62
EnvKeyHostOS = "BAETYL_HOST_OS"
63
+ EnvKeyHostSN = "BAETYL_HOST_SN"
63
64
EnvKeyMasterAPISocket = "BAETYL_MASTER_API_SOCKET"
64
65
EnvKeyMasterAPIAddress = "BAETYL_MASTER_API_ADDRESS"
65
66
EnvKeyMasterAPIVersion = "BAETYL_MASTER_API_VERSION"
You can’t perform that action at this time.
0 commit comments