2021-09-20 02:03:47 +08:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"runtime"
|
|
|
|
|
|
|
|
"github.com/gravitl/netmaker/netclient/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
func InstallDaemon(cfg config.ClientConfig) error {
|
|
|
|
os := runtime.GOOS
|
|
|
|
var err error
|
2021-10-03 00:28:17 +08:00
|
|
|
|
|
|
|
interval := "15"
|
|
|
|
if cfg.Server.CheckinInterval != "" {
|
|
|
|
interval = cfg.Server.CheckinInterval
|
|
|
|
}
|
|
|
|
|
2021-09-20 02:03:47 +08:00
|
|
|
switch os {
|
|
|
|
case "windows":
|
|
|
|
err = SetupWindowsDaemon()
|
|
|
|
case "darwin":
|
2021-10-03 00:28:17 +08:00
|
|
|
err = SetupMacDaemon(interval)
|
2021-09-20 02:03:47 +08:00
|
|
|
case "linux":
|
2021-10-03 00:28:17 +08:00
|
|
|
err = SetupSystemDDaemon(interval)
|
2021-09-20 02:03:47 +08:00
|
|
|
default:
|
|
|
|
err = errors.New("this os is not yet supported for daemon mode. Run join cmd with flag '--daemon off'")
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|