|
86 | 86 | verbose = iniConf.Bool("v", true, "show debug logging") |
87 | 87 | crashreport = iniConf.Bool("crashreport", false, "enable crashreport logging") |
88 | 88 | autostartMacOS = iniConf.Bool("autostartMacOS", true, "the Arduino Create Agent is able to start automatically after login on macOS (launchd agent)") |
| 89 | + installCerts = iniConf.Bool("installCerts", false, "") |
89 | 90 | ) |
90 | 91 |
|
91 | 92 | // the ports filter provided by the user via the -regex flag, if any |
@@ -220,6 +221,17 @@ func loop() { |
220 | 221 | configPath = config.GenerateConfig(configDir) |
221 | 222 | } |
222 | 223 |
|
| 224 | + if runtime.GOOS == "darwin" { |
| 225 | + if value, err := valueIni(configPath.String()); err != nil { |
| 226 | + log.Panicf("config.ini cannot be parsed: %s", err) |
| 227 | + } else if !value && cert.PromptInstallCertsSafari() { |
| 228 | + err = modifyIni(configPath.String()) |
| 229 | + if err != nil { |
| 230 | + log.Panicf("config.ini cannot be parsed: %s", err) |
| 231 | + } |
| 232 | + } |
| 233 | + } |
| 234 | + |
223 | 235 | // Parse the config.ini |
224 | 236 | args, err := parseIni(configPath.String()) |
225 | 237 | if err != nil { |
@@ -342,6 +354,13 @@ func loop() { |
342 | 354 | } |
343 | 355 | } |
344 | 356 |
|
| 357 | + // check if the certificates are expired and prompt the user to update them on macOS |
| 358 | + if runtime.GOOS == "darwin" { |
| 359 | + if *installCerts { |
| 360 | + cert.PromptExpiredCerts(config.GetCertificatesDir()) |
| 361 | + } |
| 362 | + } |
| 363 | + |
345 | 364 | // launch the discoveries for the running system |
346 | 365 | go serialPorts.Run() |
347 | 366 | // launch the hub routine which is the singleton for the websocket server |
@@ -487,3 +506,27 @@ func parseIni(filename string) (args []string, err error) { |
487 | 506 |
|
488 | 507 | return args, nil |
489 | 508 | } |
| 509 | + |
| 510 | +func modifyIni(filename string) error { |
| 511 | + cfg, err := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: false, AllowPythonMultilineValues: true}, filename) |
| 512 | + if err != nil { |
| 513 | + return err |
| 514 | + } |
| 515 | + _, err = cfg.Section("").NewKey("installCerts", "true") |
| 516 | + if err != nil { |
| 517 | + return err |
| 518 | + } |
| 519 | + err = cfg.SaveTo(filename) |
| 520 | + if err != nil { |
| 521 | + return err |
| 522 | + } |
| 523 | + return nil |
| 524 | +} |
| 525 | + |
| 526 | +func valueIni(filename string) (bool, error) { |
| 527 | + cfg, err := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: false, AllowPythonMultilineValues: true}, filename) |
| 528 | + if err != nil { |
| 529 | + return false, err |
| 530 | + } |
| 531 | + return cfg.Section("").HasKey("installCerts"), nil |
| 532 | +} |
0 commit comments